pandas aggregate group by code example
Example 1: two groupby pandas
In [8]: grouped = df.groupby('A')
In [9]: grouped = df.groupby(['A', 'B'])
Example 2: pandas sum group by
df.groupby(['Fiscal_Year','Billing_Group'])['CHARGE_AMT'].sum()
Example 3: python aggregate count and sum
df.groupby('Company Name').agg(MySum=('Amount', 'sum'), MyCount=('Amount', 'count'))
Example 4: how can i aggregate without group by in pandas
df.groupby(lambda _ : True).agg(new_col_name = ('col_name', 'agg_function'))