polars.Series.describe#

Series.describe(
percentiles: Sequence[float] | float | None = (0.25, 0.5, 0.75),
interpolation: RollingInterpolationMethod = 'nearest',
) DataFrame[source]#

系列的快速摘要统计。

包含混合数据类型的Series将返回第一个值的数据类型的汇总统计信息。

Parameters:
percentiles

要包含在汇总统计中的一个或多个百分位数(如果Series具有数值类型)。所有值必须在[0, 1]范围内。

interpolation{‘nearest’, ‘higher’, ‘lower’, ‘midpoint’, ‘linear’}

计算百分位数时使用的插值方法。

Returns:
DataFrame

使用Series的摘要统计进行映射。

注释

默认情况下,中位数作为50%百分位数被包含在内。

示例

>>> s = pl.Series([1, 2, 3, 4, 5])
>>> s.describe()
shape: (9, 2)
┌────────────┬──────────┐
│ statistic  ┆ value    │
│ ---        ┆ ---      │
│ str        ┆ f64      │
╞════════════╪══════════╡
│ count      ┆ 5.0      │
│ null_count ┆ 0.0      │
│ mean       ┆ 3.0      │
│ std        ┆ 1.581139 │
│ min        ┆ 1.0      │
│ 25%        ┆ 2.0      │
│ 50%        ┆ 3.0      │
│ 75%        ┆ 4.0      │
│ max        ┆ 5.0      │
└────────────┴──────────┘

非数值数据类型可能无法提供所有统计信息。

>>> s = pl.Series(["aa", "aa", None, "bb", "cc"])
>>> s.describe()
shape: (4, 2)
┌────────────┬───────┐
│ statistic  ┆ value │
│ ---        ┆ ---   │
│ str        ┆ str   │
╞════════════╪═══════╡
│ count      ┆ 4     │
│ null_count ┆ 1     │
│ min        ┆ aa    │
│ max        ┆ cc    │
└────────────┴───────┘