
    4iگ                       U d dl 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mZmZmZmZ d dl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!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-m.Z. d dl/m0Z0 d dl1m2Z2 d dl3m4Z4m5Z5m6Z6 d dl7m8Z8 d dl9m:Z; d dl<m=Z= d dl>m?Z? d dl@mAZAmBZBmCZCmDZD d dlEmFZFmGZG d dlHmIZI er d dlJmKZKmLZL d dlMZNd dlOZPd dlQZRd dlSmTZT d dlUmVZV  ej                  eX      ZYdeZd<    edej                  e	   e\e	   z  e]e	   z  e^e	   z  e_e`e	f   z        Zaeddd d!d"d#e\e	   e]e	   e^e	   e_e`e	f   f
   Zbd$eZd%<    G d& d'ed()      Zce G d* d+             Zd	 	 	 	 	 	 d9d,Ze	 	 	 	 	 	 	 	 d:d-Zf	 	 	 	 	 	 	 	 d;d.Zg	 	 	 	 	 	 	 	 d<d/Zh	 	 	 	 	 	 	 	 d=d0Zid>d1Zj	 	 	 	 	 	 	 	 d?d2Zkd@d3ZldAd4ZmdAd5Zn	 	 	 	 	 	 	 	 dBd6Zo G d7 d8      Zpy)C    )annotationsN)	dataclass)Decimal)
TYPE_CHECKINGAnyFinalLiteral	TypeAlias	TypedDictTypeVarUnioncastoverload)Required)dataframe_util)logger)make_deprecated_name_warningshow_deprecation_warning)INDEX_IDENTIFIERColumnConfigMappingColumnConfigMappingInputColumnDataKindDataframeSchemaapply_data_specific_configsdetermine_dataframe_schemais_type_compatiblemarshall_column_configprocess_config_mappingupdate_column_config)current_form_id)HeightLayoutConfigWidthvalidate_heightvalidate_width)marshall_styler)check_widget_policies)Keycompute_and_register_element_idto_key)StreamlitAPIException)Arrow)gather_metrics)get_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsregister_widget)is_list_likeis_type)calc_md5)IterableMapping)Styler)DeltaGeneratorr   _LOGGEREditableData)boundpd.DataFramezpd.Series[Any]pd.Index[Any]r8   zpa.Tablez%np.ndarray[Any, np.dtype[np.float64]]r
   	DataTypesc                  0    e Zd ZU dZded<   ded<   ded<   y)	EditingStateaD  
    A dictionary representing the current state of the data editor.

    Attributes
    ----------
    edited_rows : Dict[int, Dict[str, str | int | float | bool | None]]
        An hierarchical mapping of edited cells based on:
        row position -> column name -> value.

    added_rows : List[Dict[str, str | int | float | bool | None]]
        A list of added rows, where each row is a mapping from column name to
        the cell value.

    deleted_rows : List[int]
        A list of deleted rows, where each row is the numerical position of
        the deleted row.
    z?Required[dict[int, dict[str, str | int | float | bool | None]]]edited_rowsz:Required[list[dict[str, str | int | float | bool | None]]]
added_rowszRequired[list[int]]deleted_rowsN)__name__
__module____qualname____doc____annotations__     p/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/streamlit/elements/widgets/data_editor.pyrA   rA   u   s    $ QPJJ%%rK   rA   F)totalc                       e Zd ZdZddZddZy)DataEditorSerdezKDataEditorSerde is used to serialize and deserialize the data editor state.c                    t        d|i g g dnt        j                  |            }d|vri |d<   d|vrg |d<   d|vrg |d<   |d   j                         D ci c]  \  }}t	        |      | c}}|d<   |S c c}}w )NrA   )rB   rC   rD   rB   rD   rC   )r   jsonloadsitemsint)selfui_valuedata_editor_statekvs        rL   deserializezDataEditorSerde.deserialize   s    *. 	  "  " H%	+
  11/1m,!2202n-00.0l+
 #4M"B"H"H"J,
!QCFAI,
-( ! ,
s   A8c                8    t        j                  |t              S )N)default)rQ   dumpsstr)rU   editing_states     rL   	serializezDataEditorSerde.serialize   s    zz-55rK   N)rV   
str | NonereturnrA   )r_   rA   rb   r^   )rE   rF   rG   rH   rZ   r`   rJ   rK   rL   rO   rO      s    U!:6rK   rO   c                x   | yddl }	 |t        j                  k(  rt        |       rt	        |       S | gS |t        j
                  k(  rt        |       rt	        |       S | S |t        j                  k(  rt        |       S t        | t              rt        d      |t        j                  k(  rt        |       S |t        j                  k(  rt        |       S |t        j                  k(  rt        |       S |t        j                   k(  rt#        t        |             S |t        j$                  k(  r |j&                  |       S |t        j(                  t        j*                  t        j,                  fv r |j.                  |       } |j0                  |      ry|t        j(                  k(  r|S |t        j*                  k(  r|j3                         S |t        j,                  k(  r|j5                         S | S # t6        |j8                  j:                  t        f$ r#}t<        j?                  d| ||       Y d}~yd}~ww xY w)a  Convert a value to the correct type.

    Parameters
    ----------
    value : str | int | float | bool | list[str] | None
        The value to convert.

    column_data_kind : ColumnDataKind
        The determined data kind of the column. The column data kind refers to the
        shared data type of the values in the column (e.g. int, float, str).

    Returns
    -------
    The converted value.
    Nr   zAList values are only supported by list, string and empty columns.zFailed to parse value %s as %s.)exc_info) pandasr   LISTr3   listEMPTYSTRINGr^   
isinstance	TypeErrorINTEGERrT   FLOATfloatBOOLEANboolDECIMALr   	TIMEDELTA	TimedeltaDATETIMEDATETIME	Timestampisnadatetime
ValueErrorerrorsParserErrorr:   warning)valuecolumn_data_kindpddatetime_valueexs        rL   _parse_valuer      s   & }A~222".u"54;BE7B~333 #/u"54;@5@~444u:
 eT"S  ~555u:~333<~555;~555 3u:&&~7772<<&&## 
 

 *R\\%0Nrww~&>#:#::%%>#6#66%**,,>#6#66%**,, L 		--y9 -	 	 	
 sd   (G2 G2 (G2 G2  G2 >8G2 7G2 G2 3&G2 $G2 ?AG2 G2 *"G2 "G2 2$H9H44H9c                n   |j                         D ]  \  }}t        |      }|j                         D ]  \  }}|t        k(  r8| j                  |   }t	        ||t                 }	| j                  ||	id       G| j                  j                  |      }
t	        |||         | j                  ||
f<     y)a  Apply cell edits to the provided dataframe (inplace).

    Parameters
    ----------
    df : pd.DataFrame
        The dataframe to apply the cell edits to.

    edited_rows : Mapping[int, Mapping[str, str | int | float | bool | None]]
        A hierarchical mapping based on row position -> column name -> value

    dataframe_schema: DataframeSchema
        The schema of the dataframe.
    T)indexinplaceN)	rS   rT   r   r   r   renamecolumnsget_lociat)dfrB   dataframe_schemarow_idrow_changesrow_poscol_namer   old_idx_valuenew_idx_valuecol_poss              rL   _apply_cell_editsr     s    (  +002 f+*002 	OHe++ !# 1 ,U4DEU4V W		(-8   
 **,,X6+7+H5,w'(	rK   c                :   d}t        | j                  d         D cg c]  }d }}|j                         D ]Y  \  }}|t        k(  rt	        ||t                 }#t        d| j                  j                  |            }t	        |||         ||<   [ ||fS c c}w )zJParse the added row into an optional index value and a list of row values.N   rT   )rangeshaperS   r   r   r   r   r   )	r   	added_rowr   index_value_new_rowr   r   r   s	            rL   _parse_added_rowr   7  s     K(-bhhqk(:;1$;G;$??, O%'' 'u.>?O.PQK5"**"4"4X">?G+E3CH3MNGGO  <s   	Bc                `    t        t        | j                  |d            | j                  |<   y)zAssign values to a dataframe row via a mapping.

    This avoids numpy attempting to coerce nested sequences (e.g. lists) into
    multi-dimensional arrays when a column legitimately stores list values.
    T)strictN)dictzipr   loc)r   	row_label
