Pandas dataframe error: matplotlib.axes._subplots.AxesSubplot

vbd picture vbd · Jan 27, 2017 · Viewed 51.1k times · Source
import pandas as pd
import matplotlib.pyplot as plt

file = 'd:\\a\\pandas\\test.xlsx'
data = pd.ExcelFile(file)
df1 = data.parse('Link')
df2 = df1[['dataFor', 'total']]
df2

returns:

enter image description here

 print (type(df2))

tells me

class 'pandas.core.frame.DataFrame'

trying

df2.plot(kind='line')

returns

matplotlib.axes._subplots.AxesSubplot at 0xe4241d0

Could it be the environment?

Jupyter notebook > Help > About

The version of the notebook server is 4.2.3 and is running on:
Python 3.5.2 |Anaconda 4.2.0 (32-bit)| (default, Jul  5 2016, 11:45:57) [MSC    v.1900 32 bit (Intel)]

Where is the fault? Is matplotlib still the standard or should beginners go for Bokeh or for both?

Answer

ImportanceOfBeingErnest picture ImportanceOfBeingErnest · Jan 27, 2017

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).