Return the indices of the bins to which each value in input array belongs.
| increasing |
|
If values in x are beyond the bounds of bins, 0 or len[bins]
is returned as appropriate.
Input array to be binned. Prior to NumPy 1.10.0, this array had to be 1-dimensional, but can now have any shape.
binsarray_likeArray of bins. It has to be 1-dimensional and monotonic.
rightbool, optionalIndicating whether the intervals include the right or the left bin edge. Default behavior is [right==False] indicating that the interval does not include the right edge. The left bin end is open in this case, i.e., bins[i-1] >> x = np.array[[0.2, 6.4, 3.0, 1.6]] >>> bins = np.array[[0.0, 1.0, 2.5, 4.0, 10.0]] >>> inds = np.digitize[x, bins] >>> inds array[[1, 4, 3, 2]] >>> for n in range[x.size]: ... print[bins[inds[n]-1], "