I have two numpy arrays e.g.:
names = np.array(['A', 'B', 'C', 'D']) # (B, 1)
mask = np.array([ # (N, B)
[True, False, False, False],
[False, True, False, True ],
[True, True, False, False]
])
I want to get an 1 dimensional array of lists with shape (N,), where for each row in mask I have a list of the names in names for which the value was True. Here that would be:
result = [
['A'],
['B', 'C'],
['A', 'B']
]
Any idea how?