Trying to return a summed value based on keys from a second DataFrame.
For instance, take column 0 in df1:
0
0 a
1 b
2 c
And sum the matching values from column 1 in df2:
0 1
0 a 4
1 b 3
2 c 2
3 d 1
4 e 7
to return a value of 9. Values in column 0 in both DataFrames are non-repeating.
So far, other than a simple (and not at all Pandas-y) for loop, my best attempt is result = df2.loc[(df2[0]==df1[0]), df2[1]].sum()
, which returns a "Can only compare identically-labeled Series objects" error.
I expect this is straightforward for those with more Pandas experience than I, but I'm Pooh-trying-to-leave-Rabbit's-house level stuck. Thanks for any help!