Project - Stock Closing Price Prediction using Deep Learning, TensorFlow2 & Keras

You are currently auditing this course.
18 / 32

Filling the Missing Values

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

Note:

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.

INSTRUCTIONS
  • First let us see the number of missing values in each column in modified_df 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())
    
Get Hint See Answer

Loading comments...