'Aggregating by two different columns [duplicate]
I'm trying to aggregate this using python pandas, I'm trying to find the Sum of spend and visitors for each network, but only aggregregate them if the months are the same
for example
| month | network | spend | visitors |
|---|---|---|---|
| 9 | CNBC | 10 | 2 |
| 10 | BBC | 10 | 1 |
| 9 | BBC | 10 | 2 |
| 10 | CNBC | 10 | 2 |
| 10 | CNBC | 10 | 2 |
should result
| month | network | spend | visitors |
|---|---|---|---|
| 9 | CNBC | 10 | 2 |
| 9 | BBC | 10 | 2 |
| 10 | CNBC | 20 | 4 |
| 10 | BBC | 10 | 1 |
how would I be able to do this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
