【发布时间】:2017-02-10 10:54:55
【问题描述】:
我有一个 pandas 日期框架,下面的代码有效
df['hour'] = df.index.hour
df['c'] = df['hour'].apply(circadian)
但我试图减少制作“小时”列的需要,使用以下代码
df['c'] = df.apply(lambda x: circadian(x.index.hour), axis=1)
但我收到错误消息
AttributeError: ("'Index' object has no attribute 'hour'", u'occurred at index 2015-09-25 01:00:00')
有人知道怎么做吗?
【问题讨论】: