o
    YhK                     @  s$  U d dl mZ d dlZd dlmZ d dlmZ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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mZm Z m!Z! d dl"m#Z# d dl$m%Z% d dl&m'Z'm(Z(m)Z) d dl*m+Z+ d dl,m-Z. d dl/m0Z0 d dl1m2Z2 d dl3m4Z4m5Z5 d dl6m7Z7m8Z8 d dl9m:Z: erd dl;m<Z<m=Z= d dl>mZ? d dl@mAZA d dlBmCZC d dlDmEZE d dlFmGZG e	d ZHdeId< h dZJdeId < G d!d" d"e
d#d$ZKG d%d& d&e
d#d$ZLeG d'd( d(ZMdFd-d.ZNG d/d0 d0ZOdGd6d7ZP	dHdId=d>ZQdHdJdDdEZRdS )K    )annotationsN)	dataclass)TYPE_CHECKINGAnyFinalLiteral	TypedDictcastoverload)	TypeAlias)dataframe_util)make_deprecated_name_warningshow_deprecation_warning)INDEX_IDENTIFIERColumnConfigMappingInputapply_data_specific_configsmarshall_column_configprocess_config_mappingupdate_column_config)current_form_id)LayoutConfigWidthvalidate_heightvalidate_width)marshall_styler)check_widget_policies)Keycompute_and_register_element_idto_key)StreamlitAPIException)Arrow)
ForwardMsg)gather_metrics)enqueue_messageget_script_run_ctx)WidgetCallbackregister_widget)AttributeDictionary)HashableIterable)typing)	DataFrame)Data)DeltaGenerator)AddRowsMetadata)
single-row	multi-rowsingle-columnmulti-columnsingle-cell
multi-cellr   SelectionMode>   r0   r4   r/   r3   r2   r1   zFinal[set[SelectionMode]]_SELECTION_MODESc                   @  s*   e Zd ZU dZded< ded< ded< dS )	DataframeSelectionStatea(  
    The schema for the dataframe selection state.

    The selection state is stored in a dictionary-like object that supports both
    key and attribute notation. Selection states cannot be programmatically
    changed or set through Session State.

    .. warning::
        If a user sorts a dataframe, row selections will be reset. If your
        users need to sort and filter the dataframe to make selections, direct
        them to use the search function in the dataframe toolbar instead.

    Attributes
    ----------
    rows : list[int]
        The selected rows, identified by their integer position. The integer
        positions match the original dataframe, even if the user sorts the
        dataframe in their browser. For a ``pandas.DataFrame``, you can
        retrieve data from its integer position using methods like ``.iloc[]``
        or ``.iat[]``.
    columns : list[str]
        The selected columns, identified by their names.
    cells : list[tuple[int, str]]
        The selected cells, provided as a tuple of row integer position
        and column name. For example, the first cell in a column named "col 1"
        is represented as ``(0, "col 1")``. Cells within index columns are not
        returned.

    Example
    -------
    The following example has multi-row and multi-column selections enabled.
    Try selecting some rows. To select multiple columns, hold ``CMD`` (macOS)
    or ``Ctrl`` (Windows) while selecting columns. Hold ``Shift`` to select a
    range of columns.

    >>> import pandas as pd
    >>> import streamlit as st
    >>> from numpy.random import default_rng as rng
    >>>
    >>> df = pd.DataFrame(
    ...     rng(0).standard_normal((12, 5)), columns=["a", "b", "c", "d", "e"]
    ... )
    >>>
    >>> event = st.dataframe(
    ...     df,
    ...     key="data",
    ...     on_select="rerun",
    ...     selection_mode=["multi-row", "multi-column", "multi-cell"],
    ... )
    >>>
    >>> event.selection

    .. output::
        https://doc-dataframe-events-selection-state.streamlit.app
        height: 600px

    z	list[int]rowsz	list[str]columnszlist[tuple[int, str]]cellsN__name__
__module____qualname____doc____annotations__ rA   rA   Y/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/streamlit/elements/arrow.pyr7   ^   s
   
 :r7   F)totalc                   @  s   e Zd ZU dZded< dS )DataframeStateaX  
    The schema for the dataframe event state.

    The event state is stored in a dictionary-like object that supports both
    key and attribute notation. Event states cannot be programmatically
    changed or set through Session State.

    Only selection events are supported at this time.

    Attributes
    ----------
    selection : dict
        The state of the ``on_select`` event. This attribute returns a
        dictionary-like object that supports both key and attribute notation.
        The attributes are described by the ``DataframeSelectionState``
        dictionary schema.


    r7   	selectionNr;   rA   rA   rA   rB   rD      s   
 rD   c                   @  s$   e Zd ZdZdddZdd