row_valuess      rL   _assign_row_valuesr   K  s$     SZEFBFF9rK   c                   |syddl }d}d}d}t        | j                  |j                        r/d}| j                  j                  }| j                  j
                  }nt        | j                  |j                        rr|j                  j                  j                  | j                  j                        r9d}| j                  j                  rdn| j                  j                         dz   }d}|D ]q  }t        | ||      \  }}	||dk7  rt        | ||	       (||t        | ||	       ||z  }?t        j!                  dt#        | j                        j$                         s y)a  Apply row additions to the provided dataframe (inplace).

    Parameters
    ----------
    df : pd.DataFrame
        The dataframe to apply the row additions to.

    added_rows : List[Dict[str, Any]]
        A list of row additions. Each row addition is a dictionary with the
        column position as key and the new cell value as value.

    dataframe_schema: DataframeSchema
        The schema of the dataframe.
    Nr   otherr   integerr   zlCannot automatically add row for the index of type %s without an explicit index value. Row addition skipped.)re   rj   r   
RangeIndexstopstepIndexapitypesis_integer_dtypedtypeemptymaxr   r   r:   r~   typerE   )
r   rC   r   r   
index_type
index_stop
index_stepr   r   r   s
             rL   _apply_row_additionsr   Y  s9   ( 7>J "J!J"((BMM*
XX]]
XX]]
	BHHbhh	'BFFLL,I,I
- 
((..Qbhhllnq.@

 
	/I?OPW"zW'< r;8!j&< r:w7*$J 	PN##	
1
rK   c                D    | j                  | j                  |   d       y)zApply row deletions to the provided dataframe (inplace).

    Parameters
    ----------
    df : pd.DataFrame
        The dataframe to apply the row deletions to.

    deleted_rows : List[int]
        A list of row numbers to delete.
    T)r   N)dropr   )r   rD   s     rL   _apply_row_deletionsr     s     GGBHH\"DG1rK   c                    |j                  d      rt        | |d   |       |j                  d      rt        | |d          |j                  d      rt        | |d   |       yy)a  Apply edits to the provided dataframe (inplace).

    This includes cell edits, row additions and row deletions.

    Parameters
    ----------
    df : pd.DataFrame
        The dataframe to apply the edits to.

    data_editor_state : EditingState
        The editing state of the data editor component.

    dataframe_schema: DataframeSchema
        The schema of the dataframe.
    rB   rD   rC   N)getr   r   r   )r   rW   r   s      rL   _apply_dataframe_editsr     sk    ( ]+"/>@PQ^,R!2>!BC\* 	R!2<!@BRS +rK   c                    ddl }t        |       |j                  |j                  |j                  |j
                  fv xs( t        | d      xs t        | d      xs t        | d      S )zCheck if the index is supported by the data editor component.

    Parameters
    ----------
    df_index : pd.Index
        The index to check.

    Returns
    -------
    bool
        True if the index is supported, False otherwise.
    r   Nz&pandas.core.indexes.numeric.Int64Indexz(pandas.core.indexes.numeric.Float64Indexz'pandas.core.indexes.numeric.UInt64Index)re   r   r   r   DatetimeIndexCategoricalIndexr4   )df_indexr   s     rL   _is_supported_indexr     sx      	XMMHH		

	
 	H 8EF	H 8GH	H 8FG!rK   c           	        ddl }t        | j                  |j                        rK| j                  j	                         D cg c]!  }dj                  t        t        |            # c}| _        y|j                  j                  j                  | j                        dk7  r6| j                  | j                  D ci c]  }|t        |       c}d       yyc c}w c c}w )zeFix the column headers of the provided dataframe inplace to work
    correctly for data editing.
    r   Nr   stringT)r   r   )re   rj   r   
MultiIndexto_flat_indexjoinmapr^   r   r   infer_dtyper   )data_dfr   headercolumns       rL   _fix_column_headersr     s     '//2==1 6=__5R5R5T
+1CHHSf%&
 
	!	!'//	2h	> 	7>GVVS[(G 	 	
 
?
 Hs   &C;Cc                   | j                   j                  ry| j                   | j                   j                            }t        |      dkD  rt	        dt        |       d      t        | j                   v rt	        dt         d      y)zCheck if the column names in the provided dataframe are valid.

    It's not allowed to have duplicate column names or column names that are
    named ``_index``. If the column names are not valid, a ``StreamlitAPIException``
    is raised.
    Nr   zrAll column names are required to be unique for usage with data editor. The following column names are duplicated: z<. Please rename the duplicated columns in the provided data.zThe column name 'zu' is reserved for the index column and can't be used for data columns. Please rename the column in the provided data.)r   r   
