我試圖與一些在線的數據玩,遇到了一些麻煩密謀它由於繪圖功能如何解決AttributeError:'Series'對象沒有屬性'find'?
# Reading data from an online data sets
import pandas as pd
import requests, zipfile, StringIO
r = requests.get('https://archive.ics.uci.edu/ml/machine-learning-databases/00287/Activity Recognition from Single Chest-Mounted Accelerometer.zip')
z = zipfile.ZipFile(StringIO.StringIO(r.content))
activity_files = [name for name in z.namelist() if name.endswith('.csv')]
# Loading it to a pandas dataframe
z_data = z.read(activity_files[4]).split('\n')
activity_data = pd.DataFrame([z.split(',') for z in z_data], columns=('Seq','Ax','Ay','Az','Label'))
# Filtering
working_desk_data = activity_data[activity_data.Label == '1']
standing_data = activity_data[activity_data.Label == '3']
walking_data = activity_data[activity_data.Label == '4']
# Plotting
plt.plot(walking_data['Seq'], walking_data['Ax']) # <--- Error
plt.plot(walking_data['Seq'], walking_data['Ay']) # <--- Error
plt.plot(walking_data['Seq'], walking_data['Az']) # <--- Error
plt.show()
任何變通辦法或指向我朝着正確的方向將是有益的「屬性」的錯誤?我可以繪製以下內容,所以我明顯誤解了上面的內容。
plt.plot(range(1,5), [1,2,1,2])
plt.show()
編輯:(增加了對朱利安Spronck數據)
walking_data.head()
Out[12]:
Seq Ax Ay Az Label
22950 22950 1978 2386 1988 4
22951 22951 1977 2387 1990 4
22952 22952 1983 2390 1994 4
22953 22953 1978 2396 1994 4
22954 22954 1980 2387 1992 4
walking_data.columns
Out[79]:
Index([u'Seq', u'Ax', u'Ay', u'Az', u'Label'], dtype='object')
In [80]:
type(walking_data.Seq)
Out[80]:
pandas.core.series.Series
In [81]:
type(walking_data.Ax)
Out[81]:
pandas.core.series.Series
你能告訴我們什麼看起來像walking_data? – 2015-04-03 18:03:54
@JulienSpronck新增 – amehta 2015-04-03 20:28:19
發佈您獲得的全部錯誤,尤其是當您嘗試DSM的答案時,將會非常有用。 – Ajean 2015-04-03 21:15:29