1. Learn
  2. /
  3. Courses
  4. /
  5. Practicing Statistics Interview Questions in Python

Exercise

Handling null values

Let's practice handling null values with our laptops dataset that we worked with previously. You will identify rows with null values, and then try out several techniques to address this problem.

Remember that the laptops data and the pandas package have been imported for you already.

Instructions 1/4

undefined XP
  • 1

    Identify and print the rows with null values by slicing your DataFrame with the isnull() function.

  • 2

    Impute 0 for missing prices using the fillna() function; print the DataFrame head and note index 1 and 2 were null.

  • 3

    Adapt your code to impute the median price instead; once again print the first five rows to confirm.

  • 4

    Drop all the rows with null values using the dropna() function; make sure you pass inplace=True as a parameter.