Say I have 2 data frames
df1 = pd.DataFrame({'alpha': ['A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C'],
'number': [1, 2, 3, 4, 5, 6, 7, 8, 9]})
alpha number
0 A 1
1 A 2
2 A 3
3 B 4
4 B 5
5 B 6
6 C 7
7 C 8
8 C 9
df2 = pd.DataFrame({'alpha': ['A', 'B', 'C'],
'mult': [2, 3, 4]})
alpha mult
0 A 2
1 B 3
2 C 4
And I want to create a 3rd dataframe which will multiply all of the values in df1 by the corresponding 'mult' value in df2 based on the specific alpha value. The solution would look like this:
alpha soln
0 A 2
1 A 4
2 A 6
3 B 12
4 B 15
5 B 18
6 C 28
7 C 32
8 C 36
Any tips on how to do this easily?