I am trying to merge 2 dataframes that have the same information but broken down differently
df1: #net total at team level
Team Current Sales Previous Sales Team Total Diff
Blue 10 5 5
Orange 20 8 12
Yellow 40 11 29
df2: #net total's broken down by region
Team Region Curr Sales Prev Sales Net Diff
Blue East 4 4 0
Blue West 6 1 5
Orange East 6 3 3
Orange West 14 5 9
Yellow East 15 3 12
Yellow West 25 8 17
Merged Dataframe:
Team Region Curr Sales Previ Sales Net Diff Team Total Diff
Blue East 4 4 0 5
Blue West 6 1 5 5
Orange East 6 3 3 12
Orange West 14 5 9 12
Yellow East 15 3 12 29
Yellow West 25 8 17 29
I am doing this so i can do additional statistical functions in new columns, but i am not sure how to merge the two. If i add df1['Team Total Diff'] to df2, it fills the first 3 records and doesnt fill down for each team name.
if i use the following merge function, i dont see any change:
df2.merge(df1[['team_sort', 'Team']], how='inner', on='Team')
'team_sort' is used as an index to keep the teams sorted based on Net Team Diff in ascending order
Any help would be appreciated