Good evening,
Is there a efficient way of getting all beginning and ending indexes of True values in a boolean array?
Let's say I have this array:
x = np.array([nan, 11, 13, nan, nan, nan, 9, 3, nan, 3, 4, nan])
I use np.isnan(x) so I get:
[True, False, F, T, T, T, F, F, T, F, F, T]
I would like to have at the end an array or list with only indexes of NaN -> i.e one index if single, or beginning index and ending index if consecutive NaN values:
[0, [3, 5], 8, 11]
Do I have to loop on the array myself and write a function or is there a numpy and efficient way of doing it?
I have already something running but as I have to deal with hundred of thousands of values per array and multiples array also, it takes time.