I have a list of dictionaries that I need to populate in Python:
data = [{"startDate": 123, "endDate": 456, "campaignName": "abc", "campaignCfid": 789, "budgetImpressions": 10},
{"startDate": 123, "endDate": 456, "campaignName": "abc", "campaignCfid": 789, "budgetImpressions": 50},
{"startDate": 456, "endDate": 789, "campaignName": "def", "campaignCfid": 123, "budgetImpressions": 80}]
and I'm going to aggregate based on budgetImpressions.
So, the end result should be:
data = [{"startDate": 123, "endDate": 456, "campaignName": "abc", "campaignCfid": 789, "budgetImpressions": 60},
{"startDate": 456, "endDate": 789, "campaignName": "def", "campaignCfid": 123, "budgetImpressions": 80}]
Note that each entry with a specific campaign name will always have the same corresponding campaignCfid, startDate, and endDate.
Can this be done in Python? I tried using itertools without much success. Would there be a better approach to using Pandas?