Skip to content

Commit

Permalink
CLN: Deprecate non-keyword arguments in read_table pandas-dev#41485 (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
tegardp authored and TLouf committed Jun 1, 2021
1 parent 58013f4 commit 8d197d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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 @@ -702,7 +702,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
3 changes: 3 additions & 0 deletions pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,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
12 changes: 12 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,15 @@ 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
data = 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(data, " ")

0 comments on commit 8d197d3

Please sign in to comment.