Open In App

Python | Pandas Index.notnull()

Improve
Improve
Like Article
Like
Save
Share
Report

Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.

Pandas Index.notnull() function detect existing (non-missing) values. This function return a boolean same-sized object indicating if the values are not NA. Non-missing values get mapped to True. Characters such as empty strings ” or numpy.inf are not considered NA values (unless you set pandas.options.mode.use_inf_as_na = True). NA values, such as None or numpy.NaN, get mapped to False values.

Syntax: Index.notnull()

Returns : Boolean array to indicate which entries are not NA.

Example #1: Use Index.notnull()() function to detect missing values in the given Index.




# importing pandas as pd
import pandas as pd
  
# Creating the index
idx = pd.Index(['Jan', '', 'Mar', None, 'May', 'Jun', 'Jul',
                         'Aug', 'Sep', 'Oct', 'Nov', 'Dec'])
  
# Print the Index
idx


Output :

Let’s find out all the non-missing values in the Index




# to find the non-missing values.
idx.notnull()


Output :

As we can see in the output, all the non-missing values has been mapped to True and all the missing values has been mapped to False. Notice the empty string has been mapped to True as an empty string is not considered to be a missing value.
 

Example #2: Use Index.notnull() function find out all the non-missing values in the Index.




# importing pandas as pd
import pandas as pd
  
# Creating the index
idx = pd.Index([22, 14, 8, 56, None, 21, None, 23])
  
# Print the Index
idx


Output :

Let’s find out all the non-missing values in the Index




# to find the non-missing values.
idx.notnull()


Output :

As we can see in the output, all the non-missing values have been mapped to True and all the missing values have been mapped to False.



Last Updated : 18 Dec, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads