Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.16.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Bug Fixes
- Bug in `plot` not defaulting to matplotlib `axes.grid` setting (:issue:`9792`)

- Bug in ``Series.align`` resets ``name`` when ``fill_value`` is specified (:issue:`10067`)
- Bug in ``read_csv`` causing index name not to be set on an empty DataFrame (:issue:`10184`)
- Bug in ``SparseSeries.abs`` resets ``name`` (:issue:`10241`)


Expand Down
4 changes: 3 additions & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,9 @@ def read(self, nrows=None):
data = self._reader.read(nrows)
except StopIteration:
if nrows is None:
return None, self.names, {}
return _get_empty_meta(self.orig_names,
self.index_col,
self.index_names)
else:
raise

Expand Down
7 changes: 7 additions & 0 deletions pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,13 @@ def test_chunk_begins_with_newline_whitespace(self):
result = self.read_csv(StringIO(data), header=None)
self.assertEqual(len(result), 2)

def test_empty_with_index(self):
# GH 10184
data = 'x,y'
result = self.read_csv(StringIO(data), index_col=0)
expected = DataFrame([], columns=['y'], index=Index([], name='x'))
tm.assert_frame_equal(result, expected)


class TestPythonParser(ParserTests, tm.TestCase):
def test_negative_skipfooter_raises(self):
Expand Down