diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 83beec5607986..1542350bea85a 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -54,7 +54,7 @@ Other API changes Deprecations ~~~~~~~~~~~~ -- +- The ``notebook`` argument of :meth:`DataFrame.to_html` is deprecated (:issue:`23820`). - .. _whatsnew_1000.prior_deprecations: diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3d1a39a86c784..3fa90f042999d 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -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, @@ -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 `` tag. Default ``pd.options.display.html.border``. diff --git a/pandas/tests/io/formats/test_to_html.py b/pandas/tests/io/formats/test_to_html.py index 448e869df950d..9699c34a21c63 100644 --- a/pandas/tests/io/formats/test_to_html.py +++ b/pandas/tests/io/formats/test_to_html.py @@ -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 @@ -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