Is it possible to have this kind of disposition in pd.DataFrame :
CodePudding user response:
Create DataFrame by constructor with
import pandas as pd
dt = pd.read_excel("1.xlsx", header=[0,1])
print(dt.head())
print(dt.columns)
output:
id male
Unnamed: 0_level_1 name age
0 1 mary 19
1 2 emily 20
MultiIndex([( 'id', 'Unnamed: 0_level_1'),
('male', 'name'),
('male', 'age')],
)