Skip to content

Commit cbd0354

Browse files
rdk1024jreback
authored andcommitted
DEPR: deprecate html.border option (#16970)
1 parent 745c012 commit cbd0354

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

doc/source/options.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ display.width 80 Width of the display in charact
400400
display.html.table_schema False Whether to publish a Table Schema
401401
representation for frontends that
402402
support it.
403-
html.border 1 A ``border=value`` attribute is
403+
display.html.border 1 A ``border=value`` attribute is
404404
inserted in the ``<table>`` tag
405405
for the DataFrame HTML repr.
406406
io.excel.xls.writer xlwt The default Excel writer engine for

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Deprecations
116116
~~~~~~~~~~~~
117117
- :func:`read_excel()` has deprecated ``sheetname`` in favor of ``sheet_name`` for consistency with ``.to_excel()`` (:issue:`10559`).
118118

119+
- ``pd.options.html.border`` has been deprecated in favor of ``pd.options.display.html.border`` (:issue:`15793`).
119120

120121
.. _whatsnew_0210.prior_deprecations:
121122

pandas/core/config_init.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,17 @@ def use_numexpr_cb(key):
202202
(default: False)
203203
"""
204204

205+
pc_html_border_doc = """
206+
: int
207+
A ``border=value`` attribute is inserted in the ``<table>`` tag
208+
for the DataFrame HTML repr.
209+
"""
210+
211+
pc_html_border_deprecation_warning = """\
212+
html.border has been deprecated, use display.html.border instead
213+
(currently both are identical)
214+
"""
215+
205216
pc_line_width_deprecation_warning = """\
206217
line_width has been deprecated, use display.width instead (currently both are
207218
identical)
@@ -369,6 +380,8 @@ def table_schema_cb(key):
369380
validator=is_bool)
370381
cf.register_option('html.table_schema', False, pc_table_schema_doc,
371382
validator=is_bool, cb=table_schema_cb)
383+
cf.register_option('html.border', 1, pc_html_border_doc,
384+
validator=is_int)
372385

373386

374387
cf.deprecate_option('display.line_width',
@@ -378,16 +391,13 @@ def table_schema_cb(key):
378391
cf.deprecate_option('display.height', msg=pc_height_deprecation_warning,
379392
rkey='display.max_rows')
380393

381-
pc_html_border_doc = """
382-
: int
383-
A ``border=value`` attribute is inserted in the ``<table>`` tag
384-
for the DataFrame HTML repr.
385-
"""
386-
387394
with cf.config_prefix('html'):
388395
cf.register_option('border', 1, pc_html_border_doc,
389396
validator=is_int)
390397

398+
cf.deprecate_option('html.border', msg=pc_html_border_deprecation_warning,
399+
rkey='display.html.border')
400+
391401

392402
tc_sim_interactive_doc = """
393403
: boolean

pandas/io/formats/format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ def __init__(self, formatter, classes=None, max_rows=None, max_cols=None,
10641064
self.max_cols < len(self.fmt.columns))
10651065
self.notebook = notebook
10661066
if border is None:
1067-
border = get_option('html.border')
1067+
border = get_option('display.html.border')
10681068
self.border = border
10691069

10701070
def write(self, s, indent=0):

pandas/tests/io/formats/test_to_html.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ def test_to_html_border(self):
14011401

14021402
def test_to_html_border_option(self):
14031403
df = DataFrame({'A': [1, 2]})
1404-
with pd.option_context('html.border', 0):
1404+
with pd.option_context('display.html.border', 0):
14051405
result = df.to_html()
14061406
assert 'border="0"' in result
14071407
assert 'border="0"' in df._repr_html_()
@@ -1411,6 +1411,11 @@ def test_to_html_border_zero(self):
14111411
result = df.to_html(border=0)
14121412
assert 'border="0"' in result
14131413

1414+
def test_display_option_warning(self):
1415+
with tm.assert_produces_warning(DeprecationWarning,
1416+
check_stacklevel=False):
1417+
pd.options.html.border
1418+
14141419
def test_to_html(self):
14151420
# big mixed
14161421
biggie = DataFrame({'A': np.random.randn(200),

0 commit comments

Comments
 (0)