# Nothing to do here
# Import modules
import pandas as pd
# Read colors data
colors = pd.read_csv('datasets/colors.csv')
# Print the first few rows
colors.head()
idint64
nameobject
0
-1
Unknown
1
0
Black
2
1
Blue
3
2
Green
4
3
Dark Turquoise
# How many distinct colors are available?
# -- YOUR CODE FOR TASK 3 --
num_colors = colors.rgb.count()
num_colors
# colors_summary: Distribution of colors based on transparency
# -- YOUR CODE FOR TASK 4 --
colors_summary = colors.groupby('is_trans').count()
print(colors_summary)
id name rgb
is_trans
f 107 107 107
t 28 28 28
%matplotlib inline
# Read sets data as `sets`
sets = pd.read_csv('datasets/sets.csv')
# Create a summary of average number of parts by year: `parts_by_year`
parts_by_year = sets[['year', 'num_parts']].groupby('year').mean()
# Plot trends in average number of parts by year
parts_by_year
num_partsfloat64
10.142857142857142 - 300.1212765957447
1950
10.142857142857142
1953
16.5
1954
12.357142857142858
1955
36.857142857142854
1956
18.5
1957
42.61904761904762
1958
44.45238095238095
1959
16.25
1960
175.33333333333334
1961
70.58823529411765
# themes_by_year: Number of themes shipped by year
# -- YOUR CODE HERE --
themes_by_year = sets[['year','theme_id']]\
.groupby('year', as_index=False)\
.agg({'theme_id':pd.Series.nunique})
themes_by_year.count()
# Nothing to do here