Created
April 8, 2020 15:22
-
-
Save lucascheung/87040518649a91e4f2a2a3c8c1ed234e to your computer and use it in GitHub Desktop.
pandas groupby method with other columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df = df.groupby(['client_id','data_source'],as_index=False).agg({ | |
'client': 'first', | |
'currency': 'first', | |
'total_revenue': 'sum', | |
'total_accrual': 'sum', | |
'revenue': 'sum', | |
'media_cost': 'sum' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment