我一直在尝试解决最近2个小时的问题,并一直在简短地介绍如何解决此错误-看过youtube视频,经历了stackoverflow,但我不知道哪里出了问题.
请注意,我正在使用Anaconda和Jupyter笔记本以及Python 3进行作业.
#Import Libraries
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
#Plotly Tools
from plotly.offline import init_notebook_mode,iplot
init_notebook_mode(connected=True)
import plotly.graph_objs as go
import plotly.offline as offline
offline.init_notebook_mode()
from plotly import tools
import plotly.tools as tls
init_notebook_mode(connected=True)
#Import CSV as a Pandas Dataframe
fp = pd.read_csv("gun-violence-data_01-2013_03-2018.csv")
#Confirm that dataset was properly loaded
fp.head()
导入库后,我对数据进行了一些清理,并将其放入数据帧“ fp_clean”中.当我尝试绘制时:
temp = fp_clean["state"].value_counts().head(30)
temp.iplot(kind='bar')
我不断收到以下错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-25-261d72eb2ae5> in <module>
4 #temp.plot(kind='bar')
5 temp = fp_clean["state"].value_counts().head(30)
----> 6 temp.iplot(kind='bar')
7 #temp.iplot(kind='bar',xTitle = 'State name',yTitle = "# of incidents",title = 'Top States with highest number of Gun Violence',filename='Bar')
8 #temp.plot(kind='bar')
~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self,name)
4374 if self._info_axis._can_hold_identifiers_and_holds_name(name):
4375 return self[name]
-> 4376 return object.__getattribute__(self,name)
4377
4378 def __setattr__(self,name,value):
AttributeError: 'Series' object has no attribute 'iplot'
任何帮助将不胜感激!
谢谢!
最佳答案