I am looking for a solution to this problem.
While experimenting with masks I got this error and have no clue why. It works for rows but not for columns?
import numpy as np
a = np.array(
[[1, np.nan, 0],
[0, np.nan, 0],
[0, np.nan, 0],
[np.nan, np.nan, np.nan],
[2, np.nan, 4]])
mask_row = np.all(np.isnan(a), axis=1)
mask_column = np.all(np.isnan(a), axis=0)
print(a[~mask_row])
print(a[~mask_column])
This is the error I get for the last print statement:
IndexError: boolean index did not match indexed array along dimension 0; dimension is 5 but corresponding boolean dimension is 3