Skip to content

Commit a72ecbe

Browse files
committed
DEPR, DOC: Deprecate buffer_lines in read_csv
The 'buffer_lines' parameter is not even respected in the implementation, as it is determined internally to the C parser. [ci skip]
1 parent 103f7d3 commit a72ecbe

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

doc/source/io.rst

+6
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ low_memory : boolean, default ``True``
176176
Note that the entire file is read into a single DataFrame regardless,
177177
use the ``chunksize`` or ``iterator`` parameter to return the data in chunks.
178178
(Only valid with C parser)
179+
buffer_lines : int, default None
180+
DEPRECATED: this argument will be removed in a future version because its
181+
value is not respected by the parser
182+
183+
If ``low_memory`` is ``True``, specify the number of rows to be read for
184+
each chunk. (Only valid with C parser)
179185
compact_ints : boolean, default False
180186
DEPRECATED: this argument will be removed in a future version
181187

doc/source/whatsnew/v0.18.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ Deprecations
294294
^^^^^^^^^^^^
295295

296296
- ``compact_ints`` and ``use_unsigned`` have been deprecated in ``pd.read_csv`` and will be removed in a future version (:issue:`13320`)
297+
- ``buffer_lines`` has been deprecated in ``pd.read_csv`` and will be removed in a future version (:issue:`13360`)
297298

298299
.. _whatsnew_0182.performance:
299300

pandas/io/parsers.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,19 @@
227227
Note that the entire file is read into a single DataFrame regardless,
228228
use the `chunksize` or `iterator` parameter to return the data in chunks.
229229
(Only valid with C parser)
230+
buffer_lines : int, default None
231+
DEPRECATED: this argument will be removed in a future version because its
232+
value is not respected by the parser
233+
234+
If low_memory is True, specify the number of rows to be read for each
235+
chunk. (Only valid with C parser)
230236
compact_ints : boolean, default False
231237
DEPRECATED: this argument will be removed in a future version
232238
233239
If compact_ints is True, then for any column that is of integer dtype,
234240
the parser will attempt to cast it as the smallest integer dtype possible,
235241
either signed or unsigned depending on the specification from the
236242
`use_unsigned` parameter.
237-
238243
use_unsigned : boolean, default False
239244
DEPRECATED: this argument will be removed in a future version
240245
@@ -448,6 +453,7 @@ def _read(filepath_or_buffer, kwds):
448453
'float_precision',
449454
])
450455
_deprecated_args = set([
456+
'buffer_lines',
451457
'compact_ints',
452458
'use_unsigned',
453459
])
@@ -806,7 +812,8 @@ def _clean_options(self, options, engine):
806812
_validate_header_arg(options['header'])
807813

808814
for arg in _deprecated_args:
809-
if result[arg] != _c_parser_defaults[arg]:
815+
parser_default = _c_parser_defaults[arg]
816+
if result.get(arg, parser_default) != parser_default:
810817
warnings.warn("The '{arg}' argument has been deprecated "
811818
"and will be removed in a future version"
812819
.format(arg=arg), FutureWarning, stacklevel=2)

pandas/io/tests/parser/test_parsers.py

-2
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,12 @@ def read_csv(self, *args, **kwds):
7272
kwds = kwds.copy()
7373
kwds['engine'] = self.engine
7474
kwds['low_memory'] = self.low_memory
75-
kwds['buffer_lines'] = 2
7675
return read_csv(*args, **kwds)
7776

7877
def read_table(self, *args, **kwds):
7978
kwds = kwds.copy()
8079
kwds['engine'] = self.engine
8180
kwds['low_memory'] = True
82-
kwds['buffer_lines'] = 2
8381
return read_table(*args, **kwds)
8482

8583

pandas/io/tests/parser/test_unsupported.py

+5
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def test_deprecated_args(self):
124124

125125
# deprecated arguments with non-default values
126126
deprecated = {
127+
'buffer_lines': True,
127128
'compact_ints': True,
128129
'use_unsigned': True,
129130
}
@@ -132,6 +133,10 @@ def test_deprecated_args(self):
132133

133134
for engine in engines:
134135
for arg, non_default_val in deprecated.items():
136+
if engine == 'python' and arg == 'buffer_lines':
137+
# unsupported --> exception is raised first
138+
continue
139+
135140
with tm.assert_produces_warning(
136141
FutureWarning, check_stacklevel=False):
137142
kwargs = {arg: non_default_val}

0 commit comments

Comments
 (0)