March 2020
Beginner to intermediate
352 pages
8h 40m
English
Often when working with continuous datasets, we need to convert them into discrete or interval forms. Each interval is referred to as a bin, and hence the name binning comes into play:
height = [120, 122, 125, 127, 121, 123, 137, 131, 161, 145, 141, 132]
And we want to convert that dataset into intervals of 118 to 125, 126 to 135, 136 to 160, and finally 160 and higher.
bins = [118, 125, 135, 160, 200]category = pd.cut(height, bins)category
The output of the preceding code is as follows:
[(118, 125], (118, 125], (118, 125], (125, ...Read now
Unlock full access