I was wondering what the simplest method for doing the following is:
Suppose we have the following 2d arrays:
>>> a = np.array([['z', 'z', 'z', 'f', 'z','f', 'f'], ['z', 'z', 'z', 'f', 'z','f', 'f']])
array([['z', 'z', 'z', 'f', 'z', 'f', 'f'],
['z', 'z', 'z', 'f', 'z', 'f', 'f']],
dtype='<U1')
>>> b = np.array(range(0,14)).reshape(2, -1)
array([[ 0, 1, 2, 3, 4, 5, 6],
[ 7, 8, 9, 10, 11, 12, 13]])
>>> idxs = list(zip(*np.where(a == 'f')))
[(0, 3), (0, 5), (0, 6), (1, 3), (1, 5), (1, 6)]
>>> [b[x] for x in idxs]
[3, 5, 6, 10, 12, 13]
However, I would like to keep the structure that was there before with regard to the first index or rows - i.e. :
[[3, 5, 6], [7, 11]]
Is there a way to keep this structure easily?