filmov
tv
Pandas Transform - Merging GroupBy Results Back into Your DataFrame
![preview_player](https://i.ytimg.com/vi/jcbRt3RWcGI/maxresdefault.jpg)
Показать описание
The Pandas Transform function really comes to the rescue after you realize your groupby results need to somehow be placed back into your original dataframe.
If you need a refresher on how to perform a basic groupby operation in Pandas please visit:
After you go through the motions of getting groupby objects to work for you. You get excited and start grouping by columns that don't even need to be grouped. After the excitement goes down a bit you then hit a wall... bang! So how do I get my groupby results back into my original dataframe, you say to yourself.
Well, if you saw my video on merging dataframes together...
You then start to merge the two dataframes together. It's totally possible but you end up wondering if there is a shortcut or just a simpler way. And yes there is, this is where the Pandas transform function really shines.
I admit it is a bit confusing at first, but transform basically allows you to perform groupby operations and place those results back on your original dataframe. This is wonderful as you will see form the video that there is a lot less code you have to write. This will allow you to be more productive and make your code a bit cleaner.
If you need a refresher on how to perform a basic groupby operation in Pandas please visit:
After you go through the motions of getting groupby objects to work for you. You get excited and start grouping by columns that don't even need to be grouped. After the excitement goes down a bit you then hit a wall... bang! So how do I get my groupby results back into my original dataframe, you say to yourself.
Well, if you saw my video on merging dataframes together...
You then start to merge the two dataframes together. It's totally possible but you end up wondering if there is a shortcut or just a simpler way. And yes there is, this is where the Pandas transform function really shines.
I admit it is a bit confusing at first, but transform basically allows you to perform groupby operations and place those results back on your original dataframe. This is wonderful as you will see form the video that there is a lot less code you have to write. This will allow you to be more productive and make your code a bit cleaner.
Комментарии