Skip to content

Commit

Permalink
DEPR: deprecate html.border option (pandas-dev#16970)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdk1024 authored and alanbato committed Nov 10, 2017
1 parent c0e5b4f commit dd60dc6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/source/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ display.width 80 Width of the display in charact
display.html.table_schema False Whether to publish a Table Schema
representation for frontends that
support it.
html.border 1 A ``border=value`` attribute is
display.html.border 1 A ``border=value`` attribute is
inserted in the ``<table>`` tag
for the DataFrame HTML repr.
io.excel.xls.writer xlwt The default Excel writer engine for
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Deprecations
~~~~~~~~~~~~
- :func:`read_excel()` has deprecated ``sheetname`` in favor of ``sheet_name`` for consistency with ``.to_excel()`` (:issue:`10559`).

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

.. _whatsnew_0210.prior_deprecations:

Expand Down
22 changes: 16 additions & 6 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ def use_numexpr_cb(key):
(default: False)
"""

pc_html_border_doc = """
: int
A ``border=value`` attribute is inserted in the ``<table>`` tag
for the DataFrame HTML repr.
"""

pc_html_border_deprecation_warning = """\
html.border has been deprecated, use display.html.border instead
(currently both are identical)
"""

pc_line_width_deprecation_warning = """\
line_width has been deprecated, use display.width instead (currently both are
identical)
Expand Down Expand Up @@ -369,6 +380,8 @@ def table_schema_cb(key):
validator=is_bool)
cf.register_option('html.table_schema', False, pc_table_schema_doc,
validator=is_bool, cb=table_schema_cb)
cf.register_option('html.border', 1, pc_html_border_doc,
validator=is_int)


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

pc_html_border_doc = """
: int
A ``border=value`` attribute is inserted in the ``<table>`` tag
for the DataFrame HTML repr.
"""

with cf.config_prefix('html'):
cf.register_option('border', 1, pc_html_border_doc,
validator=is_int)

cf.deprecate_option('html.border', msg=pc_html_border_deprecation_warning,
rkey='display.html.border')


tc_sim_interactive_doc = """
: boolean
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ def __init__(self, formatter, classes=None, max_rows=None, max_cols=None,
self.max_cols < len(self.fmt.columns))
self.notebook = notebook
if border is None:
border = get_option('html.border')
border = get_option('display.html.border')
self.border = border

def write(self, s, indent=0):
Expand Down
7 changes: 6 additions & 1 deletion pandas/tests/io/formats/test_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ def test_to_html_border(self):

def test_to_html_border_option(self):
df = DataFrame({'A': [1, 2]})
with pd.option_context('html.border', 0):
with pd.option_context('display.html.border', 0):
result = df.to_html()
assert 'border="0"' in result
assert 'border="0"' in df._repr_html_()
Expand All @@ -1411,6 +1411,11 @@ def test_to_html_border_zero(self):
result = df.to_html(border=0)
assert 'border="0"' in result

def test_display_option_warning(self):
with tm.assert_produces_warning(DeprecationWarning,
check_stacklevel=False):
pd.options.html.border

def test_to_html(self):
# big mixed
biggie = DataFrame({'A': np.random.randn(200),
Expand Down

0 comments on commit dd60dc6

Please sign in to comment.