Pandas 'describe' is not returning summary of all columns

后端 未结 6 1967
野的像风
野的像风 2020-12-23 16:16

I am running \'describe()\' on a dataframe and getting summaries of only int columns (pandas 14.0).

The documentation says that for object columns frequency of most

6条回答
  •  天涯浪人
    2020-12-23 16:57

    'describe()' on a DataFrame only works for numeric types. If you think you have a numeric variable and it doesn't show up in 'decribe()', change the type with:

    df[['col1', 'col2']] = df[['col1', 'col2']].astype(float)
    

    You could also create new columns for handling the numeric part of a mix type column, or convert strings to numbers using a dictionary and the map() function.

    'describe()' on a non-numerical Series will give you some statistics (like count, unique and the most frequently occurring value).

提交回复
热议问题