describe() (Pandas)

df.describe() generates summary statistics for a DataFrame's numeric columns — count, mean, standard deviation, min, the quartiles, and max. It gives a fast statistical snapshot of your data's distribution.

Pandas

describe() is the quickest way to sanity-check numbers: the min and max flag impossible values, the mean versus the median (the 50% row) hints at skew, and the count shows how many non-null values each column has. By default it ignores text columns.

For object or category columns, pass include='object' (or include='all') and you get a different set of stats — count, number of unique values, the most frequent value, and its frequency. You can also change which percentiles appear with the percentiles argument.

Like most pandas summaries it returns a DataFrame, so you can index into it, for example df.describe().loc['mean'].

Syntax

df.describe(percentiles=None, include=None, exclude=None)

Examples

Python

import pandas as pd
df = pd.DataFrame({"v": [1, 2, 3, 4]})
print(df.describe().loc[["mean", "std"]])

Output:

             v
mean  2.500000
std   1.290994

Learn it in a lesson

See also

Back to the Dictionary