我有一个数据框,其中一列的日期时间类型为其他浮点数。当我在指定kind ='bar'的同时绘制数据框时,得到了该图。但是,如果我未指定bar(即我想要折线图),则会收到错误
我的数据框:
DATE Act fig1 Fig2 Fig3
0 2019-01-27 46027.37998 58285.4684 41219.228434982215 45064.25892364141
1 2019-01-28 55069.98999 57206.1157 48344.78846433562 48890.21159327326
2 2019-01-29 49297.31 56990.239 48088.530894421005 46813.0926774736
3 2019-01-30 53094.96997 58285.4684 52657.76140749706 51054.21267889635
4 2019-01-31 68815.61003 66488.6087 61910.84509456238 58310.31961711759
5 2019-02-01 82316.24003 71397.8652 75604.92380324422 81543.81974813671
6 2019-02-02 66563.15001 63090.4584 67020.6870408009 71332.9316668577
7 2019-02-03 39375.72 47914.6791 35901.756450152665 46120.40005916364
8 2019-02-04 41562.65001 52081.1774 43750.363854695555 47366.99449131916
9 2019-02-05 39364.66001 56247.6654 39848.36712727402 46162.050789218716
10 2019-02-06 44340.77 60414.1637 44113.74894783513 40196.60401064496
11 2019-02-07 54721.35002 66663.9009 49005.105053347426 55410.79149194656
12 2019-02-08 59968.76002 69580.4517 56733.77675923111 72458.28140044466
13 2019-02-09 53178.19001 63747.3603 42389.23467005711 64498.91389851934
14 2019-02-10 30877.04998 43593.2373 28313.94468739357 38429.596789119816
15 2019-02-11 34470.58003 44290.7238 35604.17450889417 45831.545410152874
16 2019-02-12 39826.35997 45336.9689 35920.76086080937 45535.88297224278
17 2019-02-13 42989.98009 47778.1869 38911.1770698405 48524.29063181302
18 2019-02-14 49793.46996 54055.6164 45399.86041447529 55548.64846121237
19 2019-02-15 47080.76999 61030.5323 59848.07905886687 67752.30460448604
20 2019-02-16 47249.78008 52660.6332 54688.47435532434 62532.07407812223
21 2019-02-17 26331.26005 43561.6887 30852.52110020275 40166.70663955889
22 2019-02-18 25287.14 47433.8385 34835.54664477423 43847.75648201314
23 2019-02-19 32967.26997 51305.9884 34425.44824792564 42824.853554862006
24 2019-02-20 30504.48001 55178.1383 34378.403143393065 42577.48304603604
25 2019-02-21 44767.48002 61179.968 43722.93426281729 52739.538652256015
26 2019-02-22 44889.52998 67762.6177 58421.63331088934 67469.02284121823
27 2019-02-23 51204.47002 60792.7479 53582.06434917556 61629.110622570355
dff.info()如下
<class 'pandas.core.frame.DataFrame'>
Int64Index: 28 entries, 0 to 27
Data columns (total 5 columns):
DATE 28 non-null datetime64[ns]
Act 28 non-null float64
fig1 28 non-null float64
Fig2 28 non-null float64
Fig3 28 non-null float64
dtypes: datetime64[ns](1), float64(4)
memory usage: 1.3 KB
以下线图的正确性
dff.set_index('DATE').plot(kind='bar')
以下一行给出了错误-float()参数必须是字符串或数字,而不是'Period'
dff.set_index('DATE').plot()
我不确定,但是我记得在一列中以datetime类型绘制数据帧没有问题。新版本的Pandas是否有问题?我能做什么?我的熊猫版本是0.24.2。
谢谢。
答案 0 :(得分:0)
这是熊猫中的错误,降级为熊猫0.20.2
将解决此问题。您可以通过以下方式实现:
pip install 'pandas==0.22.0'