duplicatedlenr+   rg   r   )r   duplicated_columnss     rL   _check_column_namesr   
  s      !)C)C)EF
"#::>?Q:R9S TIJ
 	
 7??*# 01 2 
 	
 +rK   c           
     d   t         | j                  fg}|t        | j                               z   D ]~  }t	        |d         }||   }||v s||   }|j                  d      du r4|j                  d      }|H|j                  d      }	|	\t        |	|      du skt        d|	 d	| d
| d       y)a  Check column type to data type compatibility.

    Iterates the index and all columns of the dataframe to check if
    the configured column types are compatible with the underlying data types.

    Parameters
    ----------
    data_df : pd.DataFrame
        The dataframe to check the type compatibilities for.

    columns_config : ColumnConfigMapping
        A mapping of column to column configurations.

    dataframe_schema : DataframeSchema
        The schema of the dataframe.

    Raises
    ------
    StreamlitAPIException
        If a configured column type is editable and not compatible with the
        underlying data type.
    r   disabledTtype_configNr   FzThe configured column type `z` for column `z:` is not compatible for editing the underlying data type `z`.

You have following options to fix this: 1) choose a compatible type 2) disable the column 3) convert the column into a compatible data type.)r   r   rg   rS   r^   r   r   r+   )
r   columns_configr   indicesr   column_namer   column_configr   configured_column_types
             rL   _check_type_compatibilitiesr   (  s    8 !'--01GD11 &)n+K8 .(*;7M  ,4 '++M:K"%0__V%<"%-!"8:JKuT+23I2J K#} %""2!3 4IJ 1rK   c                  z   e Zd Zeddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Zeddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Z ed	      ddddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
       Zedd       Zy)DataEditorMixinstretchautoNfixedF)widthheightuse_container_width
hide_indexcolumn_orderr   num_rowsr   key	on_changeargskwargs
row_heightplaceholderc                    y NrJ   rU   datar   r   r   r   r   r   r   r   r   r   r   r   r   r   s                   rL   data_editorzDataEditorMixin.data_editorh      ( 	rK   c                    y r   rJ   r   s                   rL   r   zDataEditorMixin.data_editor~  r   rK   r   c               	   ddl }ddl}t        |
      }
