Skip to content

DEPR: deprecate notebook argument in DataFrame.to_html() #26815

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
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
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Other API changes
Deprecations
~~~~~~~~~~~~

-
- The ``notebook`` argument of :meth:`DataFrame.to_html` is deprecated (:issue:`23820`).
-

.. _whatsnew_1000.prior_deprecations:
Expand Down
4 changes: 4 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,7 @@ def to_parquet(
" Ability to use str",
)
@Substitution(shared_params=fmt.common_docstring, returns=fmt.return_docstring)
@deprecate_kwarg(old_arg_name="notebook", new_arg_name=None)
def to_html(
self,
buf=None,
Expand Down Expand Up @@ -2245,6 +2246,9 @@ def to_html(
Convert the characters <, >, and & to HTML-safe sequences.
notebook : {True, False}, default False
Whether the generated HTML is for IPython Notebook.

.. deprecated:: 1.0.0

border : int
A ``border=border`` attribute is included in the opening
`<table>` tag. Default ``pd.options.display.html.border``.
Expand Down
10 changes: 6 additions & 4 deletions pandas/tests/io/formats/test_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ def test_to_html_truncation_index_false_max_cols(
@pytest.mark.parametrize("notebook", [True, False])
def test_to_html_notebook_has_style(notebook):
df = DataFrame({"A": [1, 2, 3]})
result = df.to_html(notebook=notebook)
with tm.assert_produces_warning(FutureWarning):
result = df.to_html(notebook=notebook)

if notebook:
assert "tbody tr th:only-of-type" in result
Expand Down Expand Up @@ -694,9 +695,10 @@ def test_to_html_invalid_classes_type(classes):
def test_to_html_round_column_headers():
# GH 17280
df = DataFrame([1], columns=[0.55555])
with pd.option_context("display.precision", 3):
html = df.to_html(notebook=False)
notebook = df.to_html(notebook=True)
with tm.assert_produces_warning(FutureWarning):
with pd.option_context("display.precision", 3):
html = df.to_html(notebook=False)
notebook = df.to_html(notebook=True)
assert "0.55555" in html
assert "0.556" in notebook

Expand Down