Playing with Lego Data from Rebrickable

2 minute read

Source: This exploratory analysis originated from a DataCamp project.

Ah, the good old childhood days of playing with your Lego sets. I went down this memory lane last week when I visited a bookstore and found a Lego play area. I added bricks to someone else’s tower and built a car next to it. #opensource #ftw

Fun fact: “Lego” was derived from the Danish phrase leg godt, which means “play well”.

In this analysis, let's explore the colors of the bricks and the different parts and themes of the sets.


About the Data

A comprehensive database of lego blocks is provided by Rebrickable. The data is available as csv files and the schema is shown below.


Getting a sense of the diversity of Lego sets!

First 5 rows of colors data

   id            name     rgb is_trans
0  -1         Unknown  0033B2        f
1   0           Black  05131D        f
2   1            Blue  0055BF        f
3   2           Green  237841        f
4   3  Dark Turquoise  008F9B        f

How many distinct colors of bricks are available?

135 colors

Transparent Colors in Lego Sets

The colors data has a column named is_trans that indicates whether a color is transparent (t) or not (f).

Exploring the distribution of transparent vs. non-transparent colors.

           id  name  rgb
f         107   107  107
t          28    28   28

Explore Lego Sets

Another interesting dataset available in this database is the sets data. It contains a comprehensive list of sets over the years and the number of parts that each of these sets contained.


Let us use this data to explore how the average number of parts in Lego sets has varied over the years.

1950  10.142857
1953  16.500000
1954  12.357143
1955  36.857143
1956  18.500000

Lego Themes Over Years

Lego blocks ship under multiple themes. Let us try to get a sense of how the number of themes shipped has varied over the years.

1950         2
1953         1
1954         2
1955         4
1956         3
...        ...
2013        93
2014        92
2015        99
2016        88
2017        78

[66 rows x 1 columns]

Ending with Star Wars

Star Wars: The Phantom Menace was released in 1999. We saw Lego coming out with Star Wars special edition that became a huge success. Let's take a closer look at the themes_by_year to study the number of unique themes that Lego released in 1999

71 themes released in 1999


Lego blocks offer an unlimited amount of fun across ages. We explored some interesting and basic trends around colors, parts, and themes in this analysis. The database is rich with more information for enthusiasts looking to dive deeper.


For more detail, code and interactive graphs Visit Notebook

Leave a comment