In Python, missing values can be dropped using the fillna() function. The fillna() function takes one value that we want to fill at the missing place. We can fill in the missing values using the mean, median, and mode:
# Read the data
data=pd.read_csv('employee.csv')
# Fill all the missing values in the age column with mean of the age column
data['age']=data.age.fillna(data.age.mean())
data
This results in the following output:
In the preceding example, the missing values in the age column have been filled in with the mean value of the age column. Let's learn how to fill in the missing values using the median:
# Fill all the missing values in the income column with a median of the income column
data['income']=data.income.fillna(data.income.median())
data
This results in the following output:
In the preceding example, the missing values in the income column have been filled in with the median value...