dZdS )DataframeSelectionSerdez[DataframeSelectionSerde is used to serialize and deserialize the dataframe selection state.ui_value
str | NonereturnrD   c                 C  s   dg g g di}|d u r|nt |}d|vr|}d|d vr%g |d d< d|d vr1g |d d< d|d vr>g |d d< ndd |d d D |d d< tdt|S )	NrE   )r8   r9   r:   r8   r9   r:   c                 S  s   g | ]}t |qS rA   )tuple).0cellrA   rA   rB   
<listcomp>   s    z7DataframeSelectionSerde.deserialize.<locals>.<listcomp>rD   )jsonloadsr	   r'   )selfrG   empty_selection_stateselection_staterA   rA   rB   deserialize   s(   
z#DataframeSelectionSerde.deserializestatestrc                 C  s
   t |S N)rN   dumps)rP   rT   rA   rA   rB   	serialize   s   
z!DataframeSelectionSerde.serializeN)rG   rH   rI   rD   )rT   rD   rI   rU   )r<   r=   r>   r?   rS   rX   rA   rA   rA   rB   rF      s    
"rF   selection_mode'SelectionMode | Iterable[SelectionMode]rI   'set[ArrowProto.SelectionMode.ValueType]c                 C  s  t | tr	| h}nt| }|tstd|  dt |ddhr'td|ddhr2td|d	d
hr=tdg }|D ]I}|dkrO|tj	j
 qA|dkr[|tj	j qA|dkrg|tj	j qA|dkrs|tj	j qA|d	kr|tj	j qA|d
kr|tj	j qAt|S )z2Parse and check the user provided selection modes.zInvalid selection mode: z. Valid options are: r/   r0   zJOnly one of `single-row` or `multi-row` can be selected as selection mode.r1   r2   zPOnly one of `single-column` or `multi-column` can be selected as selection mode.r3   r4   zLOnly one of `single-cell` or `multi-cell` can be selected as selection mode.)
isinstancerU   setissubsetr6   r   
issupersetappend
ArrowProtor5   
SINGLE_ROW	MULTI_ROWSINGLE_COLUMNMULTI_COLUMNSINGLE_CELL
MULTI_CELL)rY   selection_mode_setparsed_selection_modesmoderA   rA   rB   parse_selection_mode   sJ   

rk   c                   @  s   e Zd Ze			d3dddddddddd4ddZe			d3dddddddd d5d#dZed$			d3dddddddddd6d'dZed(d7d8d)d*Zed+d7d9d/d0Zed:d1d2Z	dS );
ArrowMixinNstretchautoignorer0   )use_container_width
hide_indexcolumn_ordercolumn_configkey	on_selectrY   
row_heightdatar,   widthr   heightint | Literal['auto']rp   bool | Nonerq   rr   Iterable[str] | Noners   ColumnConfigMappingInput | Nonert   
Key | Noneru   Literal['ignore']rY   rZ   rv   
int | NonerI   r-   c                C     d S rV   rA   rP   rw   rx   ry   rp   rq   rr   rs   rt   ru   rY   rv   rA   rA   rB   	dataframe     zArrowMixin.dataframe)rp   rq   rr   rs   rt   rY   rv   !Literal['rerun'] | WidgetCallbackrD   c                C  r   rV   rA   r   rA   rA   rB   r   #  r   r   +Literal['ignore', 'rerun'] | WidgetCallbackDeltaGenerator | DataframeStatec                C  sL  ddl }|	dvrt|	std|	 dt|}|	dk}|r4t|	}t| j||r-td|	nddd|d	 |durQttd
ddddddd |rJd}nt	|t
sQd}t|dd t|dddgd t|}t }|rl||_|ru||jdd< tjj|_t	||jrt||_n-t|}t|r| j }tt|}t||| tj|dd}t|| t ||_|durt!|t"d|i t#|| t$||dkr|ndd}|r|j%&t'|
 t(| j|_)t* }t+d|| j|j||||j|j,|
