pub fn digitize<T: Element, B: Element>(
x: &Array<T>,
bins: &Array<B>,
right: bool,
) -> Array<usize>Expand description
Index of the bin each value falls into, like np.digitize(x, bins, right).
bins must be monotonic. With increasing bins and right == false, i satisfies
bins[i-1] <= x < bins[i]; with right == true, bins[i-1] < x <= bins[i]. Values below
the first bin give 0, above the last give bins.len(); NaN gives bins.len().
The output has the shape of x.
use rustnum as np;
let x = np::array![0.2, 6.4, 3.0, 1.6];
let bins = np::array![0.0, 1.0, 2.5, 4.0, 10.0];
assert_eq!(np::digitize(&x, &bins, false).to_vec(), vec![1, 4, 3, 2]);