Skip to content

adding a NotImplementedError for simultaneous use of nrows and chunksize... #7085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2014
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
3 changes: 2 additions & 1 deletion doc/source/v0.14.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ Enhancements


- Add ``dropna`` argument to ``value_counts`` and ``nunique`` (:issue:`5569`).

- Add ``NotImplementedError`` for simultaneous use of ``chunksize`` and ``nrows``
for read_csv() (:issue:`6774`).



Expand Down
5 changes: 4 additions & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ def _read(filepath_or_buffer, kwds):
# Create the parser.
parser = TextFileReader(filepath_or_buffer, **kwds)

if nrows is not None:
if (nrows is not None) and (chunksize is not None):
raise NotImplementedError("'nrows' and 'chunksize' can not be used"
" together yet.")
elif nrows is not None:
return parser.read(nrows)
elif chunksize or iterator:
return parser
Expand Down
11 changes: 4 additions & 7 deletions pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1973,13 +1973,6 @@ def test_header_names_backward_compat(self):
header=0)
tm.assert_frame_equal(result, expected)

def test_integer_overflow_bug(self):
# #2601
data = "65248E10 11\n55555E55 22\n"

result = self.read_csv(StringIO(data), header=None, sep=' ')
self.assertTrue(result[0].dtype == np.float64)

def test_int64_min_issues(self):
# #2599
data = 'A,B\n0,0\n0,'
Expand Down Expand Up @@ -2141,6 +2134,10 @@ def test_ignore_leading_whitespace(self):
expected = DataFrame({'a':[1,4,7], 'b':[2,5,8], 'c': [3,6,9]})
tm.assert_frame_equal(result, expected)

def test_nrows_and_chunksize_raises_notimplemented(self):
data = 'a b c'
self.assertRaises(NotImplementedError, self.read_csv, StringIO(data),
nrows=10, chunksize=5)


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