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'
我可以理解我的订单日期列不在时间戳格式中。我不知道如何转换它。
有什么想法吗?