温度热图:工作日/年错误

问题描述 投票:1回答:1

我想从这个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

enter image description here

结果系列返回良好的结果

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

你有解决方案吗?

python-3.x csv time-series heatmap temperature
1个回答
1
投票

我只是找到解决方案...我的csv文件有法国数据格式01/01/2009而不是2009-01-01 ...

© www.soinside.com 2019 - 2024. All rights reserved.