Pd.todate时间比较不起作用python
我正在尝试根据最大日期 2023 年 11 月 15 日分配一个值。正如您在存储最大日期的列中看到的,截止日期的两侧都有几个,但只有 else 语句才会赋值。看来我编写日期的方式可能存在问题,导致比较不起作用。我暂时尝试添加 0,但它会给我一个关于无效语法的错误。有什么想法吗?
out1['churned']=np.where(out1['time']<=pd.to_datetime(2034-11-15),1,0)
数据类型为 datetime64[ns]
I am trying to assign a value based on a max date of 11-15-2023. As you can see in the column where the max date is stored, several are on both sides of the cut off date, yet only the else statement will assign a value. It seems that there could be an issue with the way I've written the date that the comparison is not working. I've tried adding the 0's for the time, but it will give me an error about invalid syntax. Any ideas ?
out1['churned']=np.where(out1['time']<=pd.to_datetime(2034-11-15),1,0)
the datatype is datetime64[ns]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论