An assistant produced this pandas code to compute "average PM2.5 per district per month" for CityPulse:
df = pd.read_csv("readings.csv")
df = df.dropna()
df["month"] = df["timestamp"].str[5:7]
df = df[df["pm25"] > 0]
monthly = df.groupby(["district", "month"]).mean()
monthly.to_csv("monthly.csv")
chart = alt.Chart(monthly).mark_line().encode(x="month", y="pm25", color="district")
- Find at least five problems (correctness, robustness, honesty).
- Rewrite the code correctly, with checks.
- List what you would report next to the chart.