Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing in

  Enroll Now

Filling the Missing Values

Now that we know that there are two missing values in the data, we have to fill those missing values.


Pandas provides some built-in methods to do this job.

  • bfill - used to backward fill or use the next valid observation to fill the missing values in the dataset.
  • ffill - used to forward fill or use the previous valid observation to fill the missing values in the dataset.
  • using fillna(metohd='bfill') is another way of achieving the job using backward filling. Similarly, one could use ffill or any other way like mean().

Let us use bfill() to fill the two missing values.

  • First let us see the number of missing values in each column in modified_data using isna().sum().

    print("Before filling missing values:\n", modified_df.<< your code comes here >>)
  • Use bfill method on modified_df and put axis=rows.

    modified_df = modified_df.<< your code comes here >>(axis ='rows')
  • Now, let us again check the column-wise null values in modified_df. Now we expect all the values to be 0 as we have filled them.

    print("\nAfter filling missing values:\n",modified_df.isna().sum())

No hints are availble for this assesment

Answer is not availble for this assesment

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...