df1 = DataFrame(np.arange(6).reshape(3, 2), index=['a', 'b', 'c'],
columns=['one', 'two'])
df2 = DataFrame(5 + np.arange(4).reshape(2, 2), index=['a', 'c'],
columns=['three', 'four'])
>>> df1
one two
a 0 1
b 2 3
c 4 5
>>> df2
three four
a 5 6
c 7 8
res = pd.concat([df1, df2], axis=1, levels=['level1', 'level2'],
names=['upper', 'lower'])
>>> res
one two three four
a 0 1 5 6
b 2 3 NaN NaN
c 4 5 7 8
My question is why levels and names are not shown in res output above? Any real example how levels option is used?
Thanks for your time and help