python - 熊猫 DateOffset 函数
问题描述
以下会返回是否正常True
?
这背后的想法是什么?
import pandas as pd
t = pd.Timestamp('2017-01-01 00:00:00')
t + pd.DateOffset(month=1) == t
解决方案
months
改为用于month
添加价值1
,而不是替换,谢谢@splash58:
print (t + pd.DateOffset(months=1) == t)
False
详情:
print (t + pd.DateOffset(month=1))
2017-01-01 00:00:00
print (t + pd.DateOffset(months=1))
2017-02-01 00:00:00
如果检查pandas.tseries.offsets.DateOffset.html
:
**kwds
Temporal parameter that add to or replace the offset value.
Parameters that add to the offset (like Timedelta):
years
months
weeks
days
hours
minutes
seconds
microseconds
nanoseconds
Parameters that replace the offset value:
year
month
day
weekday
hour
minute
second
microsecond
nanosecond
推荐阅读
- angularjs - setValidation 时应用角度摘要
- r - 如何在 r 中将 9 列重新排列为 3?
- amazon-web-services - AWS - 地理位置标头 - CloudFront - LambdaEdge - S3 存储桶方案不起作用
- javascript - TypeScript - 类型“布尔”不满足返回布尔值的类型的约束
- teradata - Informatica 并行作业在 Teradata 上创建 mload 问题
- php - 加载资源失败:服务器响应状态为 500 () PHP 网站
- isabelle - 伊莎贝尔理论“变量“返回”仅发生在右手边”
- r - Shiny (R) 中的文本分辨率
- javascript - 如何关闭在 cypress 中浏览网站时可能随时出现的弹出警报?
- php - PHP 获取 UTC/GMT 时间,四舍五入到最近的分钟,并格式化为 yyyyMMddHHmm