Crazymage
Crazymage

Reputation: 114

How to get the all the lines with any null value with python pandas?

I mean in a csv file, maybe some column of some line is null, I want to get the lines with any of its item is null. For example,

Name Age Sex
Tom   12  M
Anna  21  F
Andy  31
Monna     F

Then Andy and Monna has some value which is null, and I want them.

Upvotes: 0

Views: 468

Answers (1)

ayushindin
ayushindin

Reputation: 111

Dataframe has method isnull:

import pandas as pd

df = pd.read_csv(//your file)
df = df[df.isnull().any(axis=1)]

Upvotes: 2

Related Questions