Skip to content

Commit 6a4c85d

Browse files
committed
Fix for issue pandas-dev#11317
This includes updates to 3 Excel files, plus a test in test_excel.py, plus the fix in parsers.py
1 parent 3914e0f commit 6a4c85d

File tree

5 files changed

+7
-1
lines changed

5 files changed

+7
-1
lines changed

pandas/io/parsers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def _extract_multi_indexer_columns(self, header, index_names, col_names,
867867
field_count = len(header[0])
868868

869869
def extract(r):
870-
return tuple([r[i] for i in range(field_count) if i not in sic])
870+
return tuple([str(r[i]) for i in range(field_count) if i not in sic])
871871

872872
columns = lzip(*[extract(r) for r in header])
873873
names = ic + columns
-1.5 KB
Binary file not shown.
1.86 KB
Binary file not shown.
1.77 KB
Binary file not shown.

pandas/io/tests/test_excel.py

+6
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,12 @@ def test_read_excel_multiindex(self):
557557
actual = read_excel(mi_file, 'mi_column_name', header=[0,1], index_col=0)
558558
tm.assert_frame_equal(actual, expected)
559559

560+
# Issue #11317
561+
expected.columns = mi.set_levels(['1','2'],level=1).set_names(['c1', 'c2'])
562+
actual = read_excel(mi_file, 'name_with_int', index_col=0, header=[0,1])
563+
tm.assert_frame_equal(actual, expected)
564+
565+
expected.columns = mi.set_names(['c1', 'c2'])
560566
expected.index = mi.set_names(['ilvl1', 'ilvl2'])
561567
actual = read_excel(mi_file, 'both_name', index_col=[0,1], header=[0,1])
562568
tm.assert_frame_equal(actual, expected)

0 commit comments

Comments
 (0)