Initial data exploration
Inspect a newly loaded or transformed frame interactively.
Polars · Module
Returns summary statistics for a DataFrame. Percentile selection and percentile interpolation can be customized.
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.
DataFrame.describe(percentiles: Sequence[float] | float | None = (0.25, 0.5, 0.75), *, interpolation: QuantileMethod = 'nearest') -> DataFrame| Name | Type | Description |
|---|---|---|
percentiles | Sequence[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. |
interpolation | QuantileMethod = 'nearest' | Method used to interpolate percentile values; accepted values are nearest, higher, lower, midpoint, linear, and equiprobable. |
DataFrame containing summary statistics.
percentiles to select one percentile or a sequence of percentile values for the result.interpolation option selects how percentile results are computed.glimpse is the related documentation method named by the page for quick structural inspection.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.
Inspect a newly loaded or transformed frame interactively.
Compare distributions using selected quantiles.
Check numeric columns and broad descriptive measures before deeper analysis.
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.
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.
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