class_docstr: Helps style a DataFrame or Series according to the data with HTML and CSS.
  
  Parameters
  ----------
  data : Series or DataFrame
  precision : int
      precision to round floats to, defaults to pd.options.display.precision
  table_styles : list-like, default None
      list of {selector: (attr, value)} dicts; see Notes
  uuid : str, default None
      a unique identifier to avoid CSS collisions; generated automatically
  caption : str, default None
      caption to attach to the table
  cell_ids : bool, default True
      If True, each cell will have an ``id`` attribute in their HTML tag.
      The ``id`` takes the form ``T_<uuid>_row<num_row>_col<num_col>``
      where ``<uuid>`` is the unique identifier, ``<num_row>`` is the row
      number and ``<num_col>`` is the column number.
  
  Attributes
  ----------
  env : Jinja2 Environment
  template : Jinja2 Template
  loader : Jinja2 Loader
  
  See Also
  --------
  pandas.DataFrame.style
  
  Notes
  -----
  Most styling will be done by passing style functions into
  ``Styler.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
  the generated HTML.
  
  CSS classes are attached to the generated HTML
  
  * Index and Column names include ``index_name`` and ``level<k>``
    where `k` is its level in a MultiIndex
  * Index label cells include
  
    * ``row_heading``
    * ``row<n>`` where `n` is the numeric position of the row
    * ``level<k>`` where `k` is the level in a MultiIndex
  
  * Column label cells include
    * ``col_heading``
    * ``col<n>`` where `n` is the numeric position of the column
    * ``evel<k>`` where `k` is the level in a MultiIndex
  
  * Blank cells include ``blank``
  * Data cells include ``data``
class_docstr_tok: ["Helps","style","a","DataFrame","or","Series","according","to","the","data","with","HTML","and","CSS",".","Parameters","--","--","--","--","--","data",":","Series","or","DataFrame","precision",":","int","precision","to","round","floats","to",",","defaults","to","pd.options.display.precision","table_styles",":","list-like",",","default","None","list","of","{","selector",":","(","attr",",","value",")","}","dicts",";","see","Notes","uuid",":","str",",","default","None","a","unique","identifier","to","avoid","CSS","collisions",";","generated","automatically","caption",":","str",",","default","None","caption","to","attach","to","the","table","cell_ids",":","bool",",","default","True","If","True",",","each","cell","will","have","an","``","id","``","attribute","in","their","HTML","tag",".","The","``","id","``","takes","the","form","``","T_","<","uuid",">","_row","<","num_row",">","_col","<","num_col",">","``","where","``","<","uuid",">","``","is","the","unique","identifier",",","``","<","num_row",">","``","is","the","row","number","and","``","<","num_col",">","``","is","the","column","number",".","Attributes","--","--","--","--","--","env",":","Jinja2","Environment","template",":","Jinja2","Template","loader",":","Jinja2","Loader","See","Also","--","--","--","--","pandas.DataFrame.style","Notes","--","--","-","Most","styling","will","be","done","by","passing","style","functions","into","``","Styler.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","the","generated","HTML",".","CSS","classes","are","attached","to","the","generated","HTML","*","Index","and","Column","names","include","``","index_name","``","and","``","level","<","k",">","``","where","`","k","`","is","its","level","in","a","MultiIndex","*","Index","label","cells","include","*","``","row_heading","``","*","``","row","<","n",">","``","where","`","n","`","is","the","numeric","position","of","the","row","*","``","level","<","k",">","``","where","`","k","`","is","the","level","in","a","MultiIndex","*","Column","label","cells","include","*","``","col_heading","``","*","``","col","<","n",">","``","where","`","n","`","is","the","numeric","position","of","the","column","*","``","evel","<","k",">","``","where","`","k","`","is","the","level","in","a","MultiIndex","*","Blank","cells","include","``","blank","``","*","Data","cells","include","``","data","``"]
docstr: Color background in a range according to the data.
code: def _background_gradient(
      s, cmap="PuBu", low=0, high=0, text_color_threshold=0.408
  ):
      """
      Color background in a range according to the data.
      """
      if (
          not isinstance(text_color_threshold, (float, int))
          or not 0 <= text_color_threshold <= 1
      ):
          msg = "`text_color_threshold` must be a value from 0 to 1."
          raise ValueError(msg)
  
      with _mpl(Styler.background_gradient) as (plt, colors):
          smin = s.values.min()
          smax = s.values.max()
          rng = smax - smin
          # extend lower / upper bounds, compresses color range
          norm = colors.Normalize(
              smin - (rng * low), smax + (rng * high)
          )
          # matplotlib colors.Normalize modifies inplace?
          # https://github.com/matplotlib/matplotlib/issues/5427
          rgbas = plt.cm.get_cmap(cmap)(norm(s.values))
  
          def relative_luminance(rgba):
              """
              Calculate relative luminance of a color.
  
              The calculation adheres to the W3C standards
              (https://www.w3.org/WAI/GL/wiki/Relative_luminance)
  
              Parameters
              ----------
              color : rgb or rgba tuple
  
              Returns
              -------
              float
                  The relative luminance as a value from 0 to 1
              """
              r, g, b = (
                  x / 12.92
                  if x <= 0.03928
                  else ((x + 0.055) / 1.055**2.4)
                  for x in rgba[:3]
              )
              return 0.2126 * r + 0.7152 * g + 0.0722 * b
  
          def css(rgba):
              dark = relative_luminance(rgba) < text_color_threshold
              text_color = "#f1f1f1" if dark else "#000000"
              return "background-color: {b};color: {c};".format(
                  b=colors.rgb2hex(rgba), c=text_color
              )
  
          if s.ndim == 1:
              return [css(rgba) for rgba in rgbas]
          else:
              return pd.DataFrame(
                  [[css(rgba) for rgba in row] for row in rgbas],
                  index=s.index,
                  columns=s.columns,
              )
  
imports: from collections import defaultdict
  from contextlib import contextmanager
  import copy
  from functools import partial
  from itertools import product
  from uuid import uuid1
  import numpy
  from pandas.compat import range
  from pandas.util._decorators import Appender
  from pandas.core.dtypes.common import is_float, is_string_like
  from pandas.core.dtypes.generic import ABCSeries
  import pandas
  from pandas.api.types import is_dict_like, is_list_like
  import pandas.core.common
  from pandas.core.config import get_option
  from pandas.core.generic import _shared_docs
  from pandas.core.indexing import _maybe_numeric_slice, _non_reducing_slice
label_desc: Use image node_id 30 for calling the Styler obj's underlying member method code with example usage: obj._background_gradient(s, cmap, low, high, text_color_threshold) and returns: unknown, str, unknown, pd