Skip to content

Commit 065b3d0

Browse files
authored
Changed as requested in #52716 and added test for checking this issue… (#52796)
* Changed as requested in #52716 and added test for checking this issue #52749 * Changed as requested in #52716 and added test for checking this issue
1 parent 1ac599c commit 065b3d0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/io/excel/_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
names : array-like, default None
120120
List of column names to use. If file contains no header row,
121121
then you should explicitly pass header=None.
122-
index_col : int, list of int, default None
122+
index_col : int, str, list of int, default None
123123
Column (0-indexed) to use as the row labels of the DataFrame.
124124
Pass None if there is no such column. If a list is passed,
125125
those columns will be combined into a ``MultiIndex``. If a

pandas/tests/io/excel/test_readers.py

+8
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ def test_index_col_label_error(self, read_ext):
340340
usecols=["A", "C"],
341341
)
342342

343+
def test_index_col_str(self, read_ext):
344+
# see gh-52716
345+
result = pd.read_excel("test1" + read_ext, sheet_name="Sheet3", index_col="A")
346+
expected = DataFrame(
347+
columns=["B", "C", "D", "E", "F"], index=Index([], name="A")
348+
)
349+
tm.assert_frame_equal(result, expected)
350+
343351
def test_index_col_empty(self, read_ext):
344352
# see gh-9208
345353
result = pd.read_excel(

0 commit comments

Comments
 (0)