Hi,
I am looking for an efficient way to compress a numpy array.
I have an array like: dtype=[(name, (np.str_,8), (job, (np.str_,8), (income, np.uint32)]
(my favourite example;).
if I'm doing something like this: my_array.compress(my_array['income'] > 10000)
I'm getting a new array with only incomes > 10000, and it's quite quick.
But if I would like to filter jobs in list: it doesn't work!
my__array.compress(m_y_array['job'] in ['this', 'that'])
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
So I have to do something like this:
np.array([x for x in my_array if x['job'] in ['this', 'that'])
This is both ugly and inefficient!
Do you have an idea to make it efficient?
Thank you!
Louis