Skip to content

Commit 1bf271d

Browse files
committed
DEPR: Deprecate read_csv arguments fully
Issue warnings on `read_csv` deprecated args in full, even if the normal defaults were passed in. Closes gh-17828.
1 parent 3c964a4 commit 1bf271d

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

pandas/io/parsers.py

+20-7
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,14 @@ def _read(filepath_or_buffer, kwds):
529529
'buffer_lines',
530530
'float_precision',
531531
}
532+
533+
_deprecated_defaults = {
534+
'as_recarray': None,
535+
'buffer_lines': None,
536+
'compact_ints': None,
537+
'use_unsigned': None,
538+
'tupleize_cols': None
539+
}
532540
_deprecated_args = {
533541
'as_recarray',
534542
'buffer_lines',
@@ -594,7 +602,7 @@ def parser_f(filepath_or_buffer,
594602
comment=None,
595603
encoding=None,
596604
dialect=None,
597-
tupleize_cols=False,
605+
tupleize_cols=None,
598606

599607
# Error Handling
600608
error_bad_lines=True,
@@ -606,9 +614,9 @@ def parser_f(filepath_or_buffer,
606614
# Internal
607615
doublequote=True,
608616
delim_whitespace=False,
609-
as_recarray=False,
610-
compact_ints=False,
611-
use_unsigned=False,
617+
as_recarray=None,
618+
compact_ints=None,
619+
use_unsigned=None,
612620
low_memory=_c_parser_defaults['low_memory'],
613621
buffer_lines=None,
614622
memory_map=False,
@@ -836,7 +844,7 @@ def _get_options_with_defaults(self, engine):
836844
'The %r option is not supported with the'
837845
' %r engine' % (argname, engine))
838846
else:
839-
value = default
847+
value = _deprecated_defaults.get(argname, default)
840848
options[argname] = value
841849

842850
if engine == 'python-fwf':
@@ -962,6 +970,8 @@ def _clean_options(self, options, engine):
962970

963971
for arg in _deprecated_args:
964972
parser_default = _c_parser_defaults[arg]
973+
depr_default = _deprecated_defaults[arg]
974+
965975
msg = ("The '{arg}' argument has been deprecated "
966976
"and will be removed in a future version."
967977
.format(arg=arg))
@@ -970,10 +980,13 @@ def _clean_options(self, options, engine):
970980
msg += ' Please call pd.to_csv(...).to_records() instead.'
971981
elif arg == 'tupleize_cols':
972982
msg += (' Column tuples will then '
973-
'always be converted to MultiIndex')
983+
'always be converted to MultiIndex.')
974984

975-
if result.get(arg, parser_default) != parser_default:
985+
if result.get(arg, depr_default) != depr_default:
986+
# raise Exception(result.get(arg, depr_default), depr_default)
976987
depr_warning += msg + '\n\n'
988+
else:
989+
result[arg] = parser_default
977990

978991
if depr_warning != '':
979992
warnings.warn(depr_warning, FutureWarning, stacklevel=2)

pandas/tests/io/parser/test_unsupported.py

+5
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,15 @@ class TestDeprecatedFeatures(object):
129129

130130
@pytest.mark.parametrize("engine", ["c", "python"])
131131
@pytest.mark.parametrize("kwargs", [{"as_recarray": True},
132+
{"as_recarray": False},
132133
{"buffer_lines": True},
134+
{"buffer_lines": False},
133135
{"compact_ints": True},
136+
{"compact_ints": False},
134137
{"use_unsigned": True},
138+
{"use_unsigned": False},
135139
{"tupleize_cols": True},
140+
{"tupleize_cols": False},
136141
{"skip_footer": 1}])
137142
def test_deprecated_args(self, engine, kwargs):
138143
data = "1,2,3"

0 commit comments

Comments
 (0)