Remove rows with nan/null/missing values:
df = df.dropna(axis=0, how='any') # Remove if any value is na
df = df.dropna(axis=0, how='all') # Remove if all values are na
Remove columns with nan/null/missing values:
df = df.dropna(axis=1, how='any') # Remove if any value is na
df = df.dropna(axis=1, how='all') # Remove if all values are na
Defaut remove is
inplace=False
, if you want to remove inplace, addinplace=True
Source:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.dropna.html