>>> a = np.array([[1,2,3], [4,5,np.nan], [7,8,9]]) array([[ 1., 2., 3.], [ 4., 5., nan], [ 7., 8., 9.]]) >>> a[~np.isnan(a).any(axis=1)] array([[ 1., 2., 3.], [ 7., 8., 9.]])
and reassign it to a .
Explanation: np.isnan(a) returns a similar array with True , where NaN , False elsewhere. .any(axis=1) reduces the array m*n to n with the logical operation or in all lines, ~ inverts True/False and a[ ] selects only lines from the original array that have True in brackets.
eumiro Jul 12 2018-12-12T00: 00Z
source share