I read in a dataset as a numpy.ndarray and some of the values are missing (either by just not being there, being NaN, or by being a string written "NA").
I want to clean out all rows containing any entry like this. How do I do that with a numpy ndarray?
and reassign this to
a.Explanation:
np.isnan(a)returns a similar array withTruewhereNaN,Falseelsewhere..any(axis=1)reduces anm*narray tonwith an logicaloroperation on the whole rows,~invertsTrue/Falseanda[ ]chooses just the rows from the original array, which haveTruewithin the brackets.