I have a dataframe with double index, it looks like this:
bal:
ano unit period
business_id id
9564 302 2012 reais anual
303 2011 reais anual
2361 304 2013 reais anual
305 2012 reais anual
2369 306 2013 reais anual
307 2012 reais anual
I have another dataframe that looks like this:
accounts:
A B
id
302 5964168.52 1.097601e+07
303 5774707.15 1.086787e+07
304 3652575.31 6.608469e+06
305 321076.15 6.027066e+06
306 3858137.49 9.733126e+06
I want to merge them so they look like this:
ano unit period A B
business_id id
9564 302 2012 reais anual 5964168.52 1.097601e+07
303 2011 reais anual 5774707.15 1.086787e+07
2361 304 2013 reais anual 3652575.31 6.608469e+06
305 2012 reais anual 321076.15 6.027066e+06
2369 306 2013 reais anual 3858137.49 9.733126e+06
What I'm trying to do is something like this:
bal=bal.merge(accounts,left_on='id', right_index=True)
However I think that the synthax is not correct, since I'm getting a ValueError:
ValueError: len(right_on) must equal the number of levels in the index of "left"
Can anyone help?