furniture = furniture.groupby('Order Date')['Sales'].sum().reset_index()
print(furniture.head())
输出:
Order Date Sales
0 2014-01-06 2573.820
1 2014-01-07 76.728
2 2014-01-10 51.940
3 2014-01-11 9.940
4 2014-01-13 879.939
当我想获得每月销售平均值时,请添加
y = furniture['Sales'].resample('MS').mean()
输出:
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'
我可以理解我的“订购日期”列不是时间戳格式的,我不知道如何转换。
有什么想法吗?