In this video I am going to show you how I am able to name my group calculations using pd.namedAgg.
import library
import pandas as pd
read data into Clipboard
df = pd.read_clipboard()
create a group object
object = df.groupby('Treatment')
this is how I normally add over the group
object.sum()
this is how you can name your aggregate columns
object.agg(sum_of_cost=pd.NamedAgg(column='Cost', aggfunc='sum'),
avg_of_cost=pd.NamedAgg(column='Cost', aggfunc='mean'))
Watch video How I use the method namedAgg online without registration, duration hours minute second in high quality. This video was added by user Learn Pandas 02 August 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 18 once and liked it 2 people.