Skip to content

DEPR: Nonkeyword arguments in to_latex #54601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Other API changes
Deprecations
~~~~~~~~~~~~
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_hdf` except ``path_or_buf``. (:issue:`54229`)
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_latex` except ``buf``. (:issue:`54229`)
- 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 @@ -3306,6 +3306,9 @@ def to_latex(
...

@final
@deprecate_nonkeyword_arguments(
version="3.0", allowed_args=["self", "buf"], name="to_latex"
)
def to_latex(
self,
buf: FilePath | WriteBuffer[str] | None = None,
Expand Down
16 changes: 16 additions & 0 deletions pandas/tests/io/formats/test_to_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ def test_to_latex_midrule_location(self):
)
assert result == expected

def test_to_latex_pos_args_deprecation(self):
# GH-54229
df = DataFrame(
{
"name": ["Raphael", "Donatello"],
"age": [26, 45],
"height": [181.23, 177.65],
}
)
msg = (
r"Starting with pandas version 3.0 all arguments of to_latex except for "
r"the argument 'buf' will be keyword-only."
)
with tm.assert_produces_warning(FutureWarning, match=msg):
df.to_latex(None, None)


class TestToLatexLongtable:
def test_to_latex_empty_longtable(self):
Expand Down