||d|_-t. }t/|j-t|	r|	nd|j0|j1|dd}| jj2d||d |j3S | jj2d||dS )u2  Display a dataframe as an interactive table.

        This command works with a wide variety of collection-like and
        dataframe-like object types.

        Parameters
        ----------
        data : dataframe-like, collection-like, or None
            The data to display.

            Dataframe-like objects include dataframe and series objects from
            popular libraries like Dask, Modin, Numpy, pandas, Polars, PyArrow,
            Snowpark, Xarray, and more. You can use database cursors and
            clients that comply with the
            `Python Database API Specification v2.0 (PEP 249)
            <https://peps.python.org/pep-0249/>`_. Additionally, you can use
            anything that supports the `Python dataframe interchange protocol
            <https://data-apis.org/dataframe-protocol/latest/>`_.

            For example, you can use the following:

            - ``pandas.DataFrame``, ``pandas.Series``, ``pandas.Index``,
              ``pandas.Styler``, and ``pandas.Array``
            - ``polars.DataFrame``, ``polars.LazyFrame``, and ``polars.Series``
            - ``snowflake.snowpark.dataframe.DataFrame``,
              ``snowflake.snowpark.table.Table``

            If a data type is not recognized, Streamlit will convert the object
            to a ``pandas.DataFrame`` or ``pyarrow.Table`` using a
            ``.to_pandas()`` or ``.to_arrow()`` method, respectively, if
            available.

            If ``data`` is a ``pandas.Styler``, it will be used to style its
            underlying ``pandas.DataFrame``. Streamlit supports custom cell
            values, colors, and font weights. It does not support some of the
            more exotic styling options, like bar charts, hovering, and
            captions. For these styling options, use column configuration
            instead. Text and number formatting from ``column_config`` always
            takes precedence over text and number formatting from ``pandas.Styler``.

            Collection-like objects include all Python-native ``Collection``
            types, such as ``dict``, ``list``, and ``set``.

            If ``data`` is ``None``, Streamlit renders an empty table.

        width : "stretch", "content", or int
            The width of the dataframe element. This can be one of the following:

            - ``"stretch"`` (default): The width of the element matches the
              width of the parent container.
            - ``"content"``: The width of the element matches the width of its
              content, but doesn't exceed the width of the parent container.
            - An integer specifying the width in pixels: The element has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the element matches the width
              of the parent container.

        height : int or "auto"
            The height of the dataframe element. This can be one of the following:

            - ``"auto"`` (default): Streamlit sets the height to show at most
              ten rows.
            - An integer specifying the height in pixels: The element has a
              fixed height.

            Vertical scrolling within the dataframe element is enabled when the
            height does not accommodate all rows.

        use_container_width : bool
            Whether to override ``width`` with the width of the parent
            container. If this is ``True`` (default), Streamlit sets the width
            of the dataframe to match the width of the parent container. If
            this is ``False``, Streamlit sets the dataframe's width according
            to ``width``.

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

        column_order : Iterable[str] or None
            The ordered list of columns to display. If this is ``None``
            (default), Streamlit displays all columns in the order inherited
            from the underlying data structure. If this is a list, the
            indicated columns will display in the order they appear within the
            list. Columns may be omitted or repeated within the list.

            For example, ``column_order=("col2", "col1")`` will display
            ``"col2"`` first, followed by ``"col1"``, and will hide all other
            non-index columns.

            ``column_order`` does not accept positional column indices and
            can't move the index column(s).

        column_config : dict or None
            Configuration to customize how columns are displayed. If this is
            ``None`` (default), columns are styled based on the underlying data
            type of each column.

            Column configuration can modify column names, visibility, type,
            width, format, and more. If this is a dictionary, the keys are
            column names (strings) and/or positional column indices (integers),
            and the values are one of the following:

            - ``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``. For
              example, to show a column as dollar amounts, use
              ``st.column_config.NumberColumn("Dollar values", format="$ %d")``.
              See more info on the available column types and config options
              `here <https://docs.streamlit.io/develop/api-reference/data/st.column_config>`_.

            To configure the index column(s), use ``"_index"`` as the column
            name, or use a positional column index where ``0`` refers to the
            first index column.

        key : str
            An optional string to use for giving this element a stable
            identity. If ``key`` is ``None`` (default), this element's identity
            will be determined based on the values of the other parameters.

            Additionally, if selections are activated and ``key`` is provided,
            Streamlit will register the key in Session State to store the
            selection state. The selection state is read-only.

        on_select : "ignore" or "rerun" or callable
            How the dataframe should respond to user selection events. This
            controls whether or not the dataframe behaves like an input widget.
            ``on_select`` can be one of the following:

            - ``"ignore"`` (default): Streamlit will not react to any selection
              events in the dataframe. The dataframe will not behave like an
              input widget.

            - ``"rerun"``: Streamlit will rerun the app when the user selects
              rows, columns, or cells in the dataframe. In this case,
              ``st.dataframe`` will return the selection data as a dictionary.

            - A ``callable``: Streamlit will rerun the app and execute the
              ``callable`` as a callback function before the rest of the app.
              In this case, ``st.dataframe`` will return the selection data
              as a dictionary.

        selection_mode : "single-row", "multi-row", "single-column",             "multi-column", "single-cell", "multi-cell", or Iterable of these
            The types of selections Streamlit should allow when selections are
            enabled with ``on_select``. This can be one of the following:

            - "multi-row" (default): Multiple rows can be selected at a time.
            - "single-row": Only one row can be selected at a time.
            - "multi-column": Multiple columns can be selected at a time.
            - "single-column": Only one column can be selected at a time.
            - "multi-cell": A rectangular range of cells can be selected.
            - "single-cell": Only one cell can be selected at a time.
            - An ``Iterable`` of the above options: The table will allow
              selection based on the modes specified. For example, to allow the
              user to select multiple rows and multiple cells, use
              ``["multi-row", "multi-cell"]``.

            When column selections are enabled, column sorting is disabled.

        row_height : int or None
            The height of each row in the dataframe in pixels. If ``row_height``
            is ``None`` (default), Streamlit will use a default row height,
            which fits one line of text.

        .. deprecated::
            ``use_container_width`` is deprecated and will be removed in a
            future release. For ``use_container_width=True``, use
            ``width="stretch"``.

        Returns
        -------
        element or dict
            If ``on_select`` is ``"ignore"`` (default), this command returns an
            internal placeholder for the dataframe element that can be used
            with the ``.add_rows()`` method. Otherwise, this command returns a
            dictionary-like object that supports both key and attribute
            notation. The attributes are described by the ``DataframeState``
            dictionary schema.

        Examples
        --------
        **Example 1: Display a dataframe**

        >>> import pandas as pd
        >>> import streamlit as st
        >>> from numpy.random import default_rng as rng
        >>>
        >>> df = pd.DataFrame(
        ...     rng(0).standard_normal((50, 20)), columns=("col %d" % i for i in range(20))
        ... )
        >>>
        >>> st.dataframe(df)

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

        **Example 2: Use Pandas Styler**

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

        >>> import pandas as pd
        >>> import streamlit as st
        >>> from numpy.random import default_rng as rng
        >>>
        >>> df = pd.DataFrame(
        ...     rng(0).standard_normal((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: 500px

        **Example 3: Use column configuration**

        You can customize a dataframe via ``column_config``, ``hide_index``, or ``column_order``.

        >>> import pandas as pd
        >>> import streamlit as st
        >>> from numpy.random import default_rng as rng
        >>>
        >>> df = pd.DataFrame(
        ...     {
        ...         "name": ["Roadmap", "Extras", "Issues"],
        ...         "url": [
        ...             "https://roadmap.streamlit.app",
        ...             "https://extras.streamlit.app",
        ...             "https://issues.streamlit.app",
        ...         ],
        ...         "stars": rng(0).integers(0, 1000, size=3),
        ...         "views_history": rng(0).integers(0, 5000, size=(3, 30)).tolist(),
        ...     }
        ... )
        >>>
        >>> 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

        **Example 4: Customize your index**

        You can use column configuration to format your index.

        >>> from datetime import datetime, date
        >>> import numpy as np
        >>> import pandas as pd
        >>> import streamlit as st
        >>>
        >>> @st.cache_data
        >>> def load_data():
        >>>     year = datetime.now().year
        >>>     df = pd.DataFrame(
        ...         {
        ...             "Date": [date(year, month, 1) for month in range(1, 4)],
        ...             "Total": np.random.randint(1000, 5000, size=3),
        ...         }
        ...     )
        >>>     df.set_index("Date", inplace=True)
        >>>     return df
        >>>
        >>> df = load_data()
        >>> config = {
        ...     "_index": st.column_config.DateColumn("Month", format="MMM YYYY"),
        ...     "Total": st.column_config.NumberColumn("Total ($)"),
        ... }
        >>>
        >>> st.dataframe(df, column_config=config)

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

        r   N)ro   rerunzYou have passed zH to `on_select`. But only 'ignore', 'rerun', or a callable is supported.ro   r%   F)	on_changedefault_valuewrites_allowedenable_check_callback_rulesrp   rx   z
2025-12-31znFor `use_container_width=True`, use `width='stretch'`. For `use_container_width=False`, use `width='content'`.)include_st_prefix)show_in_browserrm   contentT)allow_contentrn   )r   allow_stretchadditional_allowed)ensure_copyhiddenrx   ry   r   )user_keydgrw   rx   ry   rp   rr   rs   rY   is_selection_activatedrv   string_value)on_change_handlerdeserializer
serializerctx
value_typearrow_data_framelayout_config)4pyarrowcallabler   r   r   r   r	   r   r   r\   intr   r   r   ra   rv   rr   EditingMode	READ_ONLYediting_modeTabler   "convert_arrow_table_to_arrow_bytesrw   determine_data_formatis_pandas_styler_get_delta_path_strrU   hashr   convert_anything_to_pandas_dfr    convert_pandas_df_to_arrow_bytesr   r   r   r   rY   extendrk   r   form_idr$   r   r9   idrF   r&   rS   rX   _enqueuevalue)rP   rw   rx   ry   rp   rq   rr   rs   rt   ru   rY   rv   par   is_callbackcolumn_config_mappingprotodata_format
delta_pathdefault_uuiddata_dfr   r   serdewidget_staterA   rA   rB   r   4  s     8
	







