numpy.digitize()
numpy.digitize
-
numpy.digitize(x, bins, right=False)
-
Return the indices of the bins to which each value in input array belongs.
Each index
i
returned is such thatbins[i-1] <= x < bins[i]
ifbins
is monotonically increasing, orbins[i-1] > x >= bins[i]
ifbins
is monotonically decreasing. If values inx
are beyond the bounds ofbins
, 0 orlen(bins)
is returned as appropriate. If right is True, then the right bin is closed so that the indexi
is such thatbins[i-1] < x <= bins[i]
or bins[i-1] >= x > bins[i]`` ifbins
is monotonically increasing or decreasing, respectively.