The data frame is divided into cells, which can store a value belonging to some data structure as well as it may contain missing or NA values. The pandas package contains various in-built functions, to check if the value in the cell of a data frame is either NA or not, and also to perform aggregations over these NA values.
The isna() function is used to detect missing/none values and return a boolean array of length equal to the data frame element over which it is applied and the sum() method is used to calculate a total of these missing values.
Method #2: Using the length of the dataframe
The count of the values contained in any particular column of the data frame is subtracted from the length of dataframe, that is the number of rows in the data frame. The count() method gives us the total number of NaN values in a specified column and the length(dataframe) gives us the length of the data frame, that is the total number of rows in the frame.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course