English · Dansk · Bahasa Malaysia
Step 6: Average parts per set
Question: Did LEGO sets grow in size and complexity?

What the code does
parts_per_set groups by year and averages num_parts with .agg(): about 12 parts in 1954 and about 222 in 2017. parts_per_set_chart draws a scatter plot, which shows an upward trend: recent sets have roughly twice the parts of sets from the 1960s.
What you gained
.agg({"num_parts": "mean"}) together with .groupby().
- A scatter plot (
.scatter()) uses a dot per data point and shows trends.
- The same slicing trick removes the incomplete last two years.
Previous: Step-5-Two-Axes · Next: Step-7-Themes-and-Keys