tablec                 C  s^   t |rt j|dd}| j }tt|}tddd}t }t	||| | jj
d||dS )a	  Display a static table.

        While ``st.dataframe`` is geared towards large datasets and interactive
        data exploration, ``st.table`` is useful for displaying small, styled
        tables without sorting or scrolling. For example, ``st.table`` may be
        the preferred way to display a confusion matrix or leaderboard.
        Additionally, ``st.table`` supports Markdown.

        Parameters
        ----------
        data : Anything supported by st.dataframe
            The table data.

            All cells including the index and column headers can optionally
            contain GitHub-flavored Markdown. Syntax information can be found
            at: https://github.github.com/gfm.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        Examples
        --------
        **Example 1: Display a simple dataframe as a static table**

        >>> import pandas as pd
        >>> import streamlit as st
        >>> from numpy.random import default_rng as rng
        >>>
        >>> df = pd.DataFrame(
        ...     rng(0).standard_normal(size=(10, 5)),
        ...     columns=("col %d" % i for i in range(5)),
        ... )
        >>>
        >>> st.table(df)

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

        **Example 2: Display a table of Markdown strings**

        >>> import pandas as pd
        >>> import streamlit as st
        >>>
        >>> df = pd.DataFrame(
        ...     {
        ...         "Command": ["**st.table**", "*st.dataframe*"],
        ...         "Type": ["`static`", "`interactive`"],
        ...         "Docs": [
        ...             "[:rainbow[docs]](https://docs.streamlit.io"
        ...             "/develop/api-reference/data/st.dataframe)",
        ...             "[:open_book:](https://docs.streamlit.io"
        ...             "/develop/api-reference/data/st.table)",
        ...         ],
        ...     }
        ... )
        >>>
        >>> st.table(df)

        .. output::
           https://doc-table-markdown.streamlit.app/
           height: 200px
        d   )max_unevaluated_rowsrm   r   r   arrow_tabler   )r   is_unevaluated_data_objectr   r   r   rU   r   r   ra   marshallr   )rP   rw   r   r   r   r   rA   rA   rB   r     s   