t        |d       t	        |dddg       t        | j                  |
|dd       |2t        t        d	d
ddd      d       |rd}nt        |t              sd}|t        |      }i }t        j                  |      }|t        j                  j                  k(  r"t!        dt#        |      j$                   d      t        j&                  |d      }t)        |j*                        s,t!        dt#        |j*                        j$                   d      t-        |       t/        |      }|j1                         D ]Q  \  }}t        j2                  |      st5        |t7        |      ddi       |j9                  d      |t;        d|      <   S t=        ||       t?        |       t        |j*                  |j@                        }|s1t5        |tB        ddi       |dv r|du rtD        jG                  d|       ||r|dv rd}|t5        |tB        d|i       t        |	tH              s|	D ]  }t5        ||ddi        |jJ                  jM                  |      }tO        ||jP                        }tS        |||       t        jT                  |      }tW               }tY        d|
d| j                  |||||t7        |      |||      }t[               }||_.        |r||_/        |r||j`                  dd |||_1        |	du |_2        |dk(  r tZ        jf                  jh                  |_5        ni|d k(  r tZ        jf                  jl                  |_5        nD|d!k(  r tZ        jf                  jn                  |_5        ntZ        jf                  jp                  |_5        ts        | j                        |_:        t        jv                  |      rHty        |
xs | j                  j{                               dd" }|j}                  |       t        |||       ||_@        t        ||       t        ||dk7  r|nd#      } t               }!t        |j\                  ||||!j                  |!j                  |d$%      }"t        ||"j                  |       | j                  j                  d&|| '       t        j                  ||      S )(u6/  Display a data editor widget.

        The data editor widget allows you to edit dataframes and many other data structures in a table-like UI.

        Parameters
        ----------
        data : Anything supported by st.dataframe
            The data to edit in the data editor.

            .. note::
                - Styles from ``pandas.Styler`` will only be applied to non-editable columns.
                - Text and number formatting from ``column_config`` always takes
                  precedence over text and number formatting from ``pandas.Styler``.
                - If your dataframe starts with an empty column, you should set
                  the column datatype in the underlying dataframe to ensure your
                  intended datatype, especially for integers versus floats.
                - Mixing data types within a column can make the column uneditable.
                - Additionally, the following data types are not yet supported for editing:
                  ``complex``, ``tuple``, ``bytes``, ``bytearray``,
                  ``memoryview``, ``dict``, ``set``, ``frozenset``,
                  ``fractions.Fraction``, ``pandas.Interval``, and
                  ``pandas.Period``.
                - To prevent overflow in JavaScript, columns containing
                  ``datetime.timedelta`` and ``pandas.Timedelta`` values will
                  default to uneditable, but this can be changed through column
                  configuration.

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

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

        height : "auto", "content", "stretch", or int
            The height of the data editor. This can be one of the following:

            - ``"auto"`` (default): Streamlit sets the height to show at most
              ten rows.
            - ``"content"``: The height of the editor matches the height of
              its content. The height is capped at 10,000 pixels to prevent
              performance issues with very large dataframes.
            - ``"stretch"``: The height of the editor expands to fill the
              available vertical space in its parent container. When multiple
              elements with stretch height are in the same container, they
              share the available vertical space evenly. The editor will
              maintain a minimum height to display up to three rows, but
              otherwise won't exceed the available height in its parent
              container.
            - An integer specifying the height in pixels: The editor has a
              fixed height.

            Vertical scrolling within the editor 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 data editor to match the width of the parent container. If
            this is ``False``, Streamlit sets the data editor's width according
            to ``width``.

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

        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, editing properties like min/max, 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.

        num_rows : "fixed", "dynamic", "add", or "delete"
            Specifies if the user can add and/or delete rows in the data editor.

            - ``"fixed"`` (default): The user can't add or delete rows.
            - ``"dynamic"``: The user can add and delete rows, and column
              sorting is disabled.
            - ``"add"``: The user can only add rows (no deleting), and column
              sorting is disabled.
            - ``"delete"``: The user can only delete rows (no adding), and
              column sorting remains enabled.

        disabled : bool or Iterable[str | int]
            Controls the editing of columns. This can be one of the following:

            - ``False`` (default): All columns that support editing are editable.
            - ``True``: All columns are disabled for editing.
            - An Iterable of column names and/or positional indices: The
              specified columns are disabled for editing while the remaining
              columns are editable where supported. For example,
              ``disabled=["col1", "col2"]`` will disable editing for the
              columns named "col1" and "col2".

            To disable editing for 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 as the unique key for this widget. If this
            is omitted, a key will be generated for the widget based on its
            content. No two widgets may have the same key.

        on_change : callable
            An optional callback invoked when this data_editor's value changes.

        args : list or tuple
            An optional list or tuple of args to pass to the callback.

        kwargs : dict
            An optional dict of kwargs to pass to the callback.

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

        placeholder : str or None
            The text that should be shown for missing values. If this is
            ``None`` (default), missing values are displayed as "None". To
            leave a cell empty, use an empty string (``""``). Other common
            values are ``"null"``, ``"NaN"`` and ``"-"``.

        Returns
        -------
        pandas.DataFrame, pandas.Series, pyarrow.Table, numpy.ndarray, list, set, tuple, or dict.
            The edited data. The edited data is returned in its original data type if
            it corresponds to any of the supported return types. All other data types
            are returned as a ``pandas.DataFrame``.

        Examples
        --------
        **Example 1: Basic usage**

        >>> import pandas as pd
        >>> import streamlit as st
        >>>
        >>> df = pd.DataFrame(
        >>>     [
        >>>         {"command": "st.selectbox", "rating": 4, "is_widget": True},
        >>>         {"command": "st.balloons", "rating": 5, "is_widget": False},
        >>>         {"command": "st.time_input", "rating": 3, "is_widget": True},
        >>>     ]
        >>> )
        >>> edited_df = st.data_editor(df)
        >>>
        >>> favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
        >>> st.markdown(f"Your favorite command is **{favorite_command}** 🎈")

        .. output::
           https://doc-data-editor.streamlit.app/
           height: 350px

        **Example 2: Allowing users to add and delete rows**

        You can allow your users to add and delete rows by setting ``num_rows``
        to "dynamic":

        >>> import streamlit as st
        >>> import pandas as pd
        >>>
        >>> df = pd.DataFrame(
        >>>     [
        >>>         {"command": "st.selectbox", "rating": 4, "is_widget": True},
        >>>         {"command": "st.balloons", "rating": 5, "is_widget": False},
        >>>         {"command": "st.time_input", "rating": 3, "is_widget": True},
        >>>     ]
        >>> )
        >>> edited_df = st.data_editor(df, num_rows="dynamic")
        >>>
        >>> favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
        >>> st.markdown(f"Your favorite command is **{favorite_command}** 🎈")

        .. output::
           https://doc-data-editor1.streamlit.app/
           height: 450px

        **Example 3: Data editor configuration**

        You can customize the data editor via ``column_config``, ``hide_index``,
        ``column_order``, or ``disabled``:

        >>> import pandas as pd
        >>> import streamlit as st
        >>>
        >>> df = pd.DataFrame(
        >>>     [
        >>>         {"command": "st.selectbox", "rating": 4, "is_widget": True},
        >>>         {"command": "st.balloons", "rating": 5, "is_widget": False},
        >>>         {"command": "st.time_input", "rating": 3, "is_widget": True},
        >>>     ]
        >>> )
        >>> edited_df = st.data_editor(
        >>>     df,
        >>>     column_config={
        >>>         "command": "Streamlit Command",
        >>>         "rating": st.column_config.NumberColumn(
        >>>             "Your rating",
        >>>             help="How much do you like this command (1-5)?",
        >>>             min_value=1,
        >>>             max_value=5,
        >>>             step=1,
        >>>             format="%d ⭐",
        >>>         ),
        >>>         "is_widget": "Widget ?",
        >>>     },
        >>>     disabled=["command", "is_widget"],
        >>>     hide_index=True,
        >>> )
        >>>
        >>> favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
        >>> st.markdown(f"Your favorite command is **{favorite_command}** 🎈")


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

        r   NT)allow_contentr   )r   allow_stretchadditional_allowedF)default_valuewrites_allowedr   r   z
2025-12-31znFor `use_container_width=True`, use `width='stretch'`. For `use_container_width=False`, use `width='content'`.)include_st_prefix)show_in_browserr   contentzThe data type (z) or format is not supported by the data editor. Please convert your data into a Pandas Dataframe or another supported data format.)ensure_copyz"The type of the dataframe index - z+ - is not yet supported by the data editor.r   r   r   required)dynamicadda  Setting `hide_index=True` in data editor with a non-range index will not have any effect when `num_rows` is '%s'. It is required for the user to fill in index values for adding new rows. To hide the index, make sure to set the DataFrame index to a range index.hiddenr   )user_keykey_as_main_identitydgr   r   r   r   r   column_config_mappingr   r   r   r   r  delete
   )r   r   string_value)on_change_handlerr   r   deserializer
serializerctx
value_typearrow_data_frame)layout_config)Kre   pyarrowr*   r%   r$   r'   r  r   r   rj   rT   rg   r   determine_data_format
DataFormatUNKNOWNr+   r   rE   convert_anything_to_pandas_dfr   r   r   r   rS    is_colum_type_arrow_incompatibler   r^   astyper   r   r   r   r   r:   r~   rp   Tablefrom_pandasr   schemar   "convert_arrow_table_to_arrow_bytesr.   r)   
ArrowProtoidr   r   r   r   EditingModeDYNAMICediting_modeADD_ONLYDELETE_ONLYFIXEDr    form_idis_pandas_stylerr5   _get_delta_path_strset_uuidr&   r   r   r"   rO   r2   rZ   r`   r   r   _enqueue convert_pandas_df_to_data_format)#rU   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   par  data_formatr   r   column_datahas_range_indexr   arrow_tabler   arrow_bytesr  
element_idprotostyler_uuidr  serdewidget_states#                                      rL   r   zDataEditorMixin.data_editor  s   t 	SkuD1 &x		
 	GG 	
 *$,) N&+ !&
 #!s+!#-L57$::4@.33;;;'!$t*"5"5!6 71 1  !>>tQUV #7==1'4T'--5H5Q5Q4R S4 4  	G$ !7} E )0 	Q$K>>{K$)3{+;j$=O 5@4F4Fx4PUK01	Q 	$$9;G 	G$$W]]BMMB !%'7*d9K --*2D.  /hBT6T J! %'7(J9O (D)" X$%:FZQUDVWX hh**73 6g{?Q?QR 	$G-BDTU$GGT !"4!&ww 3%"%&;"<!#

  )E$0Eq!" +E "T)y !+!7!7!?!?E!+!7!7!@!@E!!+!7!7!C!CE!+!7!7!=!=E'0**40 #3#G$''*E*E*GH"MKMM+&E45 
