You can do this with a list comprehension close to what you were imagining:
import numpy as np
list_of_my_bin_lists = [[2, 6, 9], [4, 6, 8], [3, 5, 9]]
my_array = np.array([1, 3, 7])
digitized = [np.digitize(np.array([item]), bin_list)[0]
for item, bin_list
in zip(my_array, list_of_my_bin_lists)]
Result: digitized == [0, 0, 2]
This works assuming you want digitized
to be a list
of int
s. If you want it to be an np.array
or something, it should be straightforward to recast it to whatever you need.