Skip to content

CLN: reorganise/group variables for readability #40368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,6 @@ def _translate(self):
Convert the DataFrame in `self.data` and the attrs from `_build_styles`
into a dictionary of {head, body, uuid, cellstyle}.
"""
table_styles = self.table_styles or []
caption = self.caption
ctx = self.ctx
hidden_index = self.hidden_index
hidden_columns = self.hidden_columns
uuid = self.uuid
ROW_HEADING_CLASS = "row_heading"
COL_HEADING_CLASS = "col_heading"
INDEX_NAME_CLASS = "index_name"
Expand All @@ -364,12 +358,22 @@ def _translate(self):
BLANK_CLASS = "blank"
BLANK_VALUE = ""

# mapping variables
ctx = self.ctx # td css styles from apply() and applymap()
cell_context = self.cell_context # td css classes from set_td_classes()
cellstyle_map: DefaultDict[Tuple[CSSPair, ...], List[str]] = defaultdict(list)

# copied attributes
table_styles = self.table_styles or []
caption = self.caption
hidden_index = self.hidden_index
hidden_columns = self.hidden_columns
uuid = self.uuid

# for sparsifying a MultiIndex
idx_lengths = _get_level_lengths(self.index)
col_lengths = _get_level_lengths(self.columns, hidden_columns)

cell_context = self.cell_context

n_rlvls = self.data.index.nlevels
n_clvls = self.data.columns.nlevels
rlabels = self.data.index.tolist()
Expand All @@ -381,10 +385,7 @@ def _translate(self):
clabels = [[x] for x in clabels]
clabels = list(zip(*clabels))

cellstyle_map: DefaultDict[Tuple[CSSPair, ...], List[str]] = defaultdict(list)

head = []

for r in range(n_clvls):
# Blank for Index columns...
row_es = [
Expand Down