我想总结一下不同年份的数据点。所以我想绘制一个不同年份的图表,并从一个指定的属性中总结出一个图表,所以让我们来看看2011 -2015年的硬币
所以我选择pandas作为我使用的数据帧:
Summerize the data point (way 1)
testn = test.groupby(by=[test.index.year,test.index.month]).sum()
print(testn['SalesDateTime'])
print (type(testn))
这给了我一个错误。这个错误告诉我没有属性year或month?
enter code here
Summerize the data point (way 1)
testn = test.groupby(by=[test.index.year,test.index.month]).sum()
print(testn['SalesDateTime'])
#print (type(testn))
Summerize the data point (way 2)
nieuw = test.groupby(by=[test.index.month, test.index.year])
print(nieuw)
testn.plot("SalesDateTime","Coins",)
plt.show(testn)
发布于 2019-04-20 10:03:53
我认为没有DatetimeIndex
,所以需要to_datetime
test.index = pd.to_datetime(test.index)
testn = test.groupby(by=[test.index.year,test.index.month]).sum()
或者:
testn = (test.groupby(by=[test.index.year.rename('year'),
test.index.month.rename('month')]).sum().reset_index())
https://stackoverflow.com/questions/55772339
复制相似问题