8000 WARN: Add FutureWarning to `DataFrame.to_html` by attack68 · Pull Request #44451 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

WARN: Add FutureWarning to DataFrame.to_html #44451

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2fa2246
add warning
attack68 Nov 12, 2021
89225de
add test
attack68 Nov 12, 2021
1119a27
fix doc warnings
attack68 Nov 12, 2021
93d9288
fix test for warning
attack68 Nov 12, 2021
2e653fe
filterwarnings
attack68 Nov 13, 2021
8e10574
skip doctest
attack68 Nov 13, 2021
e4fa4ef
test warnings
attack68 Nov 13, 2021
e20c5d9
test warnings
attack68 Nov 13, 2021
e6fc67e
Merge remote-tracking branch 'upstream/master' into depr_to_html_to_l…
attack68 Nov 14, 2021
310bdc2
warn and expand tests
attack68 Nov 14, 2021
3524116
see also
attack68 Nov 14, 2021
43acc91
Merge remote-tracking branch 'upstream/master' into depr_to_html_afte…
attack68 Nov 24, 2021
f41a438
allow warnings in io.rst
attack68 Nov 24, 2021
ad8cf24
allow warnings in scale.rst
attack68 Nov 24, 2021
0d5b4b3
aedit io.rst
attack68 Nov 24, 2021
bd5e91c
aedit io.rst
attack68 Nov 24, 2021
7e3c3df
test warnings
attack68 Nov 25, 2021
7de29d1
remove okwarning
attack68 Nov 25, 2021
f2a944a
pytest filters
attack68 Nov 25, 2021
5f4d55c
Merge remote-tracking branch 'upstream/master' into depr_to_html_afte…
attack68 Nov 26, 2021
6a4523e
whats new
attack68 Nov 26, 2021
9e66a72
add explicit test
attack68 Nov 26, 2021
505953d
Merge remote-tracking branch 'upstream/master' into depr_to_html_afte…
attack68 Dec 7, 2021
d859877
more specific warnings
attack68 Dec 7, 2021
02d913c
more specific warnings
attack68 Dec 7, 2021
7d5ab6c
more specific warnings (filters removed)
attack68 Dec 7, 2021
a9e4ac4
more specific warnings (filters removed)
attack68 Dec 7, 2021
ee97624
Merge remote-tracking branch 'upstream/master' into depr_to_html_afte…
attack68 Dec 15, 2021
10a34cb
Merge remote-tracking branch 'upstream/master' into depr_to_html_afte…
attack68 Dec 18, 2021
272670a
doc string addition
attack68 Dec 22, 2021
3af20b6
Merge remote-tracking branch 'upstream/master' into depr_to_html_afte…
attack68 Dec 22, 2021
6962393
Merge remote-tracking branch 'upstream/master' into depr_to_html_afte…
attack68 Jan 2, 2022
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
Prev Previous commit
Next Next commit
warn and expand tests
  • Loading branch information
attack68 committed Nov 14, 2021
commit 310bdc2fa099599bbb57e4291847a53a02cbd06a
9 changes: 9 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2855,6 +2855,15 @@ def to_html(
--------
to_string : Convert DataFrame to a string.
"""
msg = (
"In future versions `DataFrame.to_html` is expected to utilise the base "
"implementation of `Styler.to_html` for formatting and rendering. "
"The arguments signature may therefore change. It is recommended instead "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we intend to keep DataFrame.to_html but only change the signature, then I think such a general deprecation warning is overly broad (many people doing just df.to_html() will also see the warning while they actually don't need to change anything?)

Would it be an alternative to specifically check for keywords we know will change in the signature, and only warn for those?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an example is #41648 on which kwargs might be removed or changed.

there are quite a few, and to be honest not sure at this point we could commit to knowing with certainty how they will change.

i agree with you that it might be overly broad, the warning does not show in jupyter notebook when rendering a df by default, only when the method to_html is specifically called

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something else i considered was just implementing a DataFrame.to_html2 method temporarily, and then issuing the warning and progressively merging through version cycles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorisvandenbossche I have gone through and targeted the kwargs that will change and and only warn when they are input as non-default values. Please review

"to use `DataFrame.style.to_html` which also contains additional "
"functionality."
)
warnings.warn(msg, FutureWarning, stacklevel=find_stack_level())

if justify is not None and justify not in fmt._VALID_JUSTIFY_PARAMETERS:
raise ValueError("Invalid value for justify parameter")

Expand Down
8000
3 changes: 2 additions & 1 deletion pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -3299,6 +3299,7 @@ def test_repr_html_ipython_config(ip):


@pytest.mark.filterwarnings("ignore:In future versions `DataFrame.to_latex`")
@pytest.mark.filterwarnings("ignore:In future versions `DataFrame.to_html`")
@pytest.mark.parametrize("method", ["to_string", "to_html", "to_latex"])
@pytest.mark.parametrize(
"encoding, data",
Expand All @@ -3320,7 +3321,7 @@ def test_filepath_or_buffer_arg(
):
getattr(df, method)(buf=filepath_or_buffer, encoding=encoding)
elif encoding == "foo":
expected_warning = FutureWarning if method == "to_latex" else None
expected_warning = FutureWarning if method in ["to_latex", "to_html"] else None
with tm.assert_produces_warning(expected_warning):
with pytest.raises(LookupError, match="unknown encoding"):
getattr(df, method)(buf=filepath_or_buffer, encoding=encoding)
Expand Down
0