Skip to content

Commit

Permalink
deprecated non keyword arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
rsm-23 committed Aug 17, 2023
1 parent 7c9ba89 commit e04e1f7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Other API changes

Deprecations
~~~~~~~~~~~~
-
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_pickle` except ``path``. (:issue:`54229`)
-

.. ---------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3017,6 +3017,9 @@ def to_sql(
)

@final
@deprecate_nonkeyword_arguments(
version=None, allowed_args=["self", "path"], name="to_pickle"
)
@doc(
storage_options=_shared_docs["storage_options"],
compression_options=_shared_docs["compression_options"] % "path",
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/generic/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,13 @@ def test_bool_dep(self) -> None:
)
with tm.assert_produces_warning(FutureWarning, match=msg_warn):
DataFrame({"col": [False]}).bool()

def test_drop_pos_args_deprecation_for_to_pickle(self):
# GH-54229
df = DataFrame({"a": [1, 2, 3]})
msg = (
r"In a future version of pandas all arguments of to_pickle "
r"except for the argument 'path' will be keyword-only"
)
with tm.assert_produces_warning(FutureWarning, match=msg):
df.to_pickle("./dummy.pkl", "infer")

0 comments on commit e04e1f7

Please sign in to comment.