I
zArrowMixin.tableadd_rowskwargsr   DeltaGenerator | Nonec                 K  s   t | 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 time
        >>> import pandas as pd
        >>> import streamlit as st
        >>> from numpy.random import default_rng as rng
        >>>
        >>> df1 = pd.DataFrame(
        >>>     rng(0).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
        >>> )
        >>>
        >>> df2 = pd.DataFrame(
        >>>     rng(1).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
        >>> )
        >>>
        >>> my_table = st.table(df1)
        >>> time.sleep(1)
        >>> my_table.add_rows(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)
        >>> time.sleep(1)
        >>> my_chart.add_rows(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

        )_arrow_add_rowsr   )rP   rw   r   rA   rA   rB   r   P  s   8zArrowMixin.add_rowsc                 C  s
   t d| S )zGet our DeltaGenerator.r-   )r	   )rP   rA   rA   rB   r     s   
zArrowMixin.dg)Nrm   rn   )rw   r,   rx   r   ry   rz   rp   r{   rq   r{   rr   r|   rs   r}   rt   r~   ru   r   rY   rZ   rv   r   rI   r-   )rw   r,   rx   r   ry   rz   rp   r{   rq   r{   rr   r|   rs   r}   rt   r~   ru   r   rY   rZ   rv   r   rI   rD   )rw   r,   rx   r   ry   rz   rp   r{   rq   r{   rr   r|   rs   r}   rt   r~   ru   r   rY   rZ   rv   r   rI   r   rV   )rw   r,   rI   r-   )rw   r,   r   r   rI   r   )rI   r-   )
r<   r=   r>   r
   r   r"   r   r   propertyr   rA   rA   rA   rB   rl     sf       ?^9rl   rw   r,   add_rows_metadataAddRowsMetadata | None#tuple[Data, AddRowsMetadata | None]c                 C  s:   |st | r| d fS t | d fS ddlm} || |S )Nr   )prep_chart_data_for_add_rows)r   r   r   +streamlit.elements.lib.built_in_chart_utilsr   )rw   r   r   rA   rA   rB   _prep_data_for_add_rows  s   

