Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def parse(
sheets = list(dict.fromkeys(sheets).keys())

output = {}

header_input = header
for asheetname in sheets:
if verbose:
print(f"Reading sheet {asheetname}")
Expand All @@ -475,7 +475,10 @@ def parse(
output[asheetname] = DataFrame()
continue

if is_list_like(header) and len(header) == 1:
if isinstance(header_input, dict):
header = header_input[asheetname]

elif is_list_like(header) and len(header) == 1:
header = header[0]

# forward fill and pull out names for MultiIndex column
Expand All @@ -487,12 +490,13 @@ def parse(
for row in header:
if is_integer(skiprows):
row += skiprows
# the line we changed
if row:
data[row], control_row = fill_mi_header(data[row], control_row)

data[row], control_row = fill_mi_header(data[row], control_row)

if index_col is not None:
header_name, _ = pop_header_name(data[row], index_col)
header_names.append(header_name)
if index_col is not None:
header_name, _ = pop_header_name(data[row], index_col)
header_names.append(header_name)

if is_list_like(index_col):
# Forward fill values for MultiIndex index.
Expand Down