Sindbad~EG File Manager
�
Mٜg�` � � � d Z ddlmZ ddlmZ ddlZddlmZ ddlZddl m
Z
mZmZm
Z
ddlZddlZddlmZ ddlmZ dd lmZmZ dd
lmZ ddlZddlmZmZ ddlmc m Z! ddl"m#Z#m$Z$ dd
l%m&Z& ddl'm(Z( ddl)m*Z* edd�� Z+ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 e
r0ddl7m8Z8m9Z9m:Z: ddl;m<Z< ddl=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZH ddlmIZI ddlJZKddlLmMZN dZOed'd�� ZQdZRdZSdZTdZUdZV G d � d!e0� ZW d(d"�ZX d) d*d#�ZY d+ d,d$�ZZd-d%�Z[ d.d&�Z\y# eP$ r dZOY �w xY w)/zF
Module for applying conditional formatting to DataFrames and Series.
� )�annotations)�contextmanagerN)�partial)�
TYPE_CHECKING�Any�Callable�overload)�
get_option)�import_optional_dependency)�Substitution�doc)�find_stack_level)�
IndexSlice�
RangeIndex)� DataFrame�Series)�NDFrame)�_shared_docs)�save_to_buffer�jinja2z DataFrame.style requires jinja2.)�extra)
�
CSSProperties� CSSStyles�ExtFormatter�StylerRenderer�Subset�Tooltips�format_table_styles�maybe_convert_css_to_tuples�non_reducing_slice�refactor_levels)� Generator�Hashable�Sequence)�Colormap)�Axis�AxisInt�FilePath�
IndexLabel�IntervalClosedType�Level�QuantileInterpolation�Scalar�StorageOptions�WriteBuffer�WriteExcelBuffer)�ExcelWriterTFc # �d K � t rt t f�� y t | j � d�� ��w)Nz requires matplotlib.)�has_mpl�plt�mpl�ImportError�__name__)�funcs �B/usr/local/lib/python3.12/site-packages/pandas/io/formats/style.py�_mplr: ] s) � �� ���3�h���T�]�]�O�+@�A�B�B�s �.0a( subset : label, array-like, IndexSlice, optional
A valid 2d input to `DataFrame.loc[<subset>]`, or, in the case of a 1d input
or single key, to `DataFrame.loc[:, <subset>]` where the columns are
prioritised, to limit ``data`` to *before* applying the function.z�props : str, default None
CSS properties to use for highlighting. If ``props`` is given, ``color``
is not used.zUcolor : str, default '{default}'
Background color to use for highlighting.z�buf : str, path object, file-like object, optional
String, path object (implementing ``os.PathLike[str]``), or file-like
object implementing a string ``write()`` function. If ``None``, the result is
returned as a string.z�encoding : str, optional
Character encoding setting for file output (and meta tags if available).
Defaults to ``pandas.options.styler.render.encoding`` value of "utf-8".c �
� � e Zd ZdZ db dc� fd�
Zddd�Zded�Zded�Z df dgd�Z e e
j d ed d �
� dh did�� Ze
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d� djd�� Ze
dkd
d
d
d
d
d
d
d
d
d
d
d
d
d
d
d� dld�� Z dmdddddddddddddddd� dnd�Ze
d
d
d
d
d
d
d
d
d
d
d
d� dod�� Ze
dkd
d
d
d
d
d
d
d
d
d
d
d� dpd�� Z eee�� dmdddddddddddd� dqd�� Ze
d
d
d
d
d
d
d� drd�� Ze
dkd
d
d
d
d
d
d� dsd�� Z eee�� dmddddddd� dtd�� Zdud�Zdvd�Zdwd�Zdxdyd �Zdzd!�Zdzd"�Zd{d#�Z d| d}d$�Z ee�%� d| d}d&�� Z d~ dd(�Z e d'd)d*d+d,d-d.d/d0d1�2�
d| d�d3�� Z e ed*d+d'd)d4d5d6d7d8d9�2� d| d�d:�� Z d| d�d;�Z!dmd�d<�Z" ee�%� dmd�d=�� Z# ee�%� dm d�d>�� Z$d�d?�Z%d�d@�Z&d�dA�Z'd�dB�Z(d�dC�Z) d� d�dD�Z* d� d�dE�Z+ d� d�dF�Z,dG� Z- e dHdIdJdK�L� ee�%� d� d�dM�� � Z. e e.dIdHdNd�L� d� d�dO�� Z/ ee�%� dmd�dP�� Z0 ee�%� d�dddQdQdRdddSdT� d�dU�� Z1 eee2e3ji dV�W� �X� d� d�dY�� Z5 eee3ji dZ�W� e2�[� d� d�d\�� Z6 eee3ji dZ�W� e2�[� d� d�d]�� Z7 eee3ji dZ�W� e2�[� d� d�d^�� Z8 eee3ji dZ�W� e2�[� d� d�d_�� Z9e: df d�d`�� Z;d�da�Z<� xZ=S )��Stylera�
Helps style a DataFrame or Series according to the data with HTML and CSS.
Parameters
----------
data : Series or DataFrame
Data to be styled - either a Series or DataFrame.
precision : int, optional
Precision to round floats to. If not given defaults to
``pandas.options.styler.format.precision``.
.. versionchanged:: 1.4.0
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, tuple, default None
String caption to attach to the table. Tuple only used for LaTeX dual captions.
table_attributes : str, default None
Items that show up in the opening ``<table>`` tag
in addition to automatic (by default) id.
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.
na_rep : str, optional
Representation for missing values.
If ``na_rep`` is None, no special formatting is applied, and falls back to
``pandas.options.styler.format.na_rep``.
uuid_len : int, default 5
If ``uuid`` is not specified, the length of the ``uuid`` to randomly generate
expressed in hex characters, in range [0, 32].
decimal : str, optional
Character used as decimal separator for floats, complex and integers. If not
given uses ``pandas.options.styler.format.decimal``.
.. versionadded:: 1.3.0
thousands : str, optional, default None
Character used as thousands separator for floats, complex and integers. If not
given uses ``pandas.options.styler.format.thousands``.
.. versionadded:: 1.3.0
escape : str, optional
Use 'html' to replace the characters ``&``, ``<``, ``>``, ``'``, and ``"``
in cell display string with HTML-safe sequences.
Use 'latex' to replace the characters ``&``, ``%``, ``$``, ``#``, ``_``,
``{``, ``}``, ``~``, ``^``, and ``\`` in the cell display string with
LaTeX-safe sequences. Use 'latex-math' to replace the characters
the same way as in 'latex' mode, except for math substrings,
which either are surrounded by two characters ``$`` or start with
the character ``\(`` and end with ``\)``.
If not given uses ``pandas.options.styler.format.escape``.
.. versionadded:: 1.3.0
formatter : str, callable, dict, optional
Object to define how values are displayed. See ``Styler.format``. If not given
uses ``pandas.options.styler.format.formatter``.
.. versionadded:: 1.4.0
Attributes
----------
env : Jinja2 jinja2.Environment
template_html : Jinja2 Template
template_html_table : Jinja2 Template
template_html_style : Jinja2 Template
template_latex : Jinja2 Template
loader : Jinja2 Loader
See Also
--------
DataFrame.style : Return a Styler object containing methods for building
a styled HTML representation for the DataFrame.
Notes
-----
Most styling will be done by passing style functions into
``Styler.apply`` or ``Styler.map``. 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.to_html 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
* ``level<k>`` where `k` is the level in a MultiIndex
* Blank cells include ``blank``
* Data cells include ``data``
* Trimmed cells include ``col_trim`` or ``row_trim``.
Any, or all, or these classes can be renamed by using the ``css_class_names``
argument in ``Styler.set_table_classes``, giving a value such as
*{"row": "MY_ROW_CLASS", "col_trim": "", "row_trim": ""}*.
Examples
--------
>>> df = pd.DataFrame([[1.0, 2.0, 3.0], [4, 5, 6]], index=['a', 'b'],
... columns=['A', 'B', 'C'])
>>> pd.io.formats.style.Styler(df, precision=2,
... caption="My table") # doctest: +SKIP
Please see:
`Table Visualization <../../user_guide/style.ipynb>`_ for more examples.
Nc
� �� t �| � ||| |||||�� |xs t d� }|
xs t d� }
|xs t d� }|xs t d� }|
xs t d� }
| j |
||||
|�� y )N)�data�uuid�uuid_len�table_styles�table_attributes�caption�cell_ids� precisionzstyler.format.thousandszstyler.format.decimalzstyler.format.na_repzstyler.format.escapezstyler.format.formatter)� formatterrE �na_rep�escape�decimal� thousands)�super�__init__r
�format)�selfr>