Hello, readers! In this article, we will be focusing on Python isna() and Python notna() functions in detail. So, let us get started!
In the domain of data science and machine learning, data analysis and preprocessing play a very important role. In the entire process of data-preprocessing, missing value analysis is a crucial step towards development. By missing value analysis, we mean to say the process of detection and removal of missing or NA values from the source data.
For the same, there are numerous ways to detect the presence of missing values in a dataset. Today, we would be having a look at two easy to use functions to detect the presence of missing values–
- Python isna() function
- Python notna() function
In the course of this topic, we would be making use Bike Rental Prediction dataset. You can find the dataset here! Let us now have a look at each of them one by one in the below section.
1. The Python isna() function
With Python isna() function, we can easily detect the presence of NULL or NA values i.e. missing values in the data set. It is a boolean function that looks for the missing values and returns TRUE where it detects a missing value.
Have a look at the below syntax!
In this example, we have made use of isna() function to check for the presence of missing values. Since, the data is free from missing values, it returns FALSE.
import pandas import os #Changing the current working directory os.chdir("D:/Ediwsor_Project - Bike_Rental_Count") BIKE = pandas.read_csv("day.csv") BIKE.isna()
2. Python notna() function
With Python notna() function, we can easily pick out data that does not occupy missing values or NA values. The notna() function returns TRUE, if the data is free from missing values else it returns FALSE (if NA values are encountered).
As witnessed above, the dataset is free from NA values. Thus, the notna() function returns TRUE.
import pandas import os #Changing the current working directory os.chdir("D:/Ediwsor_Project - Bike_Rental_Count") BIKE = pandas.read_csv("day.csv") BIKE.notna()
Feel free to comment below in case you come across any questions. To summarize, with Python isna() and notna() functions, we can quickly check for the presence of missing values, especially with the huge datasets. And we can easily plan the necessary remedies to treat the missing values.
For more such posts related to Python Programming, stay tuned with us. Till then, Happy Learning!! 🙂