Get count of non missing values of column in Pandas python

Get count of non missing values of column in pandas python.  Let’s see how to

  • Get number of non missing values of each column in pandas python
  • Get number of non missing values of single column in pandas python.

First let’s create a dataframe.

import pandas as pd
import numpy as np

#Create a DataFrame
df1 = {
    'Name':['George','Andrea','micheal','maggie','Ravi','Xien','Jalpa',np.nan],
    'State':['Arizona','Georgia','Newyork','Indiana','Florida','California',np.nan,np.nan],
    'Gender':["M","F","M","F","M","M",np.nan,np.nan],      
    'Score':[63,48,56,75,np.nan,77,np.nan,np.nan]
    
   }

df1 = pd.DataFrame(df1,columns=['Name','State','Gender','Score'])
print(df1)

df1 will be

Get count of non missing values in each columns pandas python 1

 

Get count of non missing values of each columns in pandas python:

Count of non missing value of each column in pandas is created by using notnull().sum() function as shown below.


df1.notnull().sum()

So the count of non missing values will be

Get count of non missing values in each columns pandas python 2

 

Get count of non missing values of single column in pandas python:

Number of non missing values of “Score” column in pandas is identified as shown below


df1.Score.notnull().sum()

So the number of non missing values of Score column is

5

 

p Get count of non missing values of column in Pandas python                                                                                                               n Get count of non missing values of column in Pandas python