Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
pd.qcut(range(4), 5)
... # doctest: +ELLIPSIS
Out[2]:
[(-0.001, 0.6], (0.6, 1.2], (1.8, 2.4], (2.4, 3.0]]
Categories (5, interval[float64]): [(-0.001, 0.6] < (0.6, 1.2] < (1.2, 1.8] < (1.8, 2.4] < (2.4, 3.0]]
In [3]:
pd.qcut(range(4), 3, labels=["large", "big", "small"])
# doctest: +SKIP
Out[3]:
[large, large, big, small]
Categories (3, object): [large < big < small]
In [4]:
pd.qcut(range(6), 5, labels=False)
Out[4]:
array([0, 0, 1, 2, 3, 4], dtype=int64)