绘制熊猫时间数据

时间:2014-08-18 11:05:10

标签: python matplotlib pandas

我的数据是一个名为'T'的pandas数据框:

               A  B  C
Date                  
2001-11-13  30.1  2  3
2007-02-23  12.0  1  7

T.index的结果是

<class 'pandas.tseries.index.DatetimeIndex'>
[2001-11-13, 2007-02-23]
Length: 2, Freq: None, Timezone: None

所以我知道索引是一个时间序列。但是当我使用ax.plot(T)绘制它时,我没有在x轴上获得时间序列!

我只会有两个数据点,所以如何获取图表中的日期(即x轴两端的两个日期)?

Not a time series graph

1 个答案:

答案 0 :(得分:3)

使用已实施的pandas命令:

In[211]: df2
Out[211]: 
               A  B  C
1970-01-01  30.1  2  3
1980-01-01  12.0  1  7
In[212]: df2.plot()
Out[212]: <matplotlib.axes.AxesSubplot at 0x105224e0>
In[213]: plt.show()

您可以使用

访问轴
ax = df2.plot()

enter image description here

相关问题