def _translate(self):
table_styles = self.table_styles or []<EOL>caption = self.caption<EOL>ctx = self.ctx<EOL>precision = self.precision<EOL>hidden_index = self.hidden_index<EOL>hidden_columns = self.hidden_columns<EOL>uuid = self.uuid or str(uuid1()).replace("<STR_LIT:->", "<STR_LIT:_>")<EOL>ROW_HEADING_CLASS = "<STR_LIT>"<EOL>COL_HEADING_CLASS = "<STR_LIT>"<EOL>INDEX_NAME_CLASS = "<STR_LIT>"<EOL>DATA_CLASS = "<STR_LIT:data>"<EOL>BLANK_CLASS = "<STR_LIT:blank>"<EOL>BLANK_VALUE = "<STR_LIT>"<EOL>def format_attr(pair):<EOL><INDENT>return "<STR_LIT>".format(**pair)<EOL><DEDENT>idx_lengths = _get_level_lengths(self.index)<EOL>col_lengths = _get_level_lengths(self.columns, hidden_columns)<EOL>cell_context = dict()<EOL>n_rlvls = self.data.index.nlevels<EOL>n_clvls = self.data.columns.nlevels<EOL>rlabels = self.data.index.tolist()<EOL>clabels = self.data.columns.tolist()<EOL>if n_rlvls == <NUM_LIT:1>:<EOL><INDENT>rlabels = [[x] for x in rlabels]<EOL><DEDENT>if n_clvls == <NUM_LIT:1>:<EOL><INDENT>clabels = [[x] for x in clabels]<EOL><DEDENT>clabels = list(zip(*clabels))<EOL>cellstyle = []<EOL>head = []<EOL>for r in range(n_clvls):<EOL><INDENT>row_es = [{"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT:value>": BLANK_VALUE,<EOL>"<STR_LIT>": BLANK_VALUE,<EOL>"<STR_LIT>": not hidden_index,<EOL>"<STR_LIT:class>": "<STR_LIT:U+0020>".join([BLANK_CLASS])}] * (n_rlvls - <NUM_LIT:1>)<EOL>name = self.data.columns.names[r]<EOL>cs = [BLANK_CLASS if name is None else INDEX_NAME_CLASS,<EOL>"<STR_LIT>".format(lvl=r)]<EOL>name = BLANK_VALUE if name is None else name<EOL>row_es.append({"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT:value>": name,<EOL>"<STR_LIT>": name,<EOL>"<STR_LIT:class>": "<STR_LIT:U+0020>".join(cs),<EOL>"<STR_LIT>": not hidden_index})<EOL>if clabels:<EOL><INDENT>for c, value in enumerate(clabels[r]):<EOL><INDENT>cs = [COL_HEADING_CLASS, "<STR_LIT>".format(lvl=r),<EOL>"<STR_LIT>".format(col=c)]<EOL>cs.extend(cell_context.get(<EOL>"<STR_LIT>", {}).get(r, {}).get(c, []))<EOL>es = {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT:value>": value,<EOL>"<STR_LIT>": value,<EOL>"<STR_LIT:class>": "<STR_LIT:U+0020>".join(cs),<EOL>"<STR_LIT>": _is_visible(c, r, col_lengths),<EOL>}<EOL>colspan = col_lengths.get((r, c), <NUM_LIT:0>)<EOL>if colspan > <NUM_LIT:1>:<EOL><INDENT>es["<STR_LIT>"] = [<EOL>format_attr({"<STR_LIT:key>": "<STR_LIT>", "<STR_LIT:value>": colspan})<EOL>]<EOL><DEDENT>row_es.append(es)<EOL><DEDENT>head.append(row_es)<EOL><DEDENT><DEDENT>if (self.data.index.names and<EOL>com._any_not_none(*self.data.index.names) and<EOL>not hidden_index):<EOL><INDENT>index_header_row = []<EOL>for c, name in enumerate(self.data.index.names):<EOL><INDENT>cs = [INDEX_NAME_CLASS,<EOL>"<STR_LIT>".format(lvl=c)]<EOL>name = '<STR_LIT>' if name is None else name<EOL>index_header_row.append({"<STR_LIT:type>": "<STR_LIT>", "<STR_LIT:value>": name,<EOL>"<STR_LIT:class>": "<STR_LIT:U+0020>".join(cs)})<EOL><DEDENT>index_header_row.extend(<EOL>[{"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT:value>": BLANK_VALUE,<EOL>"<STR_LIT:class>": "<STR_LIT:U+0020>".join([BLANK_CLASS])<EOL>}] * (len(clabels[<NUM_LIT:0>]) - len(hidden_columns)))<EOL>head.append(index_header_row)<EOL><DEDENT>body = []<EOL>for r, idx in enumerate(self.data.index):<EOL><INDENT>row_es = []<EOL>for c, value in enumerate(rlabels[r]):<EOL><INDENT>rid = [ROW_HEADING_CLASS, "<STR_LIT>".format(lvl=c),<EOL>"<STR_LIT>".format(row=r)]<EOL>es = {<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": (_is_visible(r, c, idx_lengths) and<EOL>not hidden_index),<EOL>"<STR_LIT:value>": value,<EOL>"<STR_LIT>": value,<EOL>"<STR_LIT:id>": "<STR_LIT:_>".join(rid[<NUM_LIT:1>:]),<EOL>"<STR_LIT:class>": "<STR_LIT:U+0020>".join(rid)<EOL>}<EOL>rowspan = idx_lengths.get((c, r), <NUM_LIT:0>)<EOL>if rowspan > <NUM_LIT:1>:<EOL><INDENT>es["<STR_LIT>"] = [<EOL>format_attr({"<STR_LIT:key>": "<STR_LIT>", "<STR_LIT:value>": rowspan})<EOL>]<EOL><DEDENT>row_es.append(es)<EOL><DEDENT>for c, col in enumerate(self.data.columns):<EOL><INDENT>cs = [DATA_CLASS, "<STR_LIT>".format(row=r),<EOL>"<STR_LIT>".format(col=c)]<EOL>cs.extend(cell_context.get("<STR_LIT:data>", {}).get(r, {}).get(c, []))<EOL>formatter = self._display_funcs[(r, c)]<EOL>value = self.data.iloc[r, c]<EOL>row_dict = {"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT:value>": value,<EOL>"<STR_LIT:class>": "<STR_LIT:U+0020>".join(cs),<EOL>"<STR_LIT>": formatter(value),<EOL>"<STR_LIT>": (c not in hidden_columns)}<EOL>if (self.cell_ids or<EOL>not(len(ctx[r, c]) == <NUM_LIT:1> and ctx[r, c][<NUM_LIT:0>] == '<STR_LIT>')):<EOL><INDENT>row_dict["<STR_LIT:id>"] = "<STR_LIT:_>".join(cs[<NUM_LIT:1>:])<EOL><DEDENT>row_es.append(row_dict)<EOL>props = []<EOL>for x in ctx[r, c]:<EOL><INDENT>if x.count("<STR_LIT::>"):<EOL><INDENT>props.append(x.split("<STR_LIT::>"))<EOL><DEDENT>else:<EOL><INDENT>props.append(['<STR_LIT>', '<STR_LIT>'])<EOL><DEDENT><DEDENT>cellstyle.append({'<STR_LIT>': props,<EOL>'<STR_LIT>': "<STR_LIT>"<EOL>.format(row=r, col=c)})<EOL><DEDENT>body.append(row_es)<EOL><DEDENT>table_attr = self.table_attributes<EOL>use_mathjax = get_option("<STR_LIT>")<EOL>if not use_mathjax:<EOL><INDENT>table_attr = table_attr or '<STR_LIT>'<EOL>if '<STR_LIT>' in table_attr:<EOL><INDENT>table_attr = table_attr.replace('<STR_LIT>',<EOL>'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>table_attr += '<STR_LIT>'<EOL><DEDENT><DEDENT>return dict(head=head, cellstyle=cellstyle, body=body, uuid=uuid,<EOL>precision=precision, table_styles=table_styles,<EOL>caption=caption, table_attributes=table_attr)<EOL>
Convert the DataFrame in `self.data` and the attrs from `_build_styles`
into a dictionary of {head, body, uuid, cellstyle}.