Build df with pd.DataFrame(np.random.RandomState(8765).randint(1, 101, size=(100, 2)), columns=['A', 'B']). Bucket the rows by which range of 10 their
'A' value falls into, from (0,10], (10,20], …, up to (90,100], and return the
sum of the corresponding 'B' values for each bucket, indexed by the bucket
interval.
Output
A
(0, 10] 635
(10, 20] 360
(20, 30] 315
(30, 40] 306
(40, 50] 750
(50, 60] 284
(60, 70] 424
(70, 80] 526
(80, 90] 835
(90, 100] 852
Name: B, dtype: int64