Right now I have 2 dataframes. One with donor information and one with fundraiser information. Ideally what I want to do is for each donor sum up their donations and store it in the fundraiser dataframe. Problems are that it is possible to have a fundraiser in multiple events (so need to use the id and event as the key) and not all fundraisers actually collect anything. I've figured out how to groupby the donation dataframe to calculate the amount raised by the fundraisers that collected anything, but I have no idea how to then get that information over to the fundraiser dataframe :(
import pandas as pd
Donors = pd.DataFrame({"event": pd.Series([1,1,1,1,2,2]), "ID": pd.Series(['a','a','b','c','a','d']), "amount": ([1,2,3,4,5,6])})
fundraisers = pd.DataFrame({"event": pd.Series([1,1,1,2,2,1]), "ID": pd.Series(['a','b','c','a','d','e'])})
foo = Donors.groupby(["event", "ID"])["amount"].sum().reset_index()
ideally I want the fundraiser frame to look like:
event | id | amount raised
--------------------------
1 | a | 3
1 | b | 3
1 | c | 4
1 | e | 0
2 | a | 5
2 | d | 6