AttributeError: 'DataFrame' object has no attribute

前端 未结 4 2034
余生分开走
余生分开走 2021-02-03 22:49

I keep getting different attribute errors when trying to run this file in ipython...beginner with pandas so maybe I\'m missing something

Code:

from panda         


        
4条回答
  •  醉梦人生
    2021-02-03 23:37

    value_counts work only for series. It won't work for entire DataFrame. Try selecting only one column and using this attribute. For example:

    df['accepted'].value_counts()
    

    It also won't work if you have duplicate columns. This is because when you select a particular column, it will also represent the duplicate column and will return dataframe instead of series. At that time remove duplicate column by using

    df = df.loc[:,~df.columns.duplicated()]
    df['accepted'].value_counts()
    

提交回复
热议问题