Use the pd.cut function. The bins argument is using (] are the segments. The official documentation comes with detailed examples.

If pandas is not an option, one could use numpy.digitize to find which bin the elements belong to.

Planted: by ;

References:
No backlinks identified. Reference this note using the Note ID til/programming/pandas/pandas-binning-values.md in other notes to connect them.