
    &e09                    ^   U d dl mZ d dlmZ d dlmZmZmZmZmZm	Z	m
Z
mZ d dlZd dlmZ d dlmZ d dlmZmZmZmZmZmZ d dlmZ d d	lmZ d d
lmZ erd dl m!Z! d dl"m#Z#m$Z$m%Z% d dl&m'Z' d dl(m)Z) e
ddddej*        deee+ee         f         df	         Z,de-d<    G d d          Z.d d!dZ/dS )"    )annotations)Iterable)TYPE_CHECKINGAnyDictr   ListOptionalUnioncastN)	TypeAlias)	type_util)INDEX_IDENTIFIERColumnConfigMappingInputapply_data_specific_configsmarshall_column_configprocess_config_mappingupdate_column_config)marshall_styler)Arrow)gather_metrics)ndarray)	DataFrameIndexSeries)Styler)DeltaGeneratorr   r   r   r   r   r   Datac                      e Zd Z ed          	 	 	 dddddddd            Z ed          ddd            Z ed          dd d            Zed!d            ZdS )"
ArrowMixin	dataframeNF)use_container_width
hide_indexcolumn_ordercolumn_configdatar   width
int | Noneheightr!   boolr"   bool | Noner#   Iterable[str] | Noner$   ColumnConfigMappingInput | Nonereturn'DeltaGenerator'c                  t          |          }t                      }	||	_        |r||	_        |r||	_        |r||	j        dd<   t          j        j        |	_        t          |t          j                  rt          j        |          |	_        nt          j        |          }
t          j        |          rF| j                                        }t'          t)          |                    }t+          |	||           t          j        |d          }t/          |||
d           t          j        |          |	_        |t3          |t4          d|i           t7          |	|           | j                            d|	          S )u  Display a dataframe as an interactive table.

        This command works with dataframes from Pandas, PyArrow, Snowpark, and PySpark.
        It can also display several other types that can be converted to dataframes,
        e.g. numpy arrays, lists, sets and dictionaries.

        Parameters
        ----------
        data : pandas.DataFrame, pandas.Series, pandas.Styler, pandas.Index, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, snowflake.snowpark.table.Table, Iterable, dict, or None
            The data to display.

            If 'data' is a pandas.Styler, it will be used to style its
            underlying DataFrame. Streamlit supports custom cell
            values and colors. It does not support some of the more exotic
            pandas styling features, like bar charts, hovering, and captions.

        width : int or None
            Desired width of the dataframe expressed in pixels. If None, the width
            will be automatically calculated based on the column content.

        height : int or None
            Desired height of the dataframe expressed in pixels. If None, a
            default height is used.

        use_container_width : bool
            If True, set the dataframe width to the width of the parent container.
            This takes precedence over the width argument.

        hide_index : bool or None
            Whether to hide the index column(s). If None (default), the visibility of
            index columns is automatically determined based on the data.

        column_order : Iterable of str or None
            Specifies the display order of columns. This also affects which columns are
            visible. For example, ``column_order=("col2", "col1")`` will display 'col2'
            first, followed by 'col1', and will hide all other non-index columns. If
            None (default), the order is inherited from the original data structure.

        column_config : dict or None
            Configures how columns are displayed, e.g. their title, visibility, type, or
            format. This needs to be a dictionary where each key is a column name and
            the value is one of:

            * ``None`` to hide the column.

            * A string to set the display label of the column.

            * One of the column types defined under ``st.column_config``, e.g.
              ``st.column_config.NumberColumn("Dollar values”, format=”$ %d")`` to show
              a column as dollar amounts. See more info on the available column types
              and config options `here <https://docs.streamlit.io/library/api-reference/data/st.column_config>`_.

            To configure the index column(s), use ``_index`` as the column name.

        Examples
        --------
        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> df = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
        >>>
        >>> st.dataframe(df)  # Same as st.write(df)

        .. output::
           https://doc-dataframe.streamlit.app/
           height: 410px

        You can also pass a Pandas Styler object to change the style of
        the rendered DataFrame:

        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> df = pd.DataFrame(np.random.randn(10, 20), columns=("col %d" % i for i in range(20)))
        >>>
        >>> st.dataframe(df.style.highlight_max(axis=0))

        .. output::
           https://doc-dataframe1.streamlit.app/
           height: 410px

        Or you can customize the dataframe via ``column_config``, ``hide_index``, or ``column_order``:

        >>> import random
        >>> import pandas as pd
        >>> import streamlit as st
        >>>
        >>> df = pd.DataFrame(
        >>>     {
        >>>         "name": ["Roadmap", "Extras", "Issues"],
        >>>         "url": ["https://roadmap.streamlit.app", "https://extras.streamlit.app", "https://issues.streamlit.app"],
        >>>         "stars": [random.randint(0, 1000) for _ in range(3)],
        >>>         "views_history": [[random.randint(0, 5000) for _ in range(30)] for _ in range(3)],
        >>>     }
        >>> )
        >>> st.dataframe(
        >>>     df,
        >>>     column_config={
        >>>         "name": "App name",
        >>>         "stars": st.column_config.NumberColumn(
        >>>             "Github Stars",
        >>>             help="Number of stars on GitHub",
        >>>             format="%d ⭐",
        >>>         ),
        >>>         "url": st.column_config.LinkColumn("App URL"),
        >>>         "views_history": st.column_config.LineChartColumn(
        >>>             "Views (past 30 days)", y_min=0, y_max=5000
        >>>         ),
        >>>     },
        >>>     hide_index=True,
        >>> )

        .. output::
           https://doc-dataframe-config.streamlit.app/
           height: 350px

        NF)ensure_copy)check_arrow_compatibilityhiddenarrow_data_frame)r   
