Use index in pandas to plot data
You can use reset_index
to turn the index back into a column:
monthly_mean.reset_index().plot(x='index', y='A')
Look at monthly_mean.reset_index()
by itself- the date is no longer in the index, but is a column in the dataframe, which is now just indexed by integers. If you look at the documentation for reset_index
, you can get a bit more control over the process, including assigning sensible names to the index.
Try this,
monthly_mean.plot(y='A', use_index=True)
monthly_mean.plot(y='A')
Uses index as x-axis by default.