From the course: Data Analysis with Python and Pandas
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Pro tip: Transforming DataFrames
From the course: Data Analysis with Python and Pandas
Pro tip: Transforming DataFrames
- [Instructor] Alright, so, so far when we've been doing aggregation, part of that aggregation has included reducing the number of rows in our dataframe. And a lot of the time that's exactly what we want. We want a summary table. So when we think about grouping by the store numbers in our retail dataframe, we go from several hundred thousand rows of data down to 54, one row for each of the stores in our dataframe. But occasionally, we might want to generate aggregate statistics. So I might want to generate the mean sales of my store, but I want to compare that to the data in each row. So maybe I want to say, okay, how well did this store perform on this day versus that store's average? And with our current aggregation tools, we're unable to do that very easily. With the transform method, this is actually quite easy to do and it's super useful when we need to calculate group level statistics to perform a row level analysis, let's take a look. So here we're calling the assigned method…
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)
-
-
-
-
-
-