From the course: Data Analysis with Python and Pandas
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Challenge: pivot() and melt()
From the course: Data Analysis with Python and Pandas
Challenge: pivot() and melt()
- [Instructor] All right, everybody. We have a new email in from Chandler Capital. The subject line is Store Transactions Vs. Average. He writes us: "Hey, again, I need to summarize store numbers 1 through 11 by total bonus payable for each day of the week. Can you create a pivot table that has a sum of bonus payable by day of week? Make sure to filter out any rows that had 0 bonus payable first, and add a heatmap across the rows. Then unpivot the table so we have one row for each store and day of the week with the corresponding total owed. Thanks." All right, let's go ahead and take a look at the notebook. Okay, so we're going to be working with the table we created in assignment 4. We're going to be focused on store number, day of week, and bonus payable. We need to build a pivot table with the store number as our index, some day of week columns, and then the sum of bonus payable as our cells. We also want to make sure we filter out stores that had non-zero bonus payable, and then…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Basic aggregations4m 14s
-
(Locked)
The groupby() method4m 32s
-
(Locked)
Challenge: groupby()1m 18s
-
(Locked)
Solution: groupby()2m 11s
-
(Locked)
Grouping by multiple columns4m 41s
-
(Locked)
Challenge: Grouping by multiple columns1m 9s
-
(Locked)
Solution: Grouping by multiple columns3m
-
(Locked)
MultiIndex DataFrames7m 39s
-
(Locked)
Modifying a MultiIndex4m 25s
-
(Locked)
Challenge: MultiIndex DataFrames1m 17s
-
(Locked)
Solution: MultiIndex DataFrames4m 1s
-
(Locked)
The agg() method and named aggregations7m 22s
-
(Locked)
Challenge: The agg() method1m 22s
-
(Locked)
Solution: The agg() method3m 1s
-
(Locked)
Pro tip: Transforming DataFrames6m 50s
-
(Locked)
Challenge: Transforming a DataFrame1m 18s
-
(Locked)
Solution: Transforming a DataFrame4m 27s
-
(Locked)
Pivot tables in pandas6m 40s
-
(Locked)
Multiple aggregation pivot tables2m 54s
-
(Locked)
Pro tip: Pivot table heatmaps4m 35s
-
(Locked)
Melting DataFrames6m 26s
-
(Locked)
Challenge: pivot() and melt()1m 4s
-
(Locked)
Solution: pivot() and melt()5m 39s
-
(Locked)
Key takeaways1m 53s
-
(Locked)
-
-
-
-
-
-