O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing discretization and quantiling of data

Discretization is a means of slicing up continuous data into a set of "bins." Each value is then associated with a representative bin. The resulting distribution of the count of values in each bin can then be used to get an understanding of relative distribution of data across the different bins.

Discretization in pandas is performed using the pd.cut() and pd.qcut() functions. To demonstrate, let's start with the following set of 10000 random numbers created with a normal random number generator:

This code shows us the mean and standard deviation of this dataset, which we expect to approach ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required