Mid-Level
November 18, 2026Spot the bug: Data Analytics
One snippet. Find the bug, or prove there isn't one.
python
1import pandas as pd
2
3VALID_STATUSES = {'active', 'pending', 'cancelled'}
4
5def normalize_status_column(df: pd.DataFrame, column: str) -> pd.DataFrame:
6 cleaned = df.copy()
7 cleaned[column] = cleaned[column].astype(str).str.strip().str.lower()
8 unknown = set(cleaned[column].unique()) - VALID_STATUSES
9 if unknown:
10 raise ValueError(f'Unknown statuses: {sorted(unknown)}')
11 return cleaned
12
13def load_orders(path: str) -> pd.DataFrame:
14 raw = pd.read_csv(path)
15 return normalize_status_column(raw, 'status')
16
17orders = load_orders('orders.csv')
18print(orders['status'].value_counts())Click the lines that carry the problem.
Your verdict
One attempt per day. The answer shows up right after.
Keep your streak
Create an account to keep your streak and track your progress.