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

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…

Contents