pandas qcut 1

pandas qcut

pd.qcut(range(5), 4)

[(-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] ...

Here is what the above code is Doing:
1. The first line creates a Series of integers from 0 to 4.
2. The second line cuts the Series into 4 bins of equal size and returns a Categorical object.
3. The third line prints the Categorical object.

Similar Posts