Skip to content

Commit 04f03fb

Browse files
authored
DEPR: deprecated nonkeyword arguments in to_html (#54612)
deprecated nonkeyword arguments
1 parent 8af96fc commit 04f03fb

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

doc/source/whatsnew/v2.2.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Other API changes
9393
Deprecations
9494
~~~~~~~~~~~~
9595
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_hdf` except ``path_or_buf``. (:issue:`54229`)
96+
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_html` except ``buf``. (:issue:`54229`)
9697
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_json` except ``path_or_buf``. (:issue:`54229`)
9798
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_latex` except ``buf``. (:issue:`54229`)
9899
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_markdown` except ``buf``. (:issue:`54229`)

pandas/core/frame.py

+3
Original file line numberDiff line numberDiff line change
@@ -3134,6 +3134,9 @@ def to_html(
31343134
) -> str:
31353135
...
31363136

3137+
@deprecate_nonkeyword_arguments(
3138+
version="3.0", allowed_args=["self", "buf"], name="to_html"
3139+
)
31373140
@Substitution(
31383141
header_type="bool",
31393142
header="Whether to print column labels, default True",

pandas/tests/io/formats/test_to_html.py

+11
Original file line numberDiff line numberDiff line change
@@ -978,3 +978,14 @@ def test_to_html_empty_complex_array():
978978
"</table>"
979979
)
980980
assert result == expected
981+
982+
983+
def test_to_html_pos_args_deprecation():
984+
# GH-54229
985+
df = DataFrame({"a": [1, 2, 3]})
986+
msg = (
987+
r"Starting with pandas version 3.0 all arguments of to_html except for the "
988+
r"argument 'buf' will be keyword-only."
989+
)
990+
with tm.assert_produces_warning(FutureWarning, match=msg):
991+
df.to_html(None, None)

0 commit comments

Comments
 (0)