Pandas — Replacing NULL to ‘0’
Hi All,
We all love to do something. We can able to start anything from scratch and become hero on it. Practice, Yeah, that’s keyword for anything. Nothing can lift you expect Practice .
To do something, we have to keep these mantra in mind.
Practice ! Practice ! practice !!!
Here, To enhance the knowledge on Pandas , we will try one small panda code. Hope everyone is ready with IDE to play with data.
A dataset with any dimension with data of mixed types across columns. Need to replace the null values with ‘0’
Step 1: Import the required packages.
To handle null records and read dataset, we need the python powerful package — numpy and pandas packages
Step 2: Read the dataset which have NULL values
Download Melbourne data from Kaggle and read the downloaded csv using read_csv().
Step 3 : Check the NULL values in the dataframe
To check NULL values in dataframe, isnull() should help. It returns result in Boolean type.
Step 4: Replace NULL with 0
fillna() is used to acheive replacing NULL with 0. Here we are filling NULL values in the dataframe df with 0 and stored as df2.