I want to merge df1 and df2. I used concat function with outer join and use multi index.
The result is merged index value,, I want to divide index columns..
Please advise me how to do.
df1:
CODE U-01 U-02 U-03 U-04 U-05
INDEX host
L1 A 3.0 3.0 3.0 3.0 3.0
L2 B 3.0 3.0 3.0 3.0 3.0
L3 C 3.0 3.0 3.0 3.0 3.0
L4 D 3.0 3.0 3.0 3.0 3.0
df2:
CODE U-01 U-02 U-03 U-04 U-05
LEVEL H L H M L
STANDARD 3 3 3 3 2
so, My code is ,
total_data = pd.concat([df1, df2], join='outer')
But, The result is
U-01 U-02 U-03 U-04 U-05
LEVEL H L H M L
STANDARD 3 3 3 3 2
(L1,A) 3.0 3.0 3.0 3.0 3.0
(L2,B) 3.0 3.0 3.0 3.0 3.0
(L3,C) 3.0 3.0 3.0 3.0 3.0
(L4,D) 3.0 3.0 3.0 3.0 3.0
I want to split the column and use multi index.
Desired result would be :
U-01 U-02 U-03 U-04 U-05
LEVEL H L H M L
STANDARD 3 3 3 3 2
L1 A 3.0 3.0 3.0 3.0 3.0
L2 B 3.0 3.0 3.0 3.0 3.0
L3 C 3.0 3.0 3.0 3.0 3.0
L4 D 3.0 3.0 3.0 3.0 3.0
index = INDEX, host
print (df1.index.tolist()),print (df1.columns.tolist()),print (df2.index.tolist()),print (df2.columns.tolist())?MultiIndex[(L1,A], (L2,B), (L3,C), (L4,D)]df1. columns :Index['U-01', 'U-02', 'U-03', 'U-04', 'U-05']df2.index :Index['LEVEL', 'STANDARD']df2. columns :Index['U-01', 'U-02', 'U-03', 'U-04', 'U-05']