This lesson introduced you to aggregates in Pandas. You learned:
- How to perform aggregate statistics over individual rows with the same value using
- How to rearrange a DataFrame into a pivot table, a great way to compare data across two dimensions.
Let’s examine some more data from ShoeFly.com. This time, we’ll be looking at data about user visits to the website (the same dataset that you saw in the introduction to this lesson).
The data is a DataFrame called
head() to examine the first few rows of the DataFrame.
utm_source contains information about how users got to ShoeFly’s homepage. For instance, if
groupby statement to calculate how many visits came from each of the different sources. Save your answer to the variable
Remember to use
Paste the following code into
script.py so that you can see the results of your previous groupby:
Our Marketing department thinks that the traffic to our site has been changing over the past few months. Use
groupby to calculate the number of visits to our site from each
utm_source for each
month. Save your answer to the variable
The head of Marketing is complaining that this table is hard to read. Use
pivot to create a pivot table where the rows are
utm_source and the columns are
month. Save your results to the variable
It should look something like this:
|utm_source||1 - January||2 - February||3 - March|
View your pivot table by pasting the following code into