From the course: Python for Data Science Tips, Tricks, & Techniques

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Aggregate data with Pandas

Aggregate data with Pandas - Python Tutorial

From the course: Python for Data Science Tips, Tricks, & Techniques

Start my 1-month free trial

Aggregate data with Pandas

- [Instructor] It's really common for us to want to aggregate some data in order to understand it a bit better. So using pandas, there are some really powerful built-in functions here. If I open up the exercise files for this video, I'll find some really basic things that we want to do. I want to show you how to create a yearly sales summary out of our sales data, then break it down by product, and then look at the overall product totals. So to get started, I'll import pandas. Then I'm going to read in the CSV file for our monthly product sales, and we're going to create a data frame out of that. Here I'm going to use groupby on my data frame and tell it that I want to essentially group by the first four characters of the month of order date. So this is going to give me the year. If you remember what the format looks like, it's year-month-day. Then we're going to have to describe that and reset the index and rename some of the columns. And we can do this all in one shot here. So…

Contents