ArrowProtor!   r&   r(   r#   EditingMode	READ_ONLYediting_mode
isinstancepaTabler   pyarrow_table_to_bytesr%   determine_data_formatis_pandas_stylerdg_get_delta_path_strstrhashr   convert_anything_to_dfr   data_frame_to_bytesr   r   r   _enqueue)selfr%   r&   r(   r!   r"   r#   r$   column_config_mappingprotodata_format
delta_pathdefault_uuiddata_dfs                 8lib/python3.11/site-packages/streamlit/elements/arrow.pyr    zArrowMixin.dataframe8   s   J !7} E E$7! 	 EK 	"!EL 	1$0Eqqq!'3=dBH%% 	@"9$??EJJ $9$??K)$// ; "W88::
"4
#3#344t\:::  6tOOOG'%*/	    #6w??EJ! %'7(J9O   	u&;<<<w 2E:::    tablec                r   t          j        |          st          j        |t           j                  rt          j        |d          }| j                                        }t          t          |                    }t                      }t          |||           | j                            d|          S )a,  Display a static table.

        This differs from ``st.dataframe`` in that the table in this case is
        static: its entire contents are laid out directly on the page.

        Parameters
        ----------
        data : pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, snowflake.snowpark.table.Table, Iterable, dict, or None
            The table data.

        Example
        -------
        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> df = pd.DataFrame(np.random.randn(10, 5), columns=("col %d" % i for i in range(5)))
        >>>
        >>> st.table(df)

        .. output::
           https://doc-table.streamlit.app/
           height: 480px

        d   )max_unevaluated_rowsarrow_table)r   is_snowpark_data_objectis_type_PYSPARK_DF_TYPE_STRrB   r>   r?   r@   rA   r4   marshallrD   )rE   r%   rI   rJ   rG   s        rL   rN   zArrowMixin.table   s    < ,T22 	Ti6G)07
 7
 	T 3DsSSSD
 W0022
