I am reading an excel file with following structure -
and using the following code -
df = pd.read_excel("Myfile.xlsx", header=[0,1])
print(df.columns.ravel())
I expect the output should be like
[('Unnamed: 0_level_0', 'Id') ('Name', 'First Name')
('Name', 'Middle name') ('Name', 'Last name') ('Unnamed: 1_level_0', 'Age')
('Unnamed: 2_level_0', 'Email') ('Unnamed: 3_level_0', 'Phone') ('Address', 'House NO')
('Address', 'Street') ('Address', 'City') ('Address', 'State')
('Address', 'PIN')]
But what I get is -
[('Unnamed: 0_level_0', 'Id') ('Name', 'First Name')
('Name', 'Middle name') ('Name', 'Last name') ('Name', 'Age')
('Name', 'Email') ('Name', 'Phone') ('Address', 'House NO')
('Address', 'Street') ('Address', 'City') ('Address', 'State')
('Address', 'PIN')]
Anyone has any clue why am I not getting the output as desired or is it what is desired? As the middle columns (Age, Email & Phone) are not part of Name (level 0 column), so what is being shown is incorrect. Any clue to resolve this?