MOBI BOOT CAMP CORP. logoLearning Buddy
  • SIGN IN
  • Introduction
  • 1: NumPy Module
  • 2: Pandas Module
  • 3: Pandas - More on Dataframes
    • Data Cleaning
    • Queries on DataFames
    • Data Transformations
    • More on group by
    • Pivot Tables
    • Joining Datasets
    • Quiz
    • Colab Exercise
  • 4: Matplotlib Module
  • 5: Seaborn Module
  • 6: Plotly Express Module
  • 7: GeoSpatial Modules
  • 8. Other Popular Libs
  • 9. Data Driven Stories
  • 10. Bad Visualization Example
  • 11. Glossary
  • Slides-1
  • Slides-2

You are required to impute missing values in a dataset containing the GDP value of many countries over many years. GDP typically increases year over year, but some years have a missing value. What method would you apply to impute the missing value? Choose the most appropriate method.

df['gdp'].interpolate(method='linear', inplace=True) df['gdp'].fillna(method='bfill', inplace=True) df['gdp'].fillna(df['gdp'].mean()) df['gdp'].fillna(df['gdp'].median()) Since GDP typically follows a trend, linear interpolation is the most appropriate method to estimate the missing values based on the surrounding years. Using `bfill`, mean, or median would not account for the time-series nature of the data.

Exercise

Privacy Policy | Terms & Conditions