array([youthyouthyouthyoungadultyouthyouthmiddleagedyoungadultseniormiddleagedmiddleagedyoungadult]dtype=objectlevels ( )index([youthyoungadultmiddleagedsenior]dtype=objectif you pass cut integer number of bins instead of explicit bin edgesit will compute equal-length bins based on the minimum and maximum values in the data consider the case of some uniformly distributed data chopped into fourthsin [ ]data np random rand( in [ ]pd cut(data precision= out[ ]categoricalarray([( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]( ]]dtype=objectlevels ( )index([( ]( ]( ]( ]]dtype=objecta closely related functionqcutbins the data based on sample quantiles depending on the distribution of the datausing cut will not usually result in each bin having the same number of data points since qcut uses sample quantiles insteadby definition you will obtain roughly equal-size binsin [ ]data np random randn( normally distributed in [ ]cats pd qcut(data cut into quartiles in [ ]cats out[ ]categoricalarray([(- ][- - ]( ](- - ]( ](- - ]]dtype=objectlevels ( )index([[- - ](- - ](- ]( ]]dtype=objectin [ ]pd value_counts(catsout[ ][- - ( (- - (- similar to cut you can pass your own quantiles (numbers between and inclusive)in [ ]pd qcut(data[ ]out[ ]categoricalarray([(- ](- - ](- ](- - ](- ](- - ]]dtype=objectlevels ( )index([[- - ](- - ](- ]( ]]dtype=object data wranglingcleantransformmergereshape www it-ebooks info