Data Visualization First Steps

Aggregation & Grouping Exercise

Anjana Vakil

Anjana Vakil

Software Engineer & Educator
Data Visualization First Steps

Check out a free preview of the full Data Visualization First Steps course

The "Aggregation & Grouping Exercise" Lesson is part of the full, Data Visualization First Steps course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to use the previous plot example and specify the group's transform inputs and outputs to calculate the sum of all users in each category and visualize the result on the y axis.

Preview
Close

Transcript from the "Aggregation & Grouping Exercise" Lesson

[00:00:00]
>> So we've just walked through this code for this very basic aggregation to make these vertical bar charts based on the number of observations in the data set for each of these device categories. And we saw that we can do this with the groupX transform function combined with the barY mark to make vertical bars and that we're putting the inputs to this groupX transform as being the device category which we're going to put along the x axis and then the output of that group transform is going to be the count meaning the number of observation and counted altogether.

[00:00:44]
And that's going to be output as the height of each bar on the y axis, which is why we get bars of different heights here. However, this is not maybe the most useful information, the count of observations in our data set is probably not what we're ultimately super interested in.

[00:01:02]
What we're interested in is is probably the number of users that are using each of those device categories. So, let's try to adapt this chart to see the breakdown by the total number of users rather than the number of observations. That's gonna be our first exercise here. So in this empty cell right here, we're going to start with this grouped bar chart as an example.

[00:01:28]
So you could just copy that over and then we're going to tweak that code to specify that the group transform should be calculating the sum of the users' value. And visualizing that on the y axis. So that means that we're gonna need to pass in as one of the inputs to that group, transform.

[00:01:51]
We're gonna need to pass in the column of data that we care about summing. So in this case, that's gonna be the user's column. And then as a bonus extra credit exercise. See if you can also figure out how to get the color of each of the three bars to be different to distinguish visually that these are three different categories of device.

[00:02:16]
So feel free to lean on those hints there to get things rolling because this is a kind of a new skill that we're learning here with these group transforms. And again we can use this previous group to chart as a starting point, so you can copy that in and then make some tweaks and feel free to lean on the hints.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now