AttributeError: 'DataFrame' object has no attribute

前端 未结 4 2036
余生分开走
余生分开走 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:14

    value_counts is a Series method rather than a DataFrame method (and you are trying to use it on a DataFrame, clean). You need to perform this on a specific column:

    clean[column_name].value_counts()
    

    It doesn't usually make sense to perform value_counts on a DataFrame, though I suppose you could apply it to every entry by flattening the underlying values array:

    pd.value_counts(df.values.flatten())
    

提交回复
热议问题