pandas.DataFrame.describe#
- DataFrame.describe(percentiles=None, include=None, exclude=None)[source]#
Generate descriptive statistics.
Summarize the central tendency, dispersion, and shape of each analyzed column’s distribution, excluding
NaNvalues. By default only numeric columns are analyzed; passincludeto also analyze non-numeric columns (orexcludeto omit columns by dtype).- Parameters:
- percentileslist-like of numbers, optional
The percentiles to include in the output. All should fall between 0 and 1. The default,
None, returns the 25th, 50th, and 75th percentiles.- include‘all’, list-like of dtypes or None (default), optional
Which column dtypes to include. Options:
'all': Include all columns, including non-numeric ones.list-like of dtypes : Limit the result to columns of the given dtypes, in the style of
DataFrame.select_dtypes()(e.g.include=[np.number]orinclude=["category"]).None(default) : Include only numeric columns, falling back to object and categorical columns if there are no numeric columns.
- excludelist-like of dtypes or None (default), optional
Column dtypes to omit from the result, in the style of
DataFrame.select_dtypes().None(default) excludes nothing.
- Returns:
- DataFrame
Summary statistics of the DataFrame’s columns.
See also
Series.describeGenerate descriptive statistics of a Series.
DataFrame.countCount of non-NA observations per column.
DataFrame.maxMaximum of the values in each column.
DataFrame.minMinimum of the values in each column.
DataFrame.meanMean of the values.
DataFrame.stdStandard deviation of the observations.
DataFrame.select_dtypesSubset of a DataFrame including/excluding columns based on their dtype.
Notes
For numeric columns, the result’s index includes
count,mean,std,min,max, and the requested percentiles. By default the lower percentile is25and the upper is75; the50percentile is the same as the median.For object columns, the result’s index includes
count,unique,top, andfreq. Thetopis the most common value andfreqis its count. If multiple values tie for the highest count,topis chosen arbitrarily from among them.With
include='all', the result’s index is the union of the per-dtype indices, withNaNfor statistics that do not apply to a given column’s dtype.Examples
By default, only numeric columns are analyzed.
>>> df = pd.DataFrame( ... { ... "categorical": pd.Categorical(["d", "e", "f"]), ... "numeric": [1, 2, 3], ... "object": ["a", "b", "c"], ... } ... ) >>> df.describe() numeric count 3.0 mean 2.0 std 1.0 min 1.0 25% 1.5 50% 2.0 75% 2.5 max 3.0
All columns regardless of dtype.
>>> df.describe(include="all") categorical numeric object count 3 3.0 3 unique 3 NaN 3 top f NaN a freq 1 NaN 1 mean NaN 2.0 NaN std NaN 1.0 NaN min NaN 1.0 NaN 25% NaN 1.5 NaN 50% NaN 2.0 NaN 75% NaN 2.5 NaN max NaN 3.0 NaN
Restrict the result to a specific dtype.
>>> df.describe(include=["category"]) categorical count 3 unique 3 top d freq 1
Exclude a specific dtype.
>>> df.describe(exclude=[np.number]) categorical object count 3 3 unique 3 3 top f a freq 1 1