From 1105551377c7fbc890fa4c00d5a5a6f81d4e7539 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 17 May 2016 20:45:33 -0500 Subject: [PATCH] REF/API: Styler->HTMLStyler --- doc/source/api.rst | 38 ++++++++-------- pandas/core/frame.py | 4 +- pandas/formats/style.py | 72 +++++++++++++++--------------- pandas/tests/formats/test_style.py | 26 +++++------ 4 files changed, 70 insertions(+), 70 deletions(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index 9557867c252ed..05160d45a84d2 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -1808,7 +1808,7 @@ Style ----- .. currentmodule:: pandas.formats.style -``Styler`` objects are returned by :attr:`pandas.DataFrame.style`. +``HTMLStyler`` objects are returned by :attr:`pandas.DataFrame.style`. Constructor @@ -1816,22 +1816,22 @@ Constructor .. autosummary:: :toctree: generated/ - Styler + HTMLStyler Style Application ~~~~~~~~~~~~~~~~~ .. autosummary:: :toctree: generated/ - Styler.apply - Styler.applymap - Styler.format - Styler.set_precision - Styler.set_table_styles - Styler.set_caption - Styler.set_properties - Styler.set_uuid - Styler.clear + HTMLStyler.apply + HTMLStyler.applymap + HTMLStyler.format + HTMLStyler.set_precision + HTMLStyler.set_table_styles + HTMLStyler.set_caption + HTMLStyler.set_properties + HTMLStyler.set_uuid + HTMLStyler.clear Builtin Styles ~~~~~~~~~~~~~~ @@ -1839,11 +1839,11 @@ Builtin Styles .. autosummary:: :toctree: generated/ - Styler.highlight_max - Styler.highlight_min - Styler.highlight_null - Styler.background_gradient - Styler.bar + HTMLStyler.highlight_max + HTMLStyler.highlight_min + HTMLStyler.highlight_null + HTMLStyler.background_gradient + HTMLStyler.bar Style Export and Import ~~~~~~~~~~~~~~~~~~~~~~~ @@ -1851,9 +1851,9 @@ Style Export and Import .. autosummary:: :toctree: generated/ - Styler.render - Styler.export - Styler.use + HTMLStyler.render + HTMLStyler.export + HTMLStyler.use .. currentmodule:: pandas diff --git a/pandas/core/frame.py b/pandas/core/frame.py index b3d01d12c9336..fa127f653b408 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -589,8 +589,8 @@ def style(self): -------- pandas.formats.style.Styler """ - from pandas.formats.style import Styler - return Styler(self) + from pandas.formats.style import HTMLStyler + return HTMLStyler(self) def iteritems(self): """ diff --git a/pandas/formats/style.py b/pandas/formats/style.py index f66ac7485c76e..cf3f4bd6d6b14 100644 --- a/pandas/formats/style.py +++ b/pandas/formats/style.py @@ -12,7 +12,7 @@ try: from jinja2 import Template except ImportError: - msg = "pandas.Styler requires jinja2. "\ + msg = "pandas.HTMLStyler requires jinja2. "\ "Please install with `conda install Jinja2`\n"\ "or `pip install Jinja2`" raise ImportError(msg) @@ -39,7 +39,7 @@ def _mpl(func): raise ImportError(no_mpl_message.format(func.__name__)) -class Styler(object): +class HTMLStyler(object): """ Helps style a DataFrame or Series according to the data with HTML and CSS. @@ -70,12 +70,12 @@ class Styler(object): Notes ----- Most styling will be done by passing style functions into - ``Styler.apply`` or ``Styler.applymap``. Style functions should + ``HTMLStyler.apply`` or ``Styler.applymap``. Style functions should return values with strings containing CSS ``'attr: value'`` that will be applied to the indicated cells. - If using in the Jupyter notebook, Styler has defined a ``_repr_html_`` - to automatically render itself. Otherwise call Styler.render to get + If using in the Jupyter notebook, HTMLStyler has defined a ``_repr_html_`` + to automatically render itself. Otherwise call HTMLStyler.render to get the genterated HTML. See Also @@ -286,7 +286,7 @@ def format(self, formatter, subset=None): Returns ------- - self : Styler + self : HTMLStyler Notes ----- @@ -349,9 +349,9 @@ def render(self): Notes ----- - ``Styler`` objects have defined the ``_repr_html_`` method + ``HTMLStyler`` objects have defined the ``_repr_html_`` method which automatically calls ``self.render()`` when it's the - last item in a Notebook cell. When calling ``Styler.render()`` + last item in a Notebook cell. When calling ``HTMLStyler.render()`` directly, wrap the result in ``IPython.display.HTML`` to view the rendered HTML in the notebook. """ @@ -367,7 +367,7 @@ def render(self): def _update_ctx(self, attrs): """ - update the state of the Styler. Collects a mapping + update the state of the HTMLStyler. Collects a mapping of {index_label: [': ']} attrs: Series or DataFrame @@ -383,9 +383,9 @@ def _update_ctx(self, attrs): self.ctx[(i, j)].append(pair) def _copy(self, deepcopy=False): - styler = Styler(self.data, precision=self.precision, - caption=self.caption, uuid=self.uuid, - table_styles=self.table_styles) + styler = HTMLStyler(self.data, precision=self.precision, + caption=self.caption, uuid=self.uuid, + table_styles=self.table_styles) if deepcopy: styler.ctx = copy.deepcopy(self.ctx) styler._todo = copy.deepcopy(self._todo) @@ -457,7 +457,7 @@ def apply(self, func, axis=0, subset=None, **kwargs): Returns ------- - self : Styler + self : HTMLStyler Notes ----- @@ -496,7 +496,7 @@ def applymap(self, func, subset=None, **kwargs): Returns ------- - self : Styler + self : HTMLStyler """ self._todo.append((lambda instance: getattr(instance, '_applymap'), @@ -515,7 +515,7 @@ def set_precision(self, precision): Returns ------- - self : Styler + self : HTMLStyler """ self.precision = precision return self @@ -534,15 +534,15 @@ def set_table_attributes(self, attributes): Returns ------- - self : Styler + self : HTMLStyler """ self.table_attributes = attributes return self def export(self): """ - Export the styles to applied to the current Styler. - Can be applied to a second style with ``Styler.use``. + Export the styles to applied to the current HTMLStyler. + Can be applied to a second style with ``HTMLStyler.use``. .. versionadded:: 0.17.1 @@ -552,14 +552,14 @@ def export(self): See Also -------- - Styler.use + HTMLStyler.use """ return self._todo def use(self, styles): """ - Set the styles on the current Styler, possibly using styles - from ``Styler.export``. + Set the styles on the current HTMLStyler, possibly using styles + from ``HTMLStyler.export``. .. versionadded:: 0.17.1 @@ -570,18 +570,18 @@ def use(self, styles): Returns ------- - self : Styler + self : HTMLStyler See Also -------- - Styler.export + HTMLStyler.export """ self._todo.extend(styles) return self def set_uuid(self, uuid): """ - Set the uuid for a Styler. + Set the uuid for a HTMLStyler. .. versionadded:: 0.17.1 @@ -591,14 +591,14 @@ def set_uuid(self, uuid): Returns ------- - self : Styler + self : HTMLStyler """ self.uuid = uuid return self def set_caption(self, caption): """ - Se the caption on a Styler + Se the caption on a HTMLStyler .. versionadded:: 0.17.1 @@ -608,14 +608,14 @@ def set_caption(self, caption): Returns ------- - self : Styler + self : HTMLStyler """ self.caption = caption return self def set_table_styles(self, table_styles): """ - Set the table styles on a Styler. These are placed in a + Set the table styles on a HTMLStyler. These are placed in a ``