Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Pandas · Function

df.describe

DataFrame.describe generates descriptive statistics for analyzed columns, excluding NaN values. It can summarize mixed-type DataFrames and filter analyzed columns with include or exclude.

How it works

Call this method on a DataFrame to produce column-wise descriptive statistics. It ignores missing values, uses standard numeric summaries for numeric columns, and can include or exclude columns by dtype through its optional filters.

Syntax

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

Parameters

NameTypeDescription
percentileslist-like, optionalPercentile levels to include in the result; values must be between 0 and 1. If omitted, the method uses the 25th, 50th, and 75th percentiles.
includescalar or list-like, optionalDtype or dtypes whose columns should be included in the analysis.
excludescalar or list-like, optionalDtype or dtypes whose columns should be omitted from the analysis.

Returns

Series or DataFrame containing summary statistics for the supplied data.

Key points

  • Produces a compact statistical profile for the DataFrame.
  • The output characterizes distribution location, spread, and shape while leaving missing values out of calculations.
  • It supports numeric data, object data, and DataFrames containing mixed column types.
  • Leaving percentiles unset adds the first, second, and third quartiles.
  • The method accepts optional percentile, inclusion, and exclusion arguments.
  • The result contains summary statistics for the supplied data structure.

Common mistakes

  • Every value supplied in percentiles must be between 0 and 1.
  • Use include and exclude to control which DataFrame columns participate in the summary.

Example: Summarize numeric and object columns

import pandas as pd

frame = pd.DataFrame({
    "score": [10, 20, 30, None],
    "team": ["A", "A", "B", "B"],
})

print(frame.describe())
print(frame.describe(include=["object"]))

Creates a mixed-type DataFrame, prints numeric summary statistics, then explicitly summarizes the object column.

When to use it

Quickly inspect distributions and common summary measures before deeper analysis.

Initial dataset inspection

Review numeric and object columns in a DataFrame with different summary fields.

Mixed-type profiling

Limit profiling to selected column types using include or exclude.

Dtype-focused analysis

Interview questions

QWhat does DataFrame.describe return?

It returns descriptive statistics for the analyzed DataFrame columns and omits NaN values from those calculations. Numeric columns produce measures such as count, mean, standard deviation, minimum, maximum, and requested percentiles.

Follow-up: How would you summarize non-numeric columns? Pass an appropriate dtype through include, such as include=["object"], so those columns are analyzed.

QHow are percentiles selected?

By default, the percentile argument is None, which causes the method to include the 25th, 50th, and 75th percentiles. You can provide a list-like collection to request different percentile levels.

Follow-up: What validation constraint applies to custom percentile values? Each value must fall between 0 and 1.

QHow do include and exclude affect analysis?

The include and exclude arguments restrict the columns analyzed according to dtype. This lets a caller select non-numeric columns, omit particular dtype groups, or otherwise narrow the DataFrame summary.

Follow-up: What happens if the filters select incompatible or overlapping dtype groups? The method validates the requested selection and may raise an error rather than producing an ambiguous summary.

  • DataFrame.info
  • Series.describe

Source: pandas.DataFrame.describe — pandas 3.0.6 documentation. Checked 2026-10-15.