4
++,,l+++wu555rM   add_rows'Data'Optional['DeltaGenerator']c                (     | j         j        |fi |S )a  Concatenate a dataframe to the bottom of the current one.

        Parameters
        ----------
        data : pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.dataframe.DataFrame, Iterable, dict, or None
            Table to concat. Optional.

        **kwargs : pandas.DataFrame, numpy.ndarray, Iterable, dict, or None
            The named dataset to concat. Optional. You can only pass in 1
            dataset (including the one in the data parameter).

        Example
        -------
        >>> import streamlit as st
        >>> import pandas as pd
        >>> import numpy as np
        >>>
        >>> df1 = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
        >>>
        >>> my_table = st.table(df1)
        >>>
        >>> df2 = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
        >>>
        >>> my_table.add_rows(df2)
        >>> # Now the table shown in the Streamlit app contains the data for
        >>> # df1 followed by the data for df2.

        You can do the same thing with plots. For example, if you want to add
        more data to a line chart:

        >>> # Assuming df1 and df2 from the example above still exist...
        >>> my_chart = st.line_chart(df1)
        >>> my_chart.add_rows(df2)
        >>> # Now the chart shown in the Streamlit app contains the data for
        >>> # df1 followed by the data for df2.

        And for plots whose datasets are named, you can pass the data with a
        keyword argument where the key is the name:

        >>> my_chart = st.vega_lite_chart({
        ...     'mark': 'line',
        ...     'encoding': {'x': 'a', 'y': 'b'},
        ...     'datasets': {
        ...       'some_fancy_name': df1,  # <-- named dataset
        ...      },
        ...     'data': {'name': 'some_fancy_name'},
        ... }),
        >>> my_chart.add_rows(some_fancy_name=df2)  # <-- name used as keyword

        )r>   _arrow_add_rows)rE   r%   kwargss      rL   rW   zArrowMixin.add_rows  s"    h 'tw&t66v666rM   c                "    t          d|           S )zGet our DeltaGenerator.r   )r   )rE   s    rL   r>   zArrowMixin.dgS  s     $d+++rM   )NNN)r%   r   r&   r'   r(   r'   r!   r)   r"   r*   r#   r+   r$   r,   r-   r.   N)r%   r   r-   r.   )r%   rX   r-   rY   )r-   r.   )	__name__
__module____qualname__r   r    rN   rW   propertyr>    rM   rL   r   r   7   s        ^K    !	u; %*"&-19=u; u; u; u; u; ! u;n ^G*6 *6 *6 *6 *6X ^J37 37 37 37  37j , , , X, , ,rM   r   rG   r4   r%   rJ   Optional[str]r-   Nonec                R   t          j        |          r0t          |t                    s
J d            t	          | ||           t          |t
          j                  rt          j        |          | _        dS t          j	        |          }t          j
        |          | _        dS )a[  Marshall pandas.DataFrame into an Arrow proto.

    Parameters
    ----------
    proto : proto.Arrow
        Output. The protobuf for Streamlit Arrow proto.

    data : pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, pyspark.sql.DataFrame, snowflake.snowpark.DataFrame, Iterable, dict, or None
        Something that is or can be converted to a dataframe.

    default_uuid : Optional[str]
        If pandas.Styler UUID is not provided, this value will be used.
        This attribute is optional and only used for pandas.Styler, other elements
        (e.g. charts) can ignore it.

    z.Default UUID must be a string for Styler data.N)r   r=   r8   r@   r   r9   r:   r;   r%   rB   rC   )rG   r%   rJ   dfs       rL   rV   rV   Y  s    " !$'' 3 #
 
 	< 	<;	< 	< 	< 	t\222$!! 75d;;


-d332266


rM   r^   )rG   r4   r%   r   rJ   rd   r-   re   )0
__future__r   collections.abcr   typingr   r   r   r   r	   r
   r   pyarrowr9   typing_extensionsr   	streamlitr   *streamlit.elements.lib.column_config_utilsr   r   r   r   r   r   *streamlit.elements.lib.pandas_styler_utilsr   streamlit.proto.Arrow_pb2r   r4   streamlit.runtime.metrics_utilr   numpyr   pandasr   r   r   pandas.io.formats.styler   streamlit.delta_generatorr   r:   r@   r   __annotations__r   rV   rc   rM   rL   <module>rw      s    # " " " " " " $ $ $ $ $ $ R R R R R R R R R R R R R R R R R R R R     ' ' ' ' ' '                      G F F F F F 9 9 9 9 9 9 9 9 9 9 9 9 9//////////......888888Hd3i

 
 
 
 
_, _, _, _, _, _, _, _,D	7 7 7 7 7 7 7rM   