Reputation: 1243
My data is a pandas dataframe called 'T':
A B C
Date
2001-11-13 30.1 2 3
2007-02-23 12.0 1 7
The result of T.index is
<class 'pandas.tseries.index.DatetimeIndex'>
[2001-11-13, 2007-02-23]
Length: 2, Freq: None, Timezone: None
So I know that the index is a time series. But when I plot it using ax.plot(T)
I don't get a times series on the x axis!
I will only ever have two data points so how do I get the dates in my graph (i.e. two dates at either end of the x axis)?
Upvotes: 0
Views: 419
Reputation: 16528
Use the implemented pandas command:
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()
You can access the axis using
ax = df2.plot()
Upvotes: 3