Check out example codes for "groupby pd cut counts value". It will help you in understanding the concepts better.

Code Example 1

>>> groups = df.groupby(['username', pd.cut(df.views, bins)])
>>> groups.size().unstack()
views     (1, 10]  (10, 25]  (25, 50]  (50, 100]
username
jane            1         1         1          1
john            1         1         1          1

Learn ReactJs, React Native from akashmittal.com