qcut(x, q, labels=None, retbins: 'bool' = False, precision: 'int' = 3, duplicates: 'str' = 'raise')
Discretize variable into equal-sized buckets based on rank or based on sample quantiles. For example 1000 values for 10 quantiles would produce a Categorical object indicating quantile membership for each data point.
Out of bounds values will be NA in the resulting Categorical object
Number of quantiles. 10 for deciles, 4 for quartiles, etc. Alternately array of quantiles, e.g. [0, .25, .5, .75, 1.] for quartiles.
Used as labels for the resulting bins. Must be of the same length as the resulting bins. If False, return only integer indicators of the bins. If True, raises an error.
Whether to return the (bins, labels) or not. Can be useful if bins is given as a scalar.
The precision at which to store and display the bins labels.
If bin edges are not unique, raise ValueError or drop non-uniques.
The return type (Categorical or Series) depends on the input: a Series of type category if input is a Series else Categorical. Bins are represented as categories when categorical data is returned.
Returned only if :None:None:`retbins`
is True.
Quantile-based discretization function.
>>> pd.qcut(range(5), 4)This example is valid syntax, but we were not able to check execution
... # doctest: +ELLIPSIS [(-0.001, 1.0], (-0.001, 1.0], (1.0, 2.0], (2.0, 3.0], (3.0, 4.0]] Categories (4, interval[float64, right]): [(-0.001, 1.0] < (1.0, 2.0] ...
>>> pd.qcut(range(5), 3, labels=["good", "medium", "bad"])This example is valid syntax, but we were not able to check execution
... # doctest: +SKIP [good, good, medium, bad, bad] Categories (3, object): [good < medium < bad]
>>> pd.qcut(range(5), 4, labels=False) array([0, 0, 1, 2, 3])See :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.arrays.interval.IntervalArray
pandas.core.reshape.tile.cut
pandas.core.indexes.interval.IntervalIndex
pandas._libs.interval.Interval
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them