I have a dataframe that holds data at a particular level of aggregation – let’s call it regional.
I also have a dict that explains how these regions are formed. Something like this:
map = {'Alabama': 'region_1', 'Arizona': 'region_1', 'Arkansas': 'region_2' ... }
And a set of weights for each state within its region, stored as a series:
Alabama .25
Arizona .75
Arkansas .33
....
Is there an efficient way to apply this disaggregation map to get a new dataframe at a State level?
Aggregation is easy:
df_regional = df_states.groupby(map).sum()
But how can I do disaggregation?
Assuming two dataframes,
df_statesanddf_regional, with the followingstructure:
Does
pandas.mergearrange the data in a way that seems useful?