我正在尝试通过熊猫TimeGrouper从某些日期创建频率表,但收到以下错误消息
输入:
t = pd.to_datetime(t)
t = pd.Series(t)
t
输出:
0 2019-04-10 10:49:00
1 2019-04-10 10:49:00
2 2019-04-10 10:49:00
3 2019-04-10 10:49:00
4 2019-04-10 10:49:00
5 2019-04-10 10:48:00
6 2019-04-10 10:48:00
7 2019-04-10 10:48:00
8 2019-04-10 10:48:00
9 2019-04-10 10:48:00
Name: tweet.created_at, dtype: datetime64[ns]
输入:
t.groupby(pd.core.resample.TimeGrouper('H').count().plot(kind='bar'))
输出:
Error: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'
答案 0 :(得分:0)
我使用这个技巧来解决:
t.reset_index().set_index(1).resample('H').count().plot()