How to filter in NaN (pandas)?
Simplest of all solutions:
filtered_df = df[df['var2'].isnull()]
This filters and gives you rows which has only NaN
values in 'var2'
column.
This doesn't work because NaN
isn't equal to anything, including NaN
. Use pd.isnull(df.var2)
instead.
df[df['var'].isna()]
where
df : The DataFrame
var : The Column Name