Reputation: 79
For example data frame example I want to delete each row which are having all columns = NA. I don't want to delete rows which are not having NAs in all columns. Kindly give some suggestions with examples. I really appreciate your help.
Upvotes: 1
Views: 1336
Reputation: 883
You can specify the column names in dropna
as:
df.dropna(subset = ['column1_name', 'column2_name', 'column3_name'])
This will remove the NA values.
Upvotes: 0
Reputation: 18218
You can try:
df.dropna(how='all', inplace=True)
From documentation (pandas.DataFrame.dropna):
how : {‘any’, ‘all’}, default ‘any’
Determine if row or column is removed from DataFrame, when we have at least one NA or all NA.
‘any’ : If any NA values are present, drop that row or column.
‘all’ : If all values are NA, drop that row or column.
and inplace
:
inplace : bool, default False
If True, do operation inplace and return None.
Upvotes: 3