Skip to content

Commit 647f771

Browse files
committed
Merge pull request #7085 from michaelaye/add_notimp_error
adding a NotImplementedError for simultaneous use of nrows and chunksize...
2 parents 2bd4517 + 19a1083 commit 647f771

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

doc/source/v0.14.1.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ Enhancements
8686

8787

8888
- Add ``dropna`` argument to ``value_counts`` and ``nunique`` (:issue:`5569`).
89-
89+
- Add ``NotImplementedError`` for simultaneous use of ``chunksize`` and ``nrows``
90+
for read_csv() (:issue:`6774`).
9091

9192

9293

pandas/io/parsers.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ def _read(filepath_or_buffer, kwds):
227227
# Create the parser.
228228
parser = TextFileReader(filepath_or_buffer, **kwds)
229229

230-
if nrows is not None:
230+
if (nrows is not None) and (chunksize is not None):
231+
raise NotImplementedError("'nrows' and 'chunksize' can not be used"
232+
" together yet.")
233+
elif nrows is not None:
231234
return parser.read(nrows)
232235
elif chunksize or iterator:
233236
return parser

pandas/io/tests/test_parsers.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -1973,13 +1973,6 @@ def test_header_names_backward_compat(self):
19731973
header=0)
19741974
tm.assert_frame_equal(result, expected)
19751975

1976-
def test_integer_overflow_bug(self):
1977-
# #2601
1978-
data = "65248E10 11\n55555E55 22\n"
1979-
1980-
result = self.read_csv(StringIO(data), header=None, sep=' ')
1981-
self.assertTrue(result[0].dtype == np.float64)
1982-
19831976
def test_int64_min_issues(self):
19841977
# #2599
19851978
data = 'A,B\n0,0\n0,'
@@ -2141,6 +2134,10 @@ def test_ignore_leading_whitespace(self):
21412134
expected = DataFrame({'a':[1,4,7], 'b':[2,5,8], 'c': [3,6,9]})
21422135
tm.assert_frame_equal(result, expected)
21432136

2137+
def test_nrows_and_chunksize_raises_notimplemented(self):
2138+
data = 'a b c'
2139+
self.assertRaises(NotImplementedError, self.read_csv, StringIO(data),
2140+
nrows=10, chunksize=5)
21442141

21452142

21462143
class TestPythonParser(ParserTests, tm.TestCase):

0 commit comments

Comments
 (0)