以下内容返回True
是否正常?
其背后的想法是什么?
import pandas as pd
t = pd.Timestamp('2017-01-01 00:00:00')
t + pd.DateOffset(month=1) == t
答案 0 :(得分:1)
使用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