class_docstr: An extension to ``Styler`` that allows for and manipulates tooltips on hover
  of ``<td>`` cells in the HTML result.
  
  Parameters
  ----------
  css_name: str, default "pd-t"
      Name of the CSS class that controls visualisation of tooltips.
  css_props: list-like, default; see Notes
      List of (attr, value) tuples defining properties of the CSS class.
  tooltips: DataFrame, default empty
      DataFrame of strings aligned with underlying Styler data for tooltip
      display.
  
  Notes
  -----
  The default properties for the tooltip CSS class are:
  
      - visibility: hidden
      - position: absolute
      - z-index: 1
      - background-color: black
      - color: white
      - transform: translate(-20px, -20px)
  
  Hidden visibility is a key prerequisite to the hover functionality, and should
  always be included in any manual properties specification.
class_docstr_tok: ["An","extension","to","``","Styler","``","that","allows","for","and","manipulates","tooltips","on","hover","of","``","<","td",">","``","cells","in","the","HTML","result",".","Parameters","--","--","--","--","--","css_name",":","str",",","default","``","pd-t","''","Name","of","the","CSS","class","that","controls","visualisation","of","tooltips",".","css_props",":","list-like",",","default",";","see","Notes","List","of","(","attr",",","value",")","tuples","defining","properties","of","the","CSS","class",".","tooltips",":","DataFrame",",","default","empty","DataFrame","of","strings","aligned","with","underlying","Styler","data","for","tooltip","display",".","Notes","--","--","-","The","default","properties","for","the","tooltip","CSS","class","are",":","-","visibility",":","hidden","-","position",":","absolute","-","z-index",":","1","-","background-color",":","black","-","color",":","white","-","transform",":","translate","(","-20px",",","-20px",")","Hidden","visibility","is","a","key","prerequisite","to","the","hover","functionality",",","and","should","always","be","included","in","any","manual","properties","specification","."]
docstr: Mutate the render dictionary to allow for tooltips:
  
  - Add ``<span>`` HTML element to each data cells ``display_value``. Ignores
    headers.
  - Add table level CSS styles to control pseudo classes.
  
  Parameters
  ----------
  styler_data : DataFrame
      Underlying ``Styler`` DataFrame used for reindexing.
  uuid : str
      The underlying ``Styler`` uuid for CSS id.
  d : dict
      The dictionary prior to final render
  
  Returns
  -------
  render_dict : Dict
docstr_tok: ["Mutate","the","render","dictionary","to","allow","for","tooltips",":","-","Add","``","<","span",">","``","HTML","element","to","each","data","cells","``","display_value","``",".","Ignores","headers",".","-","Add","table","level","CSS","styles","to","control","pseudo","classes",".","Parameters","--","--","--","--","--","styler_data",":","DataFrame","Underlying","``","Styler","``","DataFrame","used","for","reindexing",".","uuid",":","str","The","underlying","``","Styler","``","uuid","for","CSS","id",".","d",":","dict","The","dictionary","prior","to","final","render","Returns","--","--","--","-","render_dict",":","Dict"]
code: def _translate(self, styler: StylerRenderer, d: dict):
      """
      Mutate the render dictionary to allow for tooltips:
  
      - Add ``<span>`` HTML element to each data cells ``display_value``. Ignores
        headers.
      - Add table level CSS styles to control pseudo classes.
  
      Parameters
      ----------
      styler_data : DataFrame
          Underlying ``Styler`` DataFrame used for reindexing.
      uuid : str
          The underlying ``Styler`` uuid for CSS id.
      d : dict
          The dictionary prior to final render
  
      Returns
      -------
      render_dict : Dict
      """
      self.tt_data = self.tt_data.reindex_like(styler.data)
      if self.tt_data.empty:
          return d
  
      name = self.class_name
      mask = (self.tt_data.isna()) | (
          self.tt_data.eq("")
      )  # empty string = no ttip
      self.table_styles = [
          style
          for sublist in [
              self._pseudo_css(
                  styler.uuid, name, i, j, str(self.tt_data.iloc[i, j])
              )
              for i in range(len(self.tt_data.index))
              for j in range(len(self.tt_data.columns))
              if not (
                  mask.iloc[i, j]
                  or i in styler.hidden_rows
                  or j in styler.hidden_columns
              )
          ]
          for style in sublist
      ]
  
      if self.table_styles:
          # add span class to every cell only if at least 1 non-empty tooltip
          for row in d["body"]:
              for item in row:
                  if item["type"] == "td":
                      item["display_value"] = (
                          str(item["display_value"])
                          + f'<span class="{self.class_name}"></span>'
                      )
          d["table_styles"].extend(self._class_styles)
          d["table_styles"].extend(self.table_styles)
  
      return d
  
imports: from __future__ import annotations
  from collections import defaultdict
  from collections.abc import Sequence
  from functools import partial
  import re
  from typing import TYPE_CHECKING, Any, Callable, DefaultDict, Optional, TypedDict, Union
  from uuid import uuid4
  import numpy
  from pandas._config import get_option
  from pandas._libs import lib
  from pandas.compat._optional import import_optional_dependency
  from pandas.core.dtypes.common import is_complex, is_float, is_integer
  from pandas.core.dtypes.generic import ABCSeries
  from pandas import DataFrame, Index, IndexSlice, MultiIndex, Series, isna
  from pandas.api.types import is_list_like
  import pandas.core.common
  from markupsafe import escape
label_desc: Use image node_id 4 for calling the Tooltips obj's underlying member method code with example usage: obj._translate(styler, d) and returns: d, d