Skip to content

Commit f6eb10b

Browse files
author
lucas
committed
BUG: Issue 9798 fixed
1 parent 5d57aad commit f6eb10b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

doc/source/whatsnew/v0.16.1.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ Bug Fixes
8888
- Bug in ``FloatArrayFormatter`` where decision boundary for displaying "small" floats in decimal format is off by one order of magnitude for a given display.precision (:issue:`9764`)
8989

9090
- Fixed bug where ``DataFrame.plot()`` raised an error when both ``color`` and ``style`` keywords were passed and there was no color symbol in the style strings (:issue:`9671`)
91+
92+
- Bug in ``read_csv()`` interprets ``index_col=True`` as ``1`` (:issue:`9798`)

pandas/io/parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ def _make_index(self, data, alldata, columns, indexnamerow=False):
905905

906906
def _get_simple_index(self, data, columns):
907907
def ix(col):
908-
if not isinstance(col, compat.string_types):
908+
if not (isinstance(col, compat.string_types) or col is True):
909909
return col
910910
raise ValueError('Index %s invalid' % col)
911911
index = None

pandas/io/tests/test_parsers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,11 @@ def test_usecols_index_col_False(self):
520520
df = self.read_csv(StringIO(s_malformed), usecols=cols, index_col=False)
521521
tm.assert_frame_equal(expected, df)
522522

523+
def test_index_col_is_True(self):
524+
# Issue 9798
525+
self.assertRaises(ValueError, self.read_csv, StringIO(self.ts_data),
526+
index_col=True)
527+
523528
def test_converter_index_col_bug(self):
524529
# 1835
525530
data = "A;B\n1;2\n3;4"

0 commit comments

Comments
 (0)