-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Changes from 22 commits
2fa2246
89225de
1119a27
93d9288
2e653fe
8e10574
e4fa4ef
e20c5d9
e6fc67e
310bdc2
3524116
43acc91
f41a438
ad8cf24
0d5b4b3
bd5e91c
7e3c3df
7de29d1
f2a944a
5f4d55c
6a4523e
9e66a72
505953d
d859877
02d913c
7d5ab6c
a9e4ac4
ee97624
10a34cb
272670a
3af20b6
6962393
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,6 +275,7 @@ column names and dtypes. That's because Dask hasn't actually read the data yet. | |
Rather than executing immediately, doing operations build up a **task graph**. | ||
|
||
.. ipython:: python | ||
:okwarning: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems unrelated? (if so, can you remove it again) |
||
|
||
ddf | ||
ddf["name"] | ||
|
@@ -333,6 +334,7 @@ known automatically. In this case, since we created the parquet files manually, | |
we need to supply the divisions manually. | ||
|
||
.. ipython:: python | ||
:okwarning: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
|
||
N = 12 | ||
starts = [f"20{i:>02d}-01-01" for i in range(N)] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2898,8 +2898,18 @@ def to_html( | |
%(returns)s | ||
See Also | ||
-------- | ||
Styler.to_html : Render a DataFrame to HTML with conditional formatting. | ||
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 " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we intend to keep Would it be an alternative to specifically check for keywords we know will change in the signature, and only warn for those? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something else i considered was just implementing a There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
|
||
import pandas.io.formats.format as fmt | ||
|
||
pytestmark = pytest.mark.filterwarnings("ignore::FutureWarning") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this actually filtering out all warnings? that's the thing, how do we know this is not warning when it shouldn't be? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes that filters the generic warnings but the tests added, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make the filter a bit more specific? (eg match the beginning of the message) Just to ensure we only ignore this warning, and not accidentally suppress warnings we should see. |
||
|
||
lorem_ipsum = ( | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod " | ||
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim " | ||
|
@@ -872,3 +874,16 @@ def test_to_html_float_format_object_col(datapath): | |
result = df.to_html(float_format=lambda x: f"{x:,.0f}") | ||
expected = expected_html(datapath, "gh40024_expected_output") | ||
assert result == expected | ||
|
||
|
||
def test_future_warning(): | ||
df = DataFrame([[1]]) | ||
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 " | ||
"to use `DataFrame.style.to_html` which also contains additional " | ||
"functionality." | ||
) | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
df.to_html() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the sphinx cross-reference syntax instead of the path-based link? (
:meth:`Styler.to_html() <pandas.io.formats.style.Styler.to_html>`
for the long format and controlling which text is changes, but I think in this case you can also use:meth:`.Styler.to_html`
to get exactly the same)(and the same for similar cases below)