pandas - How to fix AttributeError: 'Series' object has no attribute 'find'? -
pandas - How to fix AttributeError: 'Series' object has no attribute 'find'? -
i trying play online data, , having problem plotting due 'attribute' error in plot function
# reading info online info sets import pandas pd import requests, zipfile, stringio r = requests.get('https://archive.ics.uci.edu/ml/machine-learning-databases/00287/activity recognition single chest-mounted accelerometer.zip') z = zipfile.zipfile(stringio.stringio(r.content)) activity_files = [name name in z.namelist() if name.endswith('.csv')] # loading pandas dataframe z_data = z.read(activity_files[4]).split('\n') activity_data = pd.dataframe([z.split(',') 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()
any workarounds or pointing me right direction helpful ? can plot following, misunderstanding above.
plt.plot(range(1,5), [1,2,1,2]) plt.show()
edit: (added info julien 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
use dataframe plot method:
walking_data.plot('seq', ,'ax')
pandas matplotlib time-series data-analysis
Comments
Post a Comment