bins = 7
edges = np.linspace(df.value.min(), df.value.max(), bins+1).astype(int)
labels = [f'({edges[i]}, {edges[i+1]}]' for i in range(len(edges)-1)]
df['bin'] = pd.cut(df.value, bins=bins, labels=labels)
# value bin
# 1 8 (0, 53]
# 2 16 (0, 53]
# .. ... ...
# 45 360 (322, 376]
# 46 368 (322, 376]
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter