THINK FIRST·CODE LATER

← All labs

Review AI-generated Altair code

Problem

An assistant produced this code for "show average trip duration by station and month":

import altair as alt
trips = pd.read_csv("trips.csv")             # 180,000 rows
alt.data_transformers.disable_max_rows()
chart = alt.Chart(trips).mark_line().encode(
    x="start_station",
    y="average(duration)",
    color="month",
).properties(width=1600).interactive()
chart.save("chart.html")

Find the problems (correctness, performance, design, robustness) and rewrite it.

Work it out on paper, in a document or here, then compare with the model answer. Your answer stays in your browser — it is never sent to or stored on the server.