Plot giving error

My jupyter notebook is giving error for codes that are correct. specifically this is my error: AttributeError: ‘NoneType’ object has no attribute ‘plot’

I have check and check again, i have re written my codes, i also ran my code cell by cell and also use Run all . but not working. Your help will sincerely be appreciated.

here is my code

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline

recent_grads = pd.read_csv("recent-grads.csv")
cleaned_data_count = recent_grads.count()
print (cleaned_data_count)

This is my error output

AttributeError                            Traceback (most recent call last)
<ipython-input-6-e0fa232c36bf> in <module>
      1 # Look up the number of rows to ascertain if data has been droped
----> 2 cleaned_data_count = recent_grads.count()
      3 print (cleaned_data_count)

AttributeError: 'NoneType' object has no attribute 'count'

my plot also gives error. Here is the code for my plot

recent_grads.plot(x="Sample_size", y="Median", kind = "scatter", title = "Sample_size VS Median")
recent_grads.plot(x="Sample_size", y="Unemployment_rate", kind = "scatter", title = "Sample_size VS Uemployemny")
recent_grads.plot(x="Full_time", y="Median", kind = "scatter", title = "Full_time VS Median")
recent_grads.plot(x="ShareWomen", y="Unemployment_rate", kind = "scatter", title = "Sharewoman VS Unemployment_rate")
recent_grads.plot(x="Men",y="Median", kind = "scatter", title = "Men VS Median")
recent_grads.plot(x="Women",y="Median", kind = "scatter", title = "Sample_size VS Median")

here is my plot error output

AttributeError                            Traceback (most recent call last)
<ipython-input-23-6d7d435b7c0f> in <module>
----> 1 recent_grads.plot(x="Sample_size", y="Median", kind = "scatter", title = "Sample_size VS Median")
      2 recent_grads.plot(x="Sample_size", y="Unemployment_rate", kind = "scatter", title = "Sample_size VS Uemployemny")
      3 recent_grads.plot(x="Full_time", y="Median", kind = "scatter", title = "Full_time VS Median")
      4 recent_grads.plot(x="ShareWomen", y="Unemployment_rate", kind = "scatter", title = "Sharewoman VS Unemployment_rate")
      5 recent_grads.plot(x="Men",y="Median", kind = "scatter", title = "Men VS Median")

AttributeError: 'NoneType' object has no attribute 'plot'

Here is my Jupyter notebook file
Visualizing Earnings Based On College Majors.ipynb (27.3 KB)

Click here to view the jupyter notebook file in a new tab

I have noticed from your notebook , you have some confusion in investigating missing values step. Please use below code and understand it completely before moving to plotting section. I am assuming this should fix the issue , if issue still persists please reply back

#shape before dropping NAN vaues
recent_grads.shape

#Investigating Missing Values
recent_grads.isnull().sum()

#Drop missing values
recent_grads.dropna(inplace =True)

#shape after dropping NAN vaues
recent_grads.shape

#Investigating Missing Values after dropping NAN
recent_grads.isnull().sum()

@vasheyy Thank you very much for your support. It works

1 Like