Closes #18 Closes #19 Closes #20 Closes #21 Closes #22 Closes #23 Closes #24 Refs #25 Task: MIL-003#1
1.0 KiB
1.0 KiB
English · Dansk · Bahasa Malaysia
Step 1: Exploring the brick colours
Question: How many colours does LEGO make, and how many are transparent?
What the code does
count_unique_colours uses .nunique() on the name column: 135 colours. transparent_counts_groupby (.groupby("is_trans").count()) and transparent_counts_value_counts (.value_counts()) give the same answer in two ways: 107 opaque and 28 transparent colours.
What you gained
- Reading a CSV with
pd.read_csvand looking at it with.head(). .nunique()counts distinct values.- The same question can be answered with
.groupby().count()or.value_counts();.value_counts()is the shortcut for counting categories.
Previous: Getting-Started · Next: Step-2-Sets
