bins = np.arange(0, 189, 6)
bins
returns
array([ 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72,
78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150,
156, 162, 168, 174, 180, 186])
which I then use to categorize a column of differences
df['diffs'] = pd.cut(df['differences'], bins =bins)
df.day_diff_range.value_counts()
resulting in this:
(0, 6] 1744
(6, 12] 1199
(12, 18] 1003
(18, 24] 934
(24, 30] 815
(30, 36] 754
etc
However, I want the ranges to be like so: [0, 6], [7, 13], [14, 20] and so on where both points of each bin are inclusive and the next bin adds 1 to the max of the previous bin.