How do I fix plotting my boxplot?
<p>I am trying to plot my boxplot but I am getting a 'nonetype attribute error.' </p>

<p>Please, how can I fix this? </p>

<p>My Code:</p>

<pre><code>Failed = train_df['Fees'][train_df['Passedornot'] == 0]
Passed = train_df['Fees'][train_df['Passedornot'] ==1]


average_fees = DataFrame([mean(Passed), mean(Failed)])
std_fees = DataFrame([standard_deviation(Passed), standard_deviation(Failed)])
fig, axis4 = plt.subplots(1,1)
train_df['Fees'].plot(kind='hist', figsize=(15,5),bins=100, xlim=(0,30), ax=axis4)


fig, axis5 = plt.subplots(1,1)
average_fees.plot(kind='', legend=False, ax=axis5)
</code></pre>

<p>Error:</p>

<pre><code>average_fees.plot(kind='bp', legend=False, ax=axis5)
AttributeError: 'NoneType' object has no attribute 'plot'
</code></pre>

<p>Sample of Data:</p>

<pre><code>    Name        Sex     Age Score    Passedornot Fees
    Tim Cole    male    18   148          1       90
    Ellen James female  47   143          1       80
    Jerome Miles male   62   144          0       80
    Waltz Albert male   27   153          0       90
</code></pre>

<p>Not sure what happens there, but I think your <code>average_fees</code> is not a proper pandas dataframe. Furthermore, my compiler is complaining about <code>kind='bp'</code>. That is one of the reasons why the community always asks for a fully functional working example.</p>

<p>Here is a working snippet for Python3, run in a Jupyter notebook, for the piece of data you provided saved to a file sample.txt:</p>

<pre><code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
train_df = pd.read_csv('sample.txt', sep='\t')
# train_df.head()
Failed = train_df['Fees'][train_df['Passedornot'] == 0]
Passed = train_df['Fees'][train_df['Passedornot'] == 1]
average_fees = pd.DataFrame([np.mean(Passed), np.mean(Failed)])
std_fees = pd.DataFrame([np.std(Passed), np.std(Failed)])

fig1, axis4 = plt.subplots(1,1)
n, bins, patches = plt.hist(train_df.Fees, 100, linewidth=1)
plt.axis([0, 100, 0, 3])
plt.show()

fig2, axis5 = plt.subplots(1,1)
# print(type(average_fees))
average_fees.boxplot(return_type='axes')
</code></pre>

python dataframe