python - Plot a data frame -
i have data frame this:
reviewdate_month,productid,reviewer 01,185,185 02,155,155 03,130,130 04,111,111 05,110,110 06,98,98 07,101,92 08,71,71 09,73,73 10,76,76 11,105,105 12,189,189
i want plot it, reviewdate_month in x, product id , reviewer in y ideally. start 1 line either product id or reviewer. tried:
df_no_monthlycount.plot.line
got below error msg:
file "c:/users/user/pycharmprojects/assign2/main.py", line 59, in <module> 01 185 185 02 155 155 03 130 130 04 111 111 05 110 110 06 98 98 07 101 92 08 71 71 09 73 73 10 76 76 df_no_monthlycount.plot.line attributeerror: 'function' object has no attribute 'line' 11 105 105 12 189 189 process finished exit code 1
i tried this:
df_no_monthlycount.plot(x=df_helful_monthlymean['reviewdate_month'],y=df_helful_monthlymean['productid'],style='o')
error msg this:
traceback (most recent call last): file "c:/users/user/pycharmprojects/assign2/main.py", line 52, in <module> df_no_monthlycount.plot(x=df_helful_monthlymean['reviewdate_month'],y=df_helful_monthlymean['productid'],style='o') file "c:\python34\lib\site-packages\pandas\core\frame.py", line 1797, in __getitem__ return self._getitem_column(key) file "c:\python34\lib\site-packages\pandas\core\frame.py", line 1804, in _getitem_column return self._get_item_cache(key) file "c:\python34\lib\site-packages\pandas\core\generic.py", line 1084, in _get_item_cache values = self._data.get(item) file "c:\python34\lib\site-packages\pandas\core\internals.py", line 2851, in loc = self.items.get_loc(item) file "c:\python34\lib\site-packages\pandas\core\index.py", line 1572, in get_loc return self._engine.get_loc(_values_from_object(key)) file "pandas\index.pyx", line 134, in pandas.index.indexengine.get_loc (pandas\index.c:3838) file "pandas\index.pyx", line 154, in pandas.index.indexengine.get_loc (pandas\index.c:3718) file "pandas\hashtable.pyx", line 686, in pandas.hashtable.pyobjecthashtable.get_item (pandas\hashtable.c:12294) file "pandas\hashtable.pyx", line 694, in pandas.hashtable.pyobjecthashtable.get_item (pandas\hashtable.c:12245) keyerror: 'reviewdate_month'
call plot
shown below:
import pandas pd import matplotlib.pyplot plt df = pd.read_csv('data.csv') print(df) df.plot(x ='reviewdate_month',y=['productid', 'reviewer'] ,kind='line') plt.show()
will give you:
Comments
Post a Comment