Pd.todate时间比较不起作用python

发布于 2025-01-12 19:01:25 字数 412 浏览 0 评论 0原文

我正在尝试根据最大日期 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)

enter image description here

the datatype is datetime64[ns]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文