Skip to content

Commit bc9b470

Browse files
authored
CLN: Deprecate non-keyword arguments in read_table #41485 (#41717)
1 parent 67b79e5 commit bc9b470

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

doc/source/whatsnew/v1.3.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ Deprecations
702702
- Deprecated passing arguments as positional in :meth:`DataFrame.where` and :meth:`Series.where` (other than ``"cond"`` and ``"other"``) (:issue:`41485`)
703703
- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_csv` (:issue:`41485`)
704704
- Deprecated passing arguments as positional in :meth:`DataFrame.drop` (other than ``"labels"``) and :meth:`Series.drop` (:issue:`41485`)
705-
-
705+
- Deprecated passing arguments as positional (other than ``filepath_or_buffer``) in :func:`read_table` (:issue:`41485`)
706706

707707

708708
.. _whatsnew_130.deprecations.nuisance_columns:

pandas/io/parsers/readers.py

+3
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,9 @@ def read_csv(
592592
return _read(filepath_or_buffer, kwds)
593593

594594

595+
@deprecate_nonkeyword_arguments(
596+
version=None, allowed_args=["filepath_or_buffer"], stacklevel=3
597+
)
595598
@Appender(
596599
_doc_read_csv_and_table.format(
597600
func_name="read_table",

pandas/tests/io/parser/common/test_common_basic.py

+12
Original file line numberDiff line numberDiff line change
@@ -823,3 +823,15 @@ def test_malformed_second_line(all_parsers):
823823
result = parser.read_csv(StringIO(data), skip_blank_lines=False, header=1)
824824
expected = DataFrame({"a": ["b"]})
825825
tm.assert_frame_equal(result, expected)
826+
827+
828+
def test_read_table_posargs_deprecation(all_parsers):
829+
# https://github.com/pandas-dev/pandas/issues/41485
830+
data = StringIO("a\tb\n1\t2")
831+
parser = all_parsers
832+
msg = (
833+
"In a future version of pandas all arguments of read_table "
834+
"except for the argument 'filepath_or_buffer' will be keyword-only"
835+
)
836+
with tm.assert_produces_warning(FutureWarning, match=msg):
837+
parser.read_table(data, " ")

0 commit comments

Comments
 (0)