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'])]

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'])]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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