From the course: Data Analysis with Python and Pandas
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Pivot tables in pandas
From the course: Data Analysis with Python and Pandas
Pivot tables in pandas
- [Instructor] All right, so let's take a look at pivot tables in Pandas. Pivot tables are a great way to create summary tables of data. They differ from our traditional aggregations. And to be honest, I tend to stick with our group by and agg for most use cases. But there are some very nice use cases for pivot tables that we really can't approximate with group by very easily. And if you're coming to us from Excel, you're going to find right at home with pivot tables in Pandas. Let's take a look at the similarities between pivot tables in Pandas and pivot tables in Excel. So to create a pivot table in Pandas, we need to call the pivot table method on a data frame. We need to specify which column we want to be our rows, which column we want to form our columns, which values we want to aggregate, and how we want to aggregate those values. In Excel, we would do something very similar. We have columns, which is the same argument in our pivot table method. We have rows, which is equivalent…
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)
-
-
-
-
-
-