r   r   r-   r   IDataFrame | npt.NDArray[Any] | Iterable[Any] | dict[Hashable, Any] | Noner   c           	      K  s  | j du s
| jdu r| S | jjstd|dur!t|dkr!d}nt|dkr.| \}}ntdd| jjv r| jjd r| jjd jdu rt| | jjd j	}| jjd }i }|j
durc|j
|d< |jdurm|j|d	< |jdurw|j|d
< |jdur|j|d< |j	dkr|j|d< |j|d< ||fi | dS t|| jjd \}| jjd< t }| jj|jjdd< tt|  }t|jjj|| |r||jj_d|jj_t| | S )a  Concatenate a dataframe to the bottom of the current one.

    Parameters
    ----------
    data : pandas.DataFrame, pandas.Styler, numpy.ndarray, 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 time
    >>> import pandas as pd
    >>> import streamlit as st
    >>> from numpy.random import default_rng as rng
    >>>
    >>> df1 = pd.DataFrame(
    >>>     rng(0).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
    >>> )
    >>>
    >>> df2 = pd.DataFrame(
    >>>     rng(1).standard_normal(size=(50, 20)), columns=("col %d" % i for i in range(20))
    >>> )
    >>>
    >>> my_table = st.table(df1)
    >>> time.sleep(1)
    >>> my_table.add_rows(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)
    >>> time.sleep(1)
    >>> my_chart.add_rows(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

    Nz&Only existing elements can `add_rows`.r       zLWrong number of arguments to add_rows().Command requires exactly one datasetr   colorrx   ry   stack	bar_chart
horizontalrp   T)_root_container_cursor	is_lockedr   lenpopitemprops
last_indexgetattrchart_commandr   rx   ry   r   r   rp   r   r!   r   metadatarU   r   r   r   deltaarrow_add_rowsrw   namehas_namer#   )	r   rw   r   r   	st_methodr   new_datamsgr   rA   rA   rB   r     sX   ;	














r   r   ra   r   rH   Nonec                 C  s8   t |rt|tstdt| || t || _dS )aX  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 : str | None
        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   r\   rU   r   r   convert_anything_to_arrow_bytesrw   )r   rw   r   rA   rA   rB   r   '  s   

r   )rY   rZ   rI   r[   )rw   r,   r   r   rI   r   rV   )r   r-   rw   r,   r   r   rI   r   )r   ra   rw   r,   r   rH   rI   r   )S
__future__r   rN   dataclassesr   r*   r   r   r   r   r   r	   r
   typing_extensionsr   	streamlitr   streamlit.deprecation_utilr   r   *streamlit.elements.lib.column_config_utilsr   r   r   r   r   r   !streamlit.elements.lib.form_utilsr   #streamlit.elements.lib.layout_utilsr   r   r   r   *streamlit.elements.lib.pandas_styler_utilsr   streamlit.elements.lib.policiesr   streamlit.elements.lib.utilsr   r   r   streamlit.errorsr   streamlit.proto.Arrow_pb2r    ra   streamlit.proto.ForwardMsg_pb2r!   streamlit.runtime.metrics_utilr"   7streamlit.runtime.scriptrunner_utils.script_run_contextr#   r$   streamlit.runtime.stater%   r&   streamlit.utilr'   collections.abcr(   r)   numpynptpandasr+   streamlit.dataframe_utilr,   streamlit.delta_generatorr-   r   r.   r5   r@   r6   r7   rD   rF   rk   rl   r   r   r   rA   rA   rA   rB   <module>   s^   $
 
@
)1     
 