Pandas DataFrame select the specific columns with NaN values
Question:
I have a two-column DataFrame, I want to select the rows with NaN
in either column.
I used this method df[ (df['a'] == np.NaN) | (df['b'] == np.NaN) ]
However it returns an empty answer. I don’t know what’s the problem
Answers:
You can use isna() as well:
df[df['merged_key_words'].isna() | df['key_words'].isna()]
I have a two-column DataFrame, I want to select the rows with NaN
in either column.
I used this method df[ (df['a'] == np.NaN) | (df['b'] == np.NaN) ]
However it returns an empty answer. I don’t know what’s the problem
You can use isna() as well:
df[df['merged_key_words'].isna() | df['key_words'].isna()]