![](/img/trans.png)
[英]jupyter notebook and spyder not launching from anaconda prompt.However it was working fine earlier. It is giving me the following error:
[英]Jupyter notebook is giving me error for correct codes
我的 jupyter 筆記本對正確的代碼給出了錯誤。 具體來說這是我的錯誤: AttributeError: 'NoneType' object has no attribute 'plot'
我再次檢查,我已經重新編寫了我的代碼,我還逐個單元格地運行了我的代碼,並且還使用Run all
。 但不工作。 您的幫助將不勝感激。
這是我的代碼
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)
這是我的錯誤 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'
我的 plot 也給出了錯誤。 這是我的 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")
這是我的 plot 錯誤 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'
您的堆棧跟蹤准確地指示了有問題的行:
----> 2 cleaned_data_count = recent_grads.count()
...
AttributeError: 'NoneType' object has no attribute 'count'
顯然recent_grads是None ,因此您不能對其調用任何方法,包括count (以及您稍后嘗試調用的plot )。
所以上一條指令中的read_csv可能有問題。 我想輸入文件存在,否則會更早拋出另一個異常。 也許這個文件是空的?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.