So… I have a DataFrame like this
Brand Code Sells1 Sells2 TotalSell
A 123 4 8 12
B 456 0 24 24
A aaa 9 6 12
B 456 0 24 24
A aaa 9 6 12
How can I group all de rows with same ‘Code’ value, while summing the sells and not losing the ‘Brand’ value nor changing it.
I tried using
df.groupby([‘Brand’, ‘Code’])[‘Sells1’, ‘Sells2’, ‘TotalSell’].sum()
and some syntaxis variations of it, but seems like note the right approach, or am I making some mistake?
Melissa Ledesma Olmos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.