i have a dict, whose two elements are two dataframes with same index and column names. Like the code below:
my_dict = {}
my_dict['df1'] = pd.DataFrame(np.arange(6).reshape(3,2),index = ['r1','r2','r3'],columns=['c1', 'c2'])
my_dict['df2'] = pd.DataFrame((np.arange(6)+10).reshape(3,2),index = ['r1','r2','r3'],columns=['c1', 'c2'])
my_dict['df1']
Out[1]:
c1 c2
r1 0 1
r2 2 3
r3 4 5
my_dict['df2']
Out[2]:
c1 c2
r1 10 11
r2 12 13
r3 14 15
How can i convert to the dict into one dataframe. Index will be kept same as the original one, but i have one more level for columns like the following:
df1 df2
c1 c2 c1 c2
r1 0 1 10 11
r2 2 3 12 13
r3 4 5 14 15