[英]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.