user12282738
user12282738

Reputation:

How to find the percentage of null value in a pandas dataframe

How to find the percentage of null value in a pandas dataframe?

Null_Values=np.sum(data.isnull())
Null_Values/len(Null_Values)

Upvotes: 1

Views: 8393

Answers (2)

Valdi_Bo
Valdi_Bo

Reputation: 30991

data.isnull().sum() gives the number of NaN values in each column separately.

To compute the share of NaNs in the whole DataFrame, run:

data.isnull().sum().sum()/len(data)

Alternative solution:

np.count_nonzero(data.isna()) / data.size

Upvotes: 1

Georgina Skibinski
Georgina Skibinski

Reputation: 13387

This should work:

NullValues=data.isnull().sum()/len(data)

Upvotes: 0

Related Questions