I have a DataFrame df and I create gb = df.groupby("column1"). Now I would like to do the following:
x = gb.apply(lambda x: x["column2"].sum() / df["column2"].sum())
It works but I would like to based everytinh on x not x and df. Ideally I expected that there is a function x.get_source_df and then my solution would be:
x = gb.apply(lambda x: x["column2"].sum() / x.get_source_df()["column2"].sum())
and in that case I could save this lambda function in a dictionary which I could use for any df. Is it possible?