Spec-Zone.ru › Nushell

polars qcut for dataframe

Bin continuous values into discrete categories based on their quantiles for a series.

Signature

> polars qcut {flags} (quantiles)

Flags

  • --labels, -l {list<string>}: Names of the categories. The number of labels must be equal to the number of cut points plus one.
  • --left_closed, -c: Set the intervals to be left-closed instead of right-closed.
  • --include_breaks, -b: Include a column with the right endpoint of the bin each observation falls in. This will change the data type of the output from a Categorical to a Struct.
  • --allow_duplicates, -d: If set, duplicates in the resulting quantiles are dropped, rather than raising an error. This can happen even with unique probabilities, depending on the data.

Parameters

  • quantiles: Either a list of quantile probabilities between 0 and 1 or a positive integer determining the number of bins with uniform probability.

Input/output types:

input output
polars_dataframe polars_dataframe
polars_lazyframe polars_lazyframe

Examples

Divide a column into three categories according to pre-defined quantile probabilities.

> [-2, -1, 0, 1, 2] | polars into-df | polars qcut [0.25, 0.75] --labels ["a", "b", "c"]

Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/polars_qcut.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API