Below code is from python -
x = np.array([0.8, 6.9, 3.5, 1.9]) bins = np.array([0.0, 1.0, 2.5, 4.0, 10.0]) inds = np.digitize(x, bins) print(inds) array([1, 4