我想从这个csv文件https://easymagic-secret.fr/codes/test5-ko2.csv获得一份简单的年度数据热图。
当我启动此代码时,我的热图会返回错误的结果
from pandas import Series
from pandas import DataFrame
from pandas import TimeGrouper
from matplotlib import pyplot
series = Series.from_csv('https://easymagic-secret.fr/codes/test5-ko2.csv',sep=';', header=0)
groups = series.groupby(TimeGrouper('A'))
years = DataFrame()
for name, group in groups:
years[name.year] = group.values
years = years.T
pyplot.matshow(years, fignum = True, aspect='auto',cmap=pyplot.cm.coolwarm)
pyplot.show()
years
结果系列返回好结果
from pandas import Series
from pandas import DataFrame
from pandas import TimeGrouper
from matplotlib import pyplot
#series = Series.from_csv('dataset/daily-minimum-temperatures.csv', header=0)
series = Series.from_csv('https://easymagic-secret.fr/codes/test5-ko2.csv',sep=';', header=0)
series
Out :
Date
2009-01-01 2.6
2009-02-01 0.1
2009-03-01 0.4
2009-04-01 -0.6
2009-05-01 0.3
2009-06-01 -4.2
2009-07-01 -3.4
你有解决方案吗?
答案 0 :(得分:1)
我只是找到解决方案......我的csv文件有法国数据格式01/01/2009而不是2009-01-01 ......