Closes #18 Closes #19 Closes #20 Closes #21 Closes #22 Closes #23 Closes #24 Refs #25 Task: MIL-003#1
20 lines
984 B
Markdown
20 lines
984 B
Markdown
**English** · [Dansk](Step-6-Parts-per-Set-da) · [Bahasa Malaysia](Step-6-Parts-per-Set-ms)
|
|
|
|
# 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](Step-5-Two-Axes) · Next: [Step-7-Themes-and-Keys](Step-7-Themes-and-Keys)
|