u&;<
 %&F*:
  !&HH'**%	
 	w(:(:<LM+U-P>>wTTrK   c                    t        d|       S )zGet our DeltaGenerator.r9   )r   )rU   s    rL   r  zDataEditorMixin.dg  s     $d++rK   ) r   r;   r   r#   r   Height | Literal['auto']r   bool | Noner   r7  r   Iterable[str] | Noner   ColumnConfigMappingInput | Noner   ,Literal['fixed', 'dynamic', 'add', 'delete']r   bool | Iterable[str | int]r   
Key | Noner   WidgetCallback | Noner   WidgetArgs | Noner   WidgetKwargs | Noner   
int | Noner   ra   rb   r;   ) r   r   r   r#   r   r6  r   r7  r   r7  r   r8  r   r9  r   r:  r   r;  r   r<  r   r=  r   r>  r   r?  r   r@  r   ra   rb   r=   ) r   r?   r   r#   r   r6  r   r7  r   r7  r   r8  r   r9  r   r:  r   r;  r   r<  r   r=  r   r>  r   r?  r   r@  r   ra   rb   r?   )rb   r9   )rE   rF   rG   r   r   r-   propertyr  rJ   rK   rL   r   r   g  s   
 !+1+/"&-19=AH/4+/"&&*!%"&# 	
 ) )   + 7 ? -  )   $  !"  #$ 
