1
$\begingroup$

In the given code it displays only the rows without NaN values but i want only the rows with NaN values in a provided column everything has to be removed

df1 = df1[pd.notnull(df1['column_name'])]
$\endgroup$

1 Answer 1

4
$\begingroup$

If I am correct, you are looking to keep only the NaN values. You can use pd.isnull() to check which rows are NaN and then only keep those. Try this:

df1 = df1[pd.isnull(df1['column_name'])]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.