Skip to content

Commit 709ab50

Browse files
committed
removed aruments from init
1 parent 08cf8db commit 709ab50

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

doc/source/whatsnew/v0.21.0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ Other Enhancements
163163
- :func:`Categorical.rename_categories` now accepts a dict-like argument as `new_categories` and only updates the categories found in that dict. (:issue:`17336`)
164164
- :func:`read_excel` raises ``ImportError`` with a better message if ``xlrd`` is not installed. (:issue:`17613`)
165165
- :meth:`DataFrame.assign` will preserve the original order of ``**kwargs`` for Python 3.6+ users instead of sorting the column names
166-
- :class:`pandas.io.formats.style.Styler` now has ``index`` parameter and corresponding method ``hide_index()`` to determine whether the index will be rendered in ouptut (:issue:`14194`)
167-
- :class:`pandas.io.formats.style.Styler` now has ``hidden_cols`` parameter and corresponding method ``hide_columns()`` to determine whether columns will be hidden in output (:issue:`14194`)
166+
- :class:`pandas.io.formats.style.Styler` now has method ``hide_index()`` to determine whether the index will be rendered in ouptut (:issue:`14194`)
167+
- :class:`pandas.io.formats.style.Styler` now has method ``hide_columns()`` to determine whether columns will be hidden in output (:issue:`14194`)
168168

169169

170170

pandas/io/formats/style.py

+11-25
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ class Styler(object):
7070
a unique identifier to avoid CSS collisons; generated automatically
7171
caption: str, default None
7272
caption to attach to the table
73-
index: bool, default True
74-
determines if the index is rendered in the html output
75-
76-
.. versionadded:: 0.21.0
77-
78-
hidden_columns: IndexSlice, default None
79-
hides a subset of columns from rendering
80-
81-
.. versionadded:: 0.21.0
8273
8374
Attributes
8475
----------
@@ -127,8 +118,7 @@ class Styler(object):
127118
template = env.get_template("html.tpl")
128119

129120
def __init__(self, data, precision=None, table_styles=None, uuid=None,
130-
caption=None, table_attributes=None, index=True,
131-
hidden_columns=None):
121+
caption=None, table_attributes=None):
132122
self.ctx = defaultdict(list)
133123
self._todo = []
134124

@@ -150,10 +140,8 @@ def __init__(self, data, precision=None, table_styles=None, uuid=None,
150140
precision = get_option('display.precision')
151141
self.precision = precision
152142
self.table_attributes = table_attributes
153-
self.index_visible = index
154-
if hidden_columns is None:
155-
hidden_columns = []
156-
self.hidden_columns = hidden_columns
143+
self.hidden_index = False
144+
self.hidden_columns = []
157145

158146
# display_funcs maps (row, col) -> formatting function
159147

@@ -202,7 +190,7 @@ def _translate(self):
202190
caption = self.caption
203191
ctx = self.ctx
204192
precision = self.precision
205-
index_visible = self.index_visible
193+
hidden_index = self.hidden_index
206194
hidden_columns = self.hidden_columns
207195
uuid = self.uuid or str(uuid1()).replace("-", "_")
208196
ROW_HEADING_CLASS = "row_heading"
@@ -241,7 +229,7 @@ def format_attr(pair):
241229
row_es = [{"type": "th",
242230
"value": BLANK_VALUE,
243231
"display_value": BLANK_VALUE,
244-
"is_visible": index_visible,
232+
"is_visible": not hidden_index,
245233
"class": " ".join([BLANK_CLASS])}] * (n_rlvls - 1)
246234

247235
# ... except maybe the last for columns.names
@@ -253,7 +241,7 @@ def format_attr(pair):
253241
"value": name,
254242
"display_value": name,
255243
"class": " ".join(cs),
256-
"is_visible": index_visible})
244+
"is_visible": not hidden_index})
257245

258246
if clabels:
259247
for c, value in enumerate(clabels[r]):
@@ -276,7 +264,7 @@ def format_attr(pair):
276264
row_es.append(es)
277265
head.append(row_es)
278266

279-
if (self.data.index.names and index_visible and not
267+
if (self.data.index.names and not hidden_index and not
280268
all(x is None for x in self.data.index.names)):
281269
index_header_row = []
282270

@@ -303,8 +291,8 @@ def format_attr(pair):
303291
"row{row}".format(row=r)]
304292
es = {
305293
"type": "th",
306-
"is_visible": (_is_visible(r, c, idx_lengths) &
307-
index_visible),
294+
"is_visible": (_is_visible(r, c, idx_lengths) and
295+
not hidden_index),
308296
"value": value,
309297
"display_value": value,
310298
"id": "_".join(rid[1:]),
@@ -486,9 +474,7 @@ def _update_ctx(self, attrs):
486474
def _copy(self, deepcopy=False):
487475
styler = Styler(self.data, precision=self.precision,
488476
caption=self.caption, uuid=self.uuid,
489-
table_styles=self.table_styles,
490-
index=self.index_visible,
491-
hidden_columns=self.hidden_columns)
477+
table_styles=self.table_styles)
492478
if deepcopy:
493479
styler.ctx = copy.deepcopy(self.ctx)
494480
styler._todo = copy.deepcopy(self._todo)
@@ -843,7 +829,7 @@ def hide_index(self):
843829
-------
844830
self : Styler
845831
"""
846-
self.index_visible = False
832+
self.hidden_index = True
847833
return self
848834

849835
def hide_columns(self, subset):

0 commit comments

Comments
 (0)