% * 
 !+1+/"&-19=AH/4+/"&&*!%"&# 	
 ) )   + 7 ? -  )   $  !"  #$ 
% * M"
 !+1+/"&-19=AH/4+/"&&*!%"&#vUvU 	vU
 )vU )vU  vU +vU 7vU ?vU -vU vU )vU  vU $vU  !vU"  #vU$ 
%vU #vUp , ,rK   r   )r   z+str | int | float | bool | list[str] | Noner   r   rb   r   )r   r=   rB   zGMapping[int, Mapping[str, str | int | float | bool | list[str] | None]]r   r   rb   None)r   r=   r   zdict[str, Any]r   r   rb   ztuple[Any, list[Any]])r   r=   r   r   r   z	list[Any]rb   rB  )r   r=   rC   zlist[dict[str, Any]]r   r   rb   rB  )r   r=   rD   z	list[int]rb   rB  )r   r=   rW   rA   r   r   rb   rB  )r   r>   rb   rp   )r   r=   rb   rB  )r   r=   r   r   r   r   rb   rB  )q
__future__r   rQ   dataclassesr   decimalr   typingr   r   r   r	   r
   r   r   r   r   r   typing_extensionsr   	streamlitr   r   _loggerstreamlit.deprecation_utilr   r   *streamlit.elements.lib.column_config_utilsr   r   r   r   r   r   r   r   r   r   r   !streamlit.elements.lib.form_utilsr    #streamlit.elements.lib.layout_utilsr!   r"   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,   r  streamlit.runtime.metrics_utilr-   7streamlit.runtime.scriptrunner_utils.script_run_contextr.   streamlit.runtime.stater/   r0   r1   r2   streamlit.type_utilr3   r4   streamlit.utilr5   collections.abcr6   r7   numpynpre   r   r  r*  pandas.io.formats.styler8   streamlit.delta_generatorr9   
get_loggerrE   r:   rI   DataFrameGenericAliastuplerg   setr   r^   r;   r?   rA   rO   r   r   r   r   r   r   r   r   r   r   r   r   rJ   rK   rL   <module>ra     s   #  !    ' $ '    >  G A U U 2 9 9 V  6 #1.8###H- - 

.
.s
3Cj
3i 
#h 38n	 +	#JIHcN		9 &9E &0 !6 !6 !6HZ6Z$Z 	Zz%%%
 &% 
%P    &  	 (GGG G 
	GH
H
$H
 &H
 
	H
V2TT#T &T 
	T@ F
(
<<<'< &< 
	<~i, i,rK   