Pandas dataframe error: matplotlib.axes._subplots.AxesSubplot

In case you want to see the plot inline, use

%matplotlib inline

in the header (before the imports).

If you want to show the graphic in a window, add the line

plt.show()

at the end (make sure you have imported import matplotlib.pyplot as plt in the header).


## importing libraries
## notice to import %matplotlib inline to plot within notebook
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import datetime


## making a DF like yours
df2 = pd.DataFrame([], columns=['dataFor','total'])
df2['dataFor'] = [datetime.datetime(2013, 9, 11),datetime.datetime(2013, 9, 12),datetime.datetime(2013, 9, 13),datetime.datetime(2013, 9, 14),datetime.datetime(2013, 9, 15),datetime.datetime(2013, 9, 16),datetime.datetime(2013, 9, 17)]
df2['total'] = [11,15,17,18,19,20,21]

## notice date are datetimes objects and not strings
df2.plot(kind='line')

output:

enter image description here

if one wants to improve graph layout:

plt.figure(figsize=(20,10))
plt.plot(df2.dataFor, df2.total, linewidth=5)
plt.plot(df2.dataFor, df2.total, '*', markersize=20, color='red')
plt.xticks(fontsize=20, fontweight='bold',rotation=90)
plt.yticks(fontsize=20, fontweight='bold')
plt.xlabel('Dates',fontsize=20, fontweight='bold')
plt.ylabel('Total Count',fontsize=20, fontweight='bold')
plt.title('Counts per time',fontsize=20, fontweight='bold')
plt.tight_layout()

enter image description here