June 09, 2015

[Python] Remove raws with NaNs

In [27]: df.dropna()     #drop all rows that have any NaN values

In [28]: df.dropna(how='all', axis =1)     #drop only if ALL columns are NaN

In [29]: df.dropna(thresh=2)   #Drop row if it does not have at least two values that are **not** NaN

In [30]: df.dropna(subset=[1])   #Drop only if NaN in specific column (as asked in the question)

Ref

No comments :

Post a Comment