Skip to content

Commit

Permalink
CLN: Deprecate non-keyword arguments in read_table pandas-dev#41485
Browse files Browse the repository at this point in the history
  • Loading branch information
tegardp committed May 29, 2021
1 parent a811c96 commit 2e18f91
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ Deprecations
- Deprecated passing arguments as positional in :meth:`DataFrame.where` and :meth:`Series.where` (other than ``"cond"`` and ``"other"``) (:issue:`41485`)
- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_csv` (:issue:`41485`)
- Deprecated passing arguments as positional in :meth:`DataFrame.drop` (other than ``"labels"``) and :meth:`Series.drop` (:issue:`41485`)
-
- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_table` (:issue:`41485`)


.. _whatsnew_130.deprecations.nuisance_columns:
Expand Down
4 changes: 3 additions & 1 deletion pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,9 @@ def read_csv(

return _read(filepath_or_buffer, kwds)


@deprecate_nonkeyword_arguments(
version=None, allowed_args=["filepath_or_buffer"], stacklevel=3
)
@Appender(
_doc_read_csv_and_table.format(
func_name="read_table",
Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/io/parser/common/test_common_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,3 +823,14 @@ def test_malformed_second_line(all_parsers):
result = parser.read_csv(StringIO(data), skip_blank_lines=False, header=1)
expected = DataFrame({"a": ["b"]})
tm.assert_frame_equal(result, expected)

def test_read_table_posargs_deprecation(all_parsers):
# https://github.com/pandas-dev/pandas/issues/41485
f = StringIO("a\tb\n1\t2")
parser = all_parsers
msg = (
"In a future version of pandas all arguments of read_table "
"except for the argument 'filepath_or_buffer' will be keyword-only"
)
with tm.assert_produces_warning(FutureWarning, match=msg):
parser.read_table(f, " ")

0 comments on commit 2e18f91

Please sign in to comment.