【发布时间】:2020-05-05 15:03:01
【问题描述】:
daily['annual'] = (daily.index - daily.index[0].days / 356.
AttributeError: 'Timestamp' object has no attribute 'days'
属性 days 似乎已被弃用。我想建立一个从第 1 天开始增加的计数器,并测量已经过去了多少年。
我尝试使用属性 dayofyear。但后来我收到以下错误:
TypeError: unsupported operand type(s) for -: 'DatetimeIndex' and 'float'
这个问题有解决办法吗?
【问题讨论】:
-
您在这里的具体目标是什么?
-
你用括号弄错了。是
(daily.index - daily.index[0]).days / 365(而且是365,不是356)。
标签: pandas timestamp time-series