Python practice: Data Hygiene & Missing Values

Chapter 21 · 8 questions · included in full access

  1. Question 1 · easy

    Audit missing values per column

    Load "orders_messy.csv". Compute missing values with messy.isna().sum(). Print int(missing["Units"]):

    Solve it in your browser
  2. Question 2 · easy

    Drop rows missing critical price data

    Load "orders_messy.csv". Drop rows where Price is null using clean = messy.dropna(subset=["Price"]). Print len(clean):

    Solve it in your browser
  3. Question 3 · easy

    Impute missing units with 0

    Load "orders_messy.csv". Fill missing Units with 0 using messy["Units"] = messy["Units"].fillna(0). Print messy["Units"].isna().sum():

    Solve it in your browser
  4. Question 4 · easy

    Impute missing price with column median

    Load "orders_messy.csv". Compute med = messy["Price"].median(), fill null prices with med, and print round(med, 1):

    Solve it in your browser
  5. Question 5 · easy

    Forward fill sequential time series

    Create s = pd.Series([100.0, None, None, 105.0]). Apply .ffill() and print s.ffill().tolist():

    Solve it in your browser
  6. Question 6 · easy

    Count duplicate rows

    Load "orders_messy.csv". Print the count of duplicate rows using messy.duplicated().sum():

    Solve it in your browser
  7. Question 7 · easy

    Drop duplicate rows

    Load "orders_messy.csv". Drop duplicate rows using deduped = messy.drop_duplicates(). Print len(deduped):

    Solve it in your browser
  8. Question 8 · medium

    Drop missing units and prices simultaneously

    Load "orders_messy.csv". Drop any rows missing either Units or Price using clean = messy.dropna(subset=["Units", "Price"]). Print len(clean):

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing