I would like to know how to removing nan elements from multidimensional numpy array.
For example, I want to convert this array
x = array([[ 1., nan, 2.],
[ 3., 4., nan]])
to
x = array([[ 1., 2.],
[ 3., 4.]])
I found some similar ways, but looks different what I want:
1.
x = x[~np.isnan(x)]
But this way remove array shape information.
>>> x[~np.isnan(x)]
array([1., 2., 3., 4.])
These are similar questions, but I don't want remove row or column including nan's, I want to just remove nan elements.