I have an X array with NaN and I can remove the row with NaN as such:
import numpy as np
x = x[~np.isnan(x)]
But I have a corresponding Y array
assert len(x) == len(y) # True
x = x[~np.isnan(x)]
assert len(x) == len(y) # False and breaks
How do I remove the corresponding rows from the Y array?
My X array looks like this:
>>> x
[[ 2.67510434 2.67521927 3.49296989 3.80100625 4. 2.83631844]
[ 3.47538057 3.4752436 3.62245715 4.0720535 5. 3.7773169 ]
[ 2.6157049 2.61583852 3.48335887 3.78088813 0. 2.78791096]
...,
[ 3.60408952 3.60391203 3.64328267 4.1156462 5. 3.77933333]
[ 2.66773792 2.66785516 3.49177798 3.7985113 4. 2.83631844]
[ 3.26622238 3.26615124 3.58861468 4.00121327 5. 3.49693169]]
But something weird is going on:
indexes = ~np.isnan(x)
print indexes
[out]:
[[ True True True True True True]
[ True True True True True True]
[ True True True True True True]
...,
[ True True True True True True]
[ True True True True True True]
[ True True True True True True]]