I have 2 dataframes:
df1: (3 rows, 3 columns)
Type CA AR OR Total
alpha 2 3 1 6
beta 1 5 2 8
delta 8 1 1 10
df2: (4 rows, 2 columns)
Type CA AR Total
alpha 3 4 7
beta 2 6 8
gamma 9 1 10
delta 4 1 5
I want to add the values in the two dataframes. The result should be as below:
I tried df1 + df2, but the problem I face is that the two dataframes are different dimensions / sizes. Is there any sort of function that will let me add the rows/columns that have the same row/column name (some sort of match function to match the names.) In the event that there are no occurences of the value (in this case --> gamma, OR, I want it to print 0/NA --> I don't care what actually.)
And I need to be some sort of match and not hard-coded because I will be doing this for several tables.
Type CA AR OR Total
alpha 5 7 1 13
beta 3 11 2 16
gamma 9 1 0 10
delta 12 2 1 15
Thanks!!