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

Polars · Module

df.describe

Returns summary statistics for a DataFrame. Percentile selection and percentile interpolation can be customized.

How it works

Call describe on a DataFrame to produce a statistics table. You can choose the percentiles included and the interpolation strategy used for percentile calculations; the returned DataFrame is intended mainly for exploratory inspection.

Syntax

DataFrame.describe(percentiles: Sequence[float] | float | None = (0.25, 0.5, 0.75), *, interpolation: QuantileMethod = 'nearest') -> DataFrame

Parameters

NameTypeDescription
percentilesSequence[float] | float | None = (0.25, 0.5, 0.75)One or more percentiles to include in the summary statistics. Values must be in the inclusive range 0 to 1.
interpolationQuantileMethod = 'nearest'Method used to interpolate percentile values; accepted values are nearest, higher, lower, midpoint, linear, and equiprobable.

Returns

DataFrame containing summary statistics.

Key points

  • The method creates a separate DataFrame containing descriptive statistics for the source frame.
  • Use percentiles to select one percentile or a sequence of percentile values for the result.
  • The default percentile set includes the median through the 0.5 quantile.
  • The interpolation option selects how percentile results are computed.
  • glimpse is the related documentation method named by the page for quick structural inspection.

Common mistakes

  • Do not depend on the exact rows or layout of the returned table in production code.
  • Each supplied percentile must be between 0 and 1, inclusive.
  • Prefer explicit aggregations when downstream code needs a stable, programmatic result.

Example: Describe a DataFrame

import polars as pl

df = pl.DataFrame({"score": [1, 2, 3, 4], "group": ["a", "a", "b", "b"]})
print(df.describe(percentiles=[0.25, 0.5, 0.75], interpolation="linear"))

Creates a DataFrame and returns descriptive statistics using explicit percentiles and linear interpolation.

When to use it

Initial data exploration

Inspect a newly loaded or transformed frame interactively.

Custom percentile summaries

Compare distributions using selected quantiles.

Pre-analysis review

Check numeric columns and broad descriptive measures before deeper analysis.

Interview questions

QWhat does DataFrame.describe return and what are its main options?

It returns a DataFrame containing summary statistics for the input DataFrame. The optional percentiles argument controls which percentile rows are included, while interpolation controls percentile calculation.

Follow-up: Why should production code avoid parsing its output? The documentation says the output is not guaranteed to remain stable and recommends against programmatic use.

QWhich percentiles are included by default?

By default, it uses the 25th, 50th, and 75th percentiles. The median is therefore included because the 50th percentile is included by default.

Follow-up: How would you request deciles instead? Pass a sequence such as [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9] through percentiles.

QWhat does the interpolation parameter control?

The interpolation parameter accepts nearest, higher, lower, midpoint, or linear. It determines how percentile values are calculated when the requested position falls between observations.

Follow-up: How can a caller make percentile behavior explicit? Supply the desired method directly, for example interpolation="linear".

  • DataFrame.glimpse

Source: polars.DataFrame.describe — Polars documentation. Checked 2026-10-15.