Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pandas/core/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pandas/core/__pycache__/indexing.cpython-312.pyc

�

Mٜg�{���ddlmZddlmZddlZddlmZmZmZm	Z	m
Z
ddlZddlZ
ddlmZmZddlmZddlmZddlmZdd	lmZmZmZmZmZmZmZmZdd
l m!Z!ddl"m#Z#ddl$m%Z%m&Z&dd
l'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8ddl9m:Z:m;Z;m<Z<m=Z=m>Z>ddl?m@ZAddlBmCcmDZEddlFmGZHmIZIddlJmKZKmLZLmMZMmNZNddlOmPZPmQZQerddlRmSZSmTZTddlUmVZVmWZWmXZXmYZYddlZm[Z[m\Z\ed�Z]e^dd�Z_dZ`Gd�d�Zaea�ZbGd�d�ZcGd�d e�Zde!ecj��Gd!�d"ed��Zfe!ecj��Gd#�d$ed��ZhGd%�d&e�Zie!ecj��Gd'�d(ei��Zke!ecj��Gd)�d*ei��Zmd5d+�Znd6d,�Zod7d-�Zpd.�Zqd/�Zrd0�Zsd8d1�Ztd8d2�Zud9d3�Zvd:d4�Zwy);�)�annotations)�suppressN)�
TYPE_CHECKING�Any�TypeVar�cast�final)�using_copy_on_write�warn_copy_on_write)�NDFrameIndexerBase)�item_from_zerodim)�PYPY)�AbstractMethodError�ChainedAssignmentError�
IndexingError�InvalidIndexError�LossySetitemError�_chained_assignment_msg�_chained_assignment_warning_msg�
_check_cacher)�doc)�find_stack_level)�can_hold_element�
maybe_promote)
�
is_array_like�
is_bool_dtype�is_hashable�
is_integer�is_iterator�is_list_like�is_numeric_dtype�is_object_dtype�	is_scalar�is_sequence)�
concat_compat)�ExtensionDtype)�ABCDataFrame�	ABCSeries)�+construct_1d_array_from_inferred_fill_value�infer_fill_value�is_valid_na_for_dtype�isna�na_value_for_dtype)�
algorithms)�array�
extract_array)�check_array_indexer�is_list_like_indexer�is_scalar_indexer�length_of_indexer)�Index�
MultiIndex)�Hashable�Sequence)�Axis�AxisInt�Self�npt)�	DataFrame�Series�Tz(indexer may only contain one '...' entryc��eZdZdZd�Zy)�_IndexSlicea
    Create an object to more easily perform multi-index slicing.

    See Also
    --------
    MultiIndex.remove_unused_levels : New MultiIndex with no unused levels.

    Notes
    -----
    See :ref:`Defined Levels <advanced.shown_levels>`
    for further info on slicing a MultiIndex.

    Examples
    --------
    >>> midx = pd.MultiIndex.from_product([['A0','A1'], ['B0','B1','B2','B3']])
    >>> columns = ['foo', 'bar']
    >>> dfmi = pd.DataFrame(np.arange(16).reshape((len(midx), len(columns))),
    ...                     index=midx, columns=columns)

    Using the default slice command:

    >>> dfmi.loc[(slice(None), slice('B0', 'B1')), :]
               foo  bar
        A0 B0    0    1
           B1    2    3
        A1 B0    8    9
           B1   10   11

    Using the IndexSlice class for a more intuitive command:

    >>> idx = pd.IndexSlice
    >>> dfmi.loc[idx[:, 'B0':'B1'], :]
               foo  bar
        A0 B0    0    1
           B1    2    3
        A1 B0    8    9
           B1   10   11
    c��|S�N�)�self�args  �?/usr/local/lib/python3.12/site-packages/pandas/core/indexing.py�__getitem__z_IndexSlice.__getitem__�s���
�N)�__name__�
__module__�__qualname__�__doc__rHrDrIrGrArAms
��%�NrIrAc�X�eZdZdZedd��Zedd��Zed	d��Zed
d��Zy)�
IndexingMixinzH
    Mixin for adding .loc/.iloc/.at/.iat to Dataframes and Series.
    c��td|�S)a>
        Purely integer-location based indexing for selection by position.

        .. deprecated:: 2.2.0

           Returning a tuple from a callable is deprecated.

        ``.iloc[]`` is primarily integer position based (from ``0`` to
        ``length-1`` of the axis), but may also be used with a boolean
        array.

        Allowed inputs are:

        - An integer, e.g. ``5``.
        - A list or array of integers, e.g. ``[4, 3, 0]``.
        - A slice object with ints, e.g. ``1:7``.
        - A boolean array.
        - A ``callable`` function with one argument (the calling Series or
          DataFrame) and that returns valid output for indexing (one of the above).
          This is useful in method chains, when you don't have a reference to the
          calling object, but would like to base your selection on
          some value.
        - A tuple of row and column indexes. The tuple elements consist of one of the
          above inputs, e.g. ``(0, 1)``.

        ``.iloc`` will raise ``IndexError`` if a requested indexer is
        out-of-bounds, except *slice* indexers which allow out-of-bounds
        indexing (this conforms with python/numpy *slice* semantics).

        See more at :ref:`Selection by Position <indexing.integer>`.

        See Also
        --------
        DataFrame.iat : Fast integer location scalar accessor.
        DataFrame.loc : Purely label-location based indexer for selection by label.
        Series.iloc : Purely integer-location based indexing for
                       selection by position.

        Examples
        --------
        >>> mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4},
        ...           {'a': 100, 'b': 200, 'c': 300, 'd': 400},
        ...           {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000}]
        >>> df = pd.DataFrame(mydict)
        >>> df
              a     b     c     d
        0     1     2     3     4
        1   100   200   300   400
        2  1000  2000  3000  4000

        **Indexing just the rows**

        With a scalar integer.

        >>> type(df.iloc[0])
        <class 'pandas.core.series.Series'>
        >>> df.iloc[0]
        a    1
        b    2
        c    3
        d    4
        Name: 0, dtype: int64

        With a list of integers.

        >>> df.iloc[[0]]
           a  b  c  d
        0  1  2  3  4
        >>> type(df.iloc[[0]])
        <class 'pandas.core.frame.DataFrame'>

        >>> df.iloc[[0, 1]]
             a    b    c    d
        0    1    2    3    4
        1  100  200  300  400

        With a `slice` object.

        >>> df.iloc[:3]
              a     b     c     d
        0     1     2     3     4
        1   100   200   300   400
        2  1000  2000  3000  4000

        With a boolean mask the same length as the index.

        >>> df.iloc[[True, False, True]]
              a     b     c     d
        0     1     2     3     4
        2  1000  2000  3000  4000

        With a callable, useful in method chains. The `x` passed
        to the ``lambda`` is the DataFrame being sliced. This selects
        the rows whose index label even.

        >>> df.iloc[lambda x: x.index % 2 == 0]
              a     b     c     d
        0     1     2     3     4
        2  1000  2000  3000  4000

        **Indexing both axes**

        You can mix the indexer types for the index and columns. Use ``:`` to
        select the entire axis.

        With scalar integers.

        >>> df.iloc[0, 1]
        2

        With lists of integers.

        >>> df.iloc[[0, 2], [1, 3]]
              b     d
        0     2     4
        2  2000  4000

        With `slice` objects.

        >>> df.iloc[1:3, 0:3]
              a     b     c
        1   100   200   300
        2  1000  2000  3000

        With a boolean array whose length matches the columns.

        >>> df.iloc[:, [True, False, True, False]]
              a     c
        0     1     3
        1   100   300
        2  1000  3000

        With a callable function that expects the Series or DataFrame.

        >>> df.iloc[:, lambda df: [0, 2]]
              a     c
        0     1     3
        1   100   300
        2  1000  3000
        �iloc)�_iLocIndexer�rEs rGrQzIndexingMixin.iloc�s��\�F�D�)�)rIc��td|�S)a�'
        Access a group of rows and columns by label(s) or a boolean array.

        ``.loc[]`` is primarily label based, but may also be used with a
        boolean array.

        Allowed inputs are:

        - A single label, e.g. ``5`` or ``'a'``, (note that ``5`` is
          interpreted as a *label* of the index, and **never** as an
          integer position along the index).
        - A list or array of labels, e.g. ``['a', 'b', 'c']``.
        - A slice object with labels, e.g. ``'a':'f'``.

          .. warning:: Note that contrary to usual python slices, **both** the
              start and the stop are included

        - A boolean array of the same length as the axis being sliced,
          e.g. ``[True, False, True]``.
        - An alignable boolean Series. The index of the key will be aligned before
          masking.
        - An alignable Index. The Index of the returned selection will be the input.
        - A ``callable`` function with one argument (the calling Series or
          DataFrame) and that returns valid output for indexing (one of the above)

        See more at :ref:`Selection by Label <indexing.label>`.

        Raises
        ------
        KeyError
            If any items are not found.
        IndexingError
            If an indexed key is passed and its index is unalignable to the frame index.

        See Also
        --------
        DataFrame.at : Access a single value for a row/column label pair.
        DataFrame.iloc : Access group of rows and columns by integer position(s).
        DataFrame.xs : Returns a cross-section (row(s) or column(s)) from the
                       Series/DataFrame.
        Series.loc : Access group of values using labels.

        Examples
        --------
        **Getting values**

        >>> df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
        ...                   index=['cobra', 'viper', 'sidewinder'],
        ...                   columns=['max_speed', 'shield'])
        >>> df
                    max_speed  shield
        cobra               1       2
        viper               4       5
        sidewinder          7       8

        Single label. Note this returns the row as a Series.

        >>> df.loc['viper']
        max_speed    4
        shield       5
        Name: viper, dtype: int64

        List of labels. Note using ``[[]]`` returns a DataFrame.

        >>> df.loc[['viper', 'sidewinder']]
                    max_speed  shield
        viper               4       5
        sidewinder          7       8

        Single label for row and column

        >>> df.loc['cobra', 'shield']
        2

        Slice with labels for row and single label for column. As mentioned
        above, note that both the start and stop of the slice are included.

        >>> df.loc['cobra':'viper', 'max_speed']
        cobra    1
        viper    4
        Name: max_speed, dtype: int64

        Boolean list with the same length as the row axis

        >>> df.loc[[False, False, True]]
                    max_speed  shield
        sidewinder          7       8

        Alignable boolean Series:

        >>> df.loc[pd.Series([False, True, False],
        ...                  index=['viper', 'sidewinder', 'cobra'])]
                             max_speed  shield
        sidewinder          7       8

        Index (same behavior as ``df.reindex``)

        >>> df.loc[pd.Index(["cobra", "viper"], name="foo")]
               max_speed  shield
        foo
        cobra          1       2
        viper          4       5

        Conditional that returns a boolean Series

        >>> df.loc[df['shield'] > 6]
                    max_speed  shield
        sidewinder          7       8

        Conditional that returns a boolean Series with column labels specified

        >>> df.loc[df['shield'] > 6, ['max_speed']]
                    max_speed
        sidewinder          7

        Multiple conditional using ``&`` that returns a boolean Series

        >>> df.loc[(df['max_speed'] > 1) & (df['shield'] < 8)]
                    max_speed  shield
        viper          4       5

        Multiple conditional using ``|`` that returns a boolean Series

        >>> df.loc[(df['max_speed'] > 4) | (df['shield'] < 5)]
                    max_speed  shield
        cobra               1       2
        sidewinder          7       8

        Please ensure that each condition is wrapped in parentheses ``()``.
        See the :ref:`user guide<indexing.boolean>`
        for more details and explanations of Boolean indexing.

        .. note::
            If you find yourself using 3 or more conditionals in ``.loc[]``,
            consider using :ref:`advanced indexing<advanced.advanced_hierarchical>`.

            See below for using ``.loc[]`` on MultiIndex DataFrames.

        Callable that returns a boolean Series

        >>> df.loc[lambda df: df['shield'] == 8]
                    max_speed  shield
        sidewinder          7       8

        **Setting values**

        Set value for all items matching the list of labels

        >>> df.loc[['viper', 'sidewinder'], ['shield']] = 50
        >>> df
                    max_speed  shield
        cobra               1       2
        viper               4      50
        sidewinder          7      50

        Set value for an entire row

        >>> df.loc['cobra'] = 10
        >>> df
                    max_speed  shield
        cobra              10      10
        viper               4      50
        sidewinder          7      50

        Set value for an entire column

        >>> df.loc[:, 'max_speed'] = 30
        >>> df
                    max_speed  shield
        cobra              30      10
        viper              30      50
        sidewinder         30      50

        Set value for rows matching callable condition

        >>> df.loc[df['shield'] > 35] = 0
        >>> df
                    max_speed  shield
        cobra              30      10
        viper               0       0
        sidewinder          0       0

        Add value matching location

        >>> df.loc["viper", "shield"] += 5
        >>> df
                    max_speed  shield
        cobra              30      10
        viper               0       5
        sidewinder          0       0

        Setting using a ``Series`` or a ``DataFrame`` sets the values matching the
        index labels, not the index positions.

        >>> shuffled_df = df.loc[["viper", "cobra", "sidewinder"]]
        >>> df.loc[:] += shuffled_df
        >>> df
                    max_speed  shield
        cobra              60      20
        viper               0      10
        sidewinder          0       0

        **Getting values on a DataFrame with an index that has integer labels**

        Another example using integers for the index

        >>> df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
        ...                   index=[7, 8, 9], columns=['max_speed', 'shield'])
        >>> df
           max_speed  shield
        7          1       2
        8          4       5
        9          7       8

        Slice with integer labels for rows. As mentioned above, note that both
        the start and stop of the slice are included.

        >>> df.loc[7:9]
           max_speed  shield
        7          1       2
        8          4       5
        9          7       8

        **Getting values with a MultiIndex**

        A number of examples using a DataFrame with a MultiIndex

        >>> tuples = [
        ...     ('cobra', 'mark i'), ('cobra', 'mark ii'),
        ...     ('sidewinder', 'mark i'), ('sidewinder', 'mark ii'),
        ...     ('viper', 'mark ii'), ('viper', 'mark iii')
        ... ]
        >>> index = pd.MultiIndex.from_tuples(tuples)
        >>> values = [[12, 2], [0, 4], [10, 20],
        ...           [1, 4], [7, 1], [16, 36]]
        >>> df = pd.DataFrame(values, columns=['max_speed', 'shield'], index=index)
        >>> df
                             max_speed  shield
        cobra      mark i           12       2
                   mark ii           0       4
        sidewinder mark i           10      20
                   mark ii           1       4
        viper      mark ii           7       1
                   mark iii         16      36

        Single label. Note this returns a DataFrame with a single index.

        >>> df.loc['cobra']
                 max_speed  shield
        mark i          12       2
        mark ii          0       4

        Single index tuple. Note this returns a Series.

        >>> df.loc[('cobra', 'mark ii')]
        max_speed    0
        shield       4
        Name: (cobra, mark ii), dtype: int64

        Single label for row and column. Similar to passing in a tuple, this
        returns a Series.

        >>> df.loc['cobra', 'mark i']
        max_speed    12
        shield        2
        Name: (cobra, mark i), dtype: int64

        Single tuple. Note using ``[[]]`` returns a DataFrame.

        >>> df.loc[[('cobra', 'mark ii')]]
                       max_speed  shield
        cobra mark ii          0       4

        Single tuple for the index with a single label for the column

        >>> df.loc[('cobra', 'mark i'), 'shield']
        2

        Slice from index tuple to single label

        >>> df.loc[('cobra', 'mark i'):'viper']
                             max_speed  shield
        cobra      mark i           12       2
                   mark ii           0       4
        sidewinder mark i           10      20
                   mark ii           1       4
        viper      mark ii           7       1
                   mark iii         16      36

        Slice from index tuple to index tuple

        >>> df.loc[('cobra', 'mark i'):('viper', 'mark ii')]
                            max_speed  shield
        cobra      mark i          12       2
                   mark ii          0       4
        sidewinder mark i          10      20
                   mark ii          1       4
        viper      mark ii          7       1

        Please see the :ref:`user guide<advanced.advanced_hierarchical>`
        for more details and explanations of advanced indexing.
        �loc)�_LocIndexerrSs rGrUzIndexingMixin.loc1s��`	�5�$�'�'rIc��td|�S)aq
        Access a single value for a row/column label pair.

        Similar to ``loc``, in that both provide label-based lookups. Use
        ``at`` if you only need to get or set a single value in a DataFrame
        or Series.

        Raises
        ------
        KeyError
            If getting a value and 'label' does not exist in a DataFrame or Series.

        ValueError
            If row/column label pair is not a tuple or if any label
            from the pair is not a scalar for DataFrame.
            If label is list-like (*excluding* NamedTuple) for Series.

        See Also
        --------
        DataFrame.at : Access a single value for a row/column pair by label.
        DataFrame.iat : Access a single value for a row/column pair by integer
            position.
        DataFrame.loc : Access a group of rows and columns by label(s).
        DataFrame.iloc : Access a group of rows and columns by integer
            position(s).
        Series.at : Access a single value by label.
        Series.iat : Access a single value by integer position.
        Series.loc : Access a group of rows by label(s).
        Series.iloc : Access a group of rows by integer position(s).

        Notes
        -----
        See :ref:`Fast scalar value getting and setting <indexing.basics.get_value>`
        for more details.

        Examples
        --------
        >>> df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
        ...                   index=[4, 5, 6], columns=['A', 'B', 'C'])
        >>> df
            A   B   C
        4   0   2   3
        5   0   4   1
        6  10  20  30

        Get value at specified row/column pair

        >>> df.at[4, 'B']
        2

        Set value at specified row/column pair

        >>> df.at[4, 'B'] = 10
        >>> df.at[4, 'B']
        10

        Get value within a Series

        >>> df.loc[5].at['B']
        4
        �at)�
_AtIndexerrSs rGrXzIndexingMixin.atcs��~�$��%�%rIc��td|�S)a�
        Access a single value for a row/column pair by integer position.

        Similar to ``iloc``, in that both provide integer-based lookups. Use
        ``iat`` if you only need to get or set a single value in a DataFrame
        or Series.

        Raises
        ------
        IndexError
            When integer position is out of bounds.

        See Also
        --------
        DataFrame.at : Access a single value for a row/column label pair.
        DataFrame.loc : Access a group of rows and columns by label(s).
        DataFrame.iloc : Access a group of rows and columns by integer position(s).

        Examples
        --------
        >>> df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
        ...                   columns=['A', 'B', 'C'])
        >>> df
            A   B   C
        0   0   2   3
        1   0   4   1
        2  10  20  30

        Get value at specified row/column pair

        >>> df.iat[1, 2]
        1

        Set value at specified row/column pair

        >>> df.iat[1, 2] = 10
        >>> df.iat[1, 2]
        10

        Get value within a series

        >>> df.loc[0].iat[1]
        2
        �iat)�_iAtIndexerrSs rGr[zIndexingMixin.iat�s��\�5�$�'�'rIN)�returnrR)r]rV)r]rY)r]r\)	rJrKrLrM�propertyrQrUrXr[rDrIrGrOrO�s^����M*��M*�^�o(��o(�b	�>&��>&�@�-(��-(rIrOc�j�eZdZUded<dZded<ded<eddd��Zd	�Zed
��Zed d!d��Z	ed!d��Z
d"d
�Zed#d��Zed$d��Z
ed%d��Zed$d��Zed$d��Zed&d��Zed&d��Zed&d��Zd"d�Zd'd�Zed��Zd(d�Zd&d�Zd"d�Zd)d�Zed"d��Zy)*�_LocationIndexer�str�_valid_typesNzAxisInt | None�axis�bool�	_takeablec��t|�|j|j�}|�|jj|�}n|}||_|SrC)�type�name�obj�_get_axis_numberrc)rErc�new_self�
axis_int_nones    rG�__call__z_LocationIndexer.__call__�sI���4��:�d�i�i����2���� �H�H�5�5�d�;�M� �M�%��
��rIc���|jdk(r|j|�t|t�r|D]
}t	|��|j
�!t
|j|j
|�}|jjd�}t|t�rY|jdk7rJt|�r?t|t�s/ttt�5|j!|�cddd�St|t�r*tt"�5|j%|�cddd�St|t&�rt)|�}|j+|d��S#1swY�qxYw#1swY�CxYw)zR
        Convert a potentially-label-based key into a positional indexer.
        rUNrrQ�rc)rh�_ensure_listlike_indexer�
isinstance�tuple�check_dict_or_set_indexersrc�_tupleize_axis_indexer�ndimri�	_get_axisr6r�slicer�KeyErrorr�get_locr�_convert_tuple�range�list�_convert_to_indexer)rE�key�x�axs    rG�_get_setitem_indexerz%_LocationIndexer._get_setitem_indexer�s���9�9����)�)�#�.��c�5�!���*�1�-���9�9� �(����D�I�I�s�C�C�
�X�X�
�
��
"��
�r�:�&��	�	�V�#��C� ��s�E�*��(�$5�6��z�z�#��7�6��c�5�!��-�(��*�*�3�/�)�(��c�5�!��s�)�C��'�'��!�'�4�4�7�6��
)�(�s�E�E(�E%�(E1c�v�t|t��r}t|�dk(�rnt|ttf��rW|\}}|j
}t
j|��r,t|�t|�k(�r|j�d}t||j
dz
�r3|dk(r.|jjj||�}||f}||fSt|tj�r�|jj dk(r�t|�dk(rt|dk(r.|jjj||�}||f}||fS|dk(r<|j"ddk(r*|jjj%||�}||f}||fSt
j|�r|j�d}||fS)a
        If we have obj.iloc[mask] = series_or_frame and series_or_frame has the
        same length as obj, we treat this as obj.iloc[mask] = series_or_frame[mask],
        similar to Series.__setitem__.

        Note this is only for loc, not iloc.
        �r��i)rqrr�lenr(r'ru�com�is_bool_indexer�nonzeror3rirQ�
_align_series�np�ndarray�dtype�kind�shape�_align_frame)rE�indexer�value�pi�icolsru�newkeys       rG�_maybe_mask_setitem_valuez*_LocationIndexer._maybe_mask_setitem_values���
�w��&��G���!��5�9�l�";�<��I�B���:�:�D��"�"�2�&�3�u�:��R��+@�����a���$�U�D�I�I��M�:�t�q�y�!�H�H�M�M�7�7���G�E�%�u�o�G�*��~��%�u�b�j�j�1����(�(�C�/��E�
�a���q�y�!%���
�
� ;� ;�G�U� K��#)�5�/����~�����u�{�{�1�~��':� $���
�
� :� :�7�E� J��#)�5�/����~���
 �
 ��
)��o�o�'��*�G���~�rIc��d}|jdk7ryt|t�rt|�dkDr||}|}||k(�r�t|jj
t��s^t|��rQtj|��s:td�|D���r&|jj
j|d��}t|�j|jj
d��}t|�r�tjt|�tj ��}d|t|jj
�d|jj"j%||d	d
d
��}||j_y|jj"j'|d	d
��|j_yyyyyy)
a
        Ensure that a list-like of column labels are all present by adding them if
        they do not already exist.

        Parameters
        ----------
        key : list-like of column labels
            Target labels.
        axis : key axis if known
        r�r�Nc3�2K�|]}t|����y�wrC)r��.0�ks  rG�	<genexpr>z<_LocationIndexer._ensure_listlike_indexer.<locals>.<genexpr>Zs����0�C�q�K��N�C���F)�sort�r����rT)r�rc�
only_slice�use_na_proxy)rcr�)rurqrrr�ri�columnsr6r2r�r��all�unionr5�
differencer��arange�intp�_mgr�reindex_indexer�reindex_axis)	rEr~rcr��column_axis�keys�diffr��new_mgrs	         rGrpz)_LocationIndexer._ensure_listlike_indexer=sy�����9�9��>���c�5�!�c�#�h��l��k�"�C��D�
�K���t�x�x�/�/��<�$�S�)��'�'��,��0�C�0�0��8�8�#�#�)�)�#�E�)�:�D���:�(�(����)9�)9��(�F�D��4�y��)�)�C��I�R�W�W�=��35���D�H�H�,�,�-�/�0��(�(�-�-�7�7��'��d�QU�8���!(����
�� �H�H�M�M�6�6�t�!�PT�6�U�D�H�H�M�-1�-�*�=�
 rIc�T��tsMt�rCtj�j�dkr�tjttd��nztstt�sjtj�j�}d}t�st�j�r|dz
}||kr tjttd��t|�t|t�r'td�|D��}t�fd�|D��}n2t!j"|�j�}�j%||�}�j'|�}�j)|��j*dk(r�n�jj,}|j/||�j*�y)Nr���
stacklevelr�c3�LK�|]}t|�rt|�n|���y�wrC�rr|�r�rs  rGr�z/_LocationIndexer.__setitem__.<locals>.<genexpr>�� ����F�#�Q�;�q�>��Q��q�8�#���"$c3�^�K�|]$}tj|�j����&y�wrC�r��apply_if_callableri�r�rrEs  �rGr�z/_LocationIndexer.__setitem__.<locals>.<genexpr>��#�����H�C�q��-�-�a����:�C���*-rQ)rr
�sys�getrefcountri�warnings�warnrrrrr�
FutureWarningrsrqrrr�r�� _check_deprecated_callable_usager��_has_valid_setitem_indexerrhrQ�_setitem_with_indexer)rEr~r��ctr�	ref_count�maybe_callabler�rQs`       rG�__setitem__z_LocationIndexer.__setitem__rs7����+�-����t�x�x�(�A�-��
�
�+�-C�PQ���1�3��/�/�$�(�(�+�C��I�%�'�M�$�(�(�,C��Q��	��i���
�
�3�]�q��	#�3�'��c�5�!��F�#�F�F�C��H�C�H�H�C� �2�2�3����A�N��7�7��^�L�C��+�+�C�0���'�'��,��y�y�F�*�t����
�
���"�"�7�E�4�9�9�=rIc��t|��)a�
        Ensure that key is valid for current indexer.

        Parameters
        ----------
        key : scalar, slice or list-like
            Key requested.
        axis : int
            Dimension on which the indexing is being made.

        Raises
        ------
        TypeError
            If the key (or some element of it) has wrong type.
        IndexError
            If the key (or some element of it) is out of bounds.
        KeyError
            If the key was not found.
        �r�rEr~rcs   rG�
_validate_keyz_LocationIndexer._validate_key�s��("�$�'�'rIc��td�|D��rl|jt�dkDrtt��t|�|jk(r-|jt�}|d|tfz||dzdz}|S|S)zt
        If a tuple key includes an Ellipsis, replace it with an appropriate
        number of null slices.
        c3�,K�|]}|tu���y�wrC)�Ellipsisr�s  rGr�z4_LocationIndexer._expand_ellipsis.<locals>.<genexpr>�s����*�c��q�H�}�c�s�r�N)	�any�countr�r�_one_ellipsis_messager�ru�index�_NS)rE�tupr��new_keys    rG�_expand_ellipsisz!_LocationIndexer._expand_ellipsis�s|���*�c�*�*��y�y��"�Q�&�#�$9�:�:��3�x�4�9�9�$��I�I�h�'���b�q�'�S�F�*�S��Q���\�9�����
rIc���|j|�}|j|�}t|�D]\}}	|j||��|S#t$r}t	d|j
�d��|�d}~wwxYw)zA
        Check the key for valid keys across my indexer.
        z'Location based indexing can only have [z] typesN)�_validate_key_lengthr��	enumerater��
ValueErrorrb)rEr~r�r��errs     rG�_validate_tuple_indexerz(_LocationIndexer._validate_tuple_indexer�s���
�'�'��,���#�#�C�(���c�N�D�A�q�
��"�"�1�a�(�#��
���
� ���)�)�*�'�3�����
�s�A�	A3�A.�.A3c���td�|jjD��r(t�fd�|jjD��Sy)�6
        Returns
        -------
        bool
        c3�<K�|]}t|t����y�wrC)rqr6)r�r�s  rGr�z<_LocationIndexer._is_nested_tuple_indexer.<locals>.<genexpr>�s����B�M�b�z�"�j�)�M���c3�6�K�|]}t�|����y�wrC)�is_nested_tuple)r�r�r�s  �rGr�z<_LocationIndexer._is_nested_tuple_indexer.<locals>.<genexpr>�s�����H�-�B��s�B�/�-���F)r�ri�axes�rEr�s `rG�_is_nested_tuple_indexerz)_LocationIndexer._is_nested_tuple_indexer�s7����B�D�H�H�M�M�B�B��H�$�(�(�-�-�H�H�H�rIc��|j|�t|�D��cgc]\}}|j||����}}}t|�Scc}}w�Nro)r�r�r}rr)rEr~r�r��keyidxs     rGrzz_LocationIndexer._convert_tuple�sN��	
�!�!�#�&�BK�C�.�Q�.�$�!�Q�$�*�*�1�1�*�5�.��Q��V�}���Rs�Ac��t|�|jkDrC|dtur-|dd}t|vrtt��|j|�Std��|S)Nrr��Too many indexers)r�rur�rr�r��rEr~s  rGr�z%_LocationIndexer._validate_key_length�s^���s�8�d�i�i���1�v��!��!�"�g���s�?�'�(=�>�>��0�0��5�5�� 3�4�4��
rIc��|j}|jt|�z
dz}tt	|��D]o\}}|j|z
|z
}tj|�r�.t||j�j||��}|j|jk(r�oJ�||jur|jd��}|S)z�
        Index with indexers that should return an object of the same dimension
        as self.obj.

        This is only called after a failed call to _getitem_lowerdim.
        r�roF��deep)rirur�r��reversedr��
is_null_slice�getattrrh�
_getitem_axis�copy)rEr��retval�	start_valr�r~s      rG�_getitem_tuple_same_dimz(_LocationIndexer._getitem_tuple_same_dim�s��������Y�Y��S��)�Q�.�	����
�.�F�A�s��	�	�A�
�	�)�A�� � ��%���V�T�Y�Y�/�=�=�c��=�J�F��;�;�$�)�)�+�+�+�/��T�X�X���[�[�e�[�,�F��
rIc��|j�8|jj|j�}|j||��S|j	|�r|j|�S|jj
d�}t|t�rY|jdk7rJtd�|D��s8tt�5tt|�j|�cddd�S|j!|�}t#|�D]�\}}t%|�s�|j||��}|j&|j&k(r|d|t(fz||dzdz}n!|d|||dzdz}t+|�dk(r|d}t-j.|�r|cSt1||j�|cStd��#1swY��xYw)NrorrQc3�<K�|]}t|t����y�wrC�rqrwr�s  rGr�z5_LocationIndexer._getitem_lowerdim.<locals>.<genexpr>s����:�c��
�1�e�,�c�r�r�znot applicable)rcrirjr�r��_getitem_nested_tuplervrqr6rhr�rrrrV�"_handle_lowerdim_multi_index_axis0r�r��
is_label_likerur�r�r�r�r�)rEr�rc�ax0r�r~�sectionr�s        rG�_getitem_lowerdimz"_LocationIndexer._getitem_lowerdims����9�9� ��8�8�,�,�T�Y�Y�7�D��%�%�c��%�5�5��(�(��-��-�-�c�2�2��h�h� � ��#��
�s�J�'��	�	�V�#��:�c�:�:��-�(��K��.�Q�Q�RU�V�)�(��'�'��,����n�F�A�s��S�!��,�,�S�q�,�9��
�<�<�4�9�9�,�"�"�1�g���.��Q��U�W��=�G�"�"�1�g��A��E�G��4�G��7�|�q�(�")�!�*���$�$�W�-�"�N��w��	�	�2�7�;�;�9%�<�,�-�-�G)�(�s�F=�=Gc���dd��|D]
}t|��t|�|jkDr�|jdk7rt	d��t�fd�|D��r8t
t�5tt|�j|�cddd�St|jt�rtd�|D��rtd��|jxsd}|j!||��S|j}t|�d	z
}|ddd
�D]c}t#j$|�r|d	z}�t'||j�j!||��}|d	z}t)|�s
t+|d�r�b|S|S#1swY��xYw)
Nc�j�t|t�rtd�|D��St|t�ryy)Nc3�<K�|]}t|t����y�wrCr��r��vs  rGr�zR_LocationIndexer._getitem_nested_tuple.<locals>._contains_slice.<locals>.<genexpr>Ms����;��A�:�a��/��r�TF)rqrrr�rw)rs rG�_contains_slicez?_LocationIndexer._getitem_nested_tuple.<locals>._contains_sliceJs-���!�U�#��;��;�;�;��A�u�%��rIrUzToo many indicesc3�x�K�|]1}t|�xr	�|�xstj|����3y�wrC)rr�r�)r�rrs  �rGr�z9_LocationIndexer._getitem_nested_tuple.<locals>.<genexpr>\s>�������A��Q��:���(:�$:�S�s�?P�?P�QR�?S�S��s�7:c3�<K�|]}t|t����y�wrC�rqrrr�s  rGr�z9_LocationIndexer._getitem_nested_tuple.<locals>.<genexpr>gs����9�.1��
�1�e�$�c�r�r�rror�r�ru)r�objectr]rd)rsr�rurhr�r�rrrrVr�rqrir(r�rcr�r�r�r�r#�hasattr)rEr�r~rcrirs     @rGr�z&_LocationIndexer._getitem_nested_tupleEsv���
	��C�&�s�+���s�8�d�i�i���y�y�E�!� �!3�4�4�������m�,���T�2�U�U���-�,��D�H�H�i�0�S�9�.1�9�6�$�$7�8�8��9�9�>��D��%�%�c��%�5�5��h�h���3�x�!�|���t��t�9�C�� � ��%���	����#�t�y�y�)�7�7��$�7�G�C��A�I�D���~�W�S�&�%9���
���
�K-�,�s�-E:�:Fc��t|��rCr�r�s   rGr}z$_LocationIndexer._convert_to_indexer��
��!�$�'�'rIc��|jdk(r?t|�r4t|t�r$t	j
dtt���|S)NrQzaReturning a tuple from a callable with iloc is deprecated and will be removed in a future versionr�)rh�callablerqrrr�r�r�r)rEr~r�s   rGr�z1_LocationIndexer._check_deprecated_callable_usage�sA���9�9���8�C�=�Z��PU�5V��M�M�H��+�-�	
��rIc����t|�t|�turntd�|D��}t�fd�|D��}�j|�r&�jj
|d�ji�S�j|�S�jxsd}tj|�j�}�j||�}�j||��S)Nc3�LK�|]}t|�rt|�n|���y�wrCr�r�s  rGr�z/_LocationIndexer.__getitem__.<locals>.<genexpr>�r�r�c3�^�K�|]$}tj|�j����&y�wrCr�r�s  �rGr�z/_LocationIndexer.__getitem__.<locals>.<genexpr>�r�r��takeablerro)
rsrgrr�_is_scalar_accessri�
_get_valuere�_getitem_tuplercr�r�r�r�)rEr~rcr�s`   rGrHz_LocationIndexer.__getitem__�s����"�3�'���9����F�#�F�F�C��H�C�H�H�C��%�%�c�*�*�t�x�x�*�*�C�I�$�.�.�I�I��&�&�s�+�+��9�9�>��D� �2�2�3����A�N�!�B�B�3��W�N��%�%�n�4�%�@�@rIc��t��rC��NotImplementedErrorr�s  rGrz"_LocationIndexer._is_scalar_access����!�#�#rIc��t|��rCr�r�s  rGrz_LocationIndexer._getitem_tuple�rrIc��t��rCrr�s   rGr�z_LocationIndexer._getitem_axis�rrIc��t|��rCr��rEr�s  rGr�z+_LocationIndexer._has_valid_setitem_indexer�rrIc��|jj|�}t||�}|j�d}|jj	||��S)Nrro)rirv�check_bool_indexerr��_take_with_is_copy)rEr~rc�labels�indss     rG�
_getbool_axisz_LocationIndexer._getbool_axis�sN�����#�#�D�)�� ���-���{�{�}�Q����x�x�*�*�4�d�*�;�;rIrC)rczAxis | Noner]r;�NN�r]�None�rcr:)r�rrr]rr)r~rrr]rr�r�rrr]rd�r�rr)r~rr�r?r]r?)r~rr�r]rd)rJrKrL�__annotations__rcr	rmr�r�rpr�r�r�r�r�rzr�r�rr�r}r�rHrrr�r�r&rDrIrGr`r`�sb�����D�.���O�
�	��	�$5�L�,��,�\�2V��2V�h�>��>�<(�,����*���� ���������	��	�����6�:.��:.�x�B��B�H(�	��A��A� $�(�$�(��<��<rIr`c��eZdZUdZded<dZeej�dd��Zdd�Z	dd�Z
dd�Zdd	�Zdd
�Z
dd�Zdd�Zdd
�Zdd�Zdd�Zdd�Zdd�Zy)rVFrdrez�labels (MUST BE IN THE INDEX), slices of labels (BOTH endpoints included! Can be slices of integers if the index is integers), listlike of labels, booleanc���|jj|�}t|t�rpt	|j
�s[|j
jdk(sBt|t�r$t	|jd�j
�st|�d���t|t�rCt|jt�st|jt�rt|�d���yy)N�booleanrz7: boolean label can not be used without a boolean indexz+: boolean values can not be used in a slice)rirvrqrdrr�rhr6�get_level_valuesrxrw�start�stop�	TypeError)rEr~rcr�s    rGr�z_LocIndexer._validate_key�s����X�X�
�
��
%���c�4� ��"�(�(�#��x�x�}�}�	�)��"�j�)��b�1�1�!�4�:�:�;���%�N�O��
��c�5�!��s�y�y�$�'�:�c�h�h��+E��s�e�#N�O�P�P�,F�"rIc��y)NTrDr s  rGr�z&_LocIndexer._has_valid_setitem_indexer�s��rIc�$�t|�|jk7ryt|�D]i\}}t|�sy|jj
|}t
|t�ryt
|t�r|jry|jr�iyy)r�FT)r�rur�r#rir�rqr6ra�!_supports_partial_string_indexing�_index_as_unique)rEr~r�r�r�s     rGrz_LocIndexer._is_scalar_access�sz���s�8�t�y�y� ���c�N�D�A�q��Q�<�������q�!�B��"�j�)���!�S�!�b�&J�&J���&�&��#� rIc�N�td�|D��sytd�|D��S)a�
        Check whether there is the possibility to use ``_multi_take``.

        Currently the limit is that all axes being indexed, must be indexed with
        list-likes.

        Parameters
        ----------
        tup : tuple
            Tuple of indexers, one per axis.

        Returns
        -------
        bool
            Whether the current indexing,
            can be passed through `_multi_take`.
        c3�2K�|]}t|����y�wrC)r2r�s  rGr�z6_LocIndexer._multi_take_opportunity.<locals>.<genexpr>s����8�C�q�'��*�C�r�Fc3�FK�|]}tj|����y�wrC)r�r�r�s  rGr�z6_LocIndexer._multi_take_opportunity.<locals>.<genexpr>s����;�s�!�s�*�*�1�-�s�s�!)r�r�r�s  rG�_multi_take_opportunityz#_LocIndexer._multi_take_opportunitys+��$�8�C�8�8���;�s�;�;�;�;rIc	���t||jj�D��cic]\}}||j||���}}}|jj	|dd��Scc}}w)a�
        Create the indexers for the passed tuple of keys, and
        executes the take operation. This allows the take operation to be
        executed all at once, rather than once for each dimension.
        Improving efficiency.

        Parameters
        ----------
        tup : tuple
            Tuple of indexers, one per axis.

        Returns
        -------
        values: same type as the object being indexed
        T�r��
allow_dups)�zipri�_AXIS_ORDERS�_get_listlike_indexer�_reindex_with_indexers)rEr�r~rc�ds     rG�_multi_takez_LocIndexer._multi_takesn��& #�3����(=�(=�>�
�>���d�
�$�,�,�S�$�7�7�>�	
�
��x�x�.�.�q�t��.�M�M��	
s�A"c��|j||�|j||�\}}|jj|||gidd��S)a�
        Index current object with an iterable collection of keys.

        Parameters
        ----------
        key : iterable
            Targeted labels.
        axis : int
            Dimension on which the indexing is being made.

        Raises
        ------
        KeyError
            If no key was found. Will change in the future to raise if not all
            keys were found.

        Returns
        -------
        scalar, DataFrame, or Series: indexed value(s).
        Tr?)r�rCrirD)rEr~rc�keyarrr�s     rG�_getitem_iterablez_LocIndexer._getitem_iterable6sY��.	
���3��%��4�4�S�$�?�����x�x�.�.�
�F�G�$�%�D�T�/�
�	
rIc��tt�5|j|�}|j|�cddd�S#1swYnxYw|j	|�}|j|�r|j
|�S|j|�SrC)rrr�rr�r=rFr�r�s  rGrz_LocIndexer._getitem_tupleUsx��
�m�
$��'�'��,�C��)�)�#�.�%�
$�
$��
�*�*�3�/���'�'��,��#�#�C�(�(��+�+�C�0�0s	�"<�Ac�<�|jj||��Sr�)ri�xs)rE�labelrcs   rG�
_get_labelz_LocIndexer._get_labelcs���x�x�{�{�5�t�{�,�,rIc��|jxsd}	|j||��S#t$rP}|jt	|�cxkr$|j
jjkr|�td�|�d}~wwxYw)NrrozNo label returned)	rcrNrxrur�rir��nlevelsr)rEr�rc�eks    rGr�z._LocIndexer._handle_lowerdim_multi_index_axis0gst���y�y�~�A��		=��?�?�3�T�?�2�2���	=��y�y�3�s�8�=�t�x�x�~�~�'=�'=�=���>�� 3�4�"�<��	=�s�%�	A>�AA9�9A>c�|�t|�}t|�rt|�}|turt	d�}|j
j
|�}t|t�rt|t�rt|�}t|t�r%|j||�|j||��Stj|�r|j||��St|�r�t|t�rt|t�s9t!|d�r|j"dkDrt%d��|j'||��St)||�rQ|j+|�}t	d�g|j"z}|||<|j
j,t|�S|j||�|j/||��S)Nrorur�z&Cannot index with multidimensional key)r
rr|r�rwrirvrqrrr6r��_get_slice_axisr�r�r&r2r
rur�rIr��get_locsrQrN)rEr~rcr$�locsr�s      rGr�z_LocIndexer._getitem_axisusu����$���s���s�)�C��(�?���+�C����#�#�D�)���c�5�!�j���&D���*�C��c�5�!����s�D�)��'�'��$�'�7�7�
�
 �
 ��
%��%�%�c��%�5�5�
!�#�
&��s�E�*�z�&�*�/M��3��'�C�H�H�q�L�$�%M�N�N��-�-�c��-�=�=��s�F�+����s�+��?D�T�{�m�d�i�i�>W�� $���
��x�x�}�}�U�7�^�4�4�	
���3��%����s���.�.rIc�l�|j}t|�s|jd��S|j|�}|j	|j
|j|j�}t|t�r|jj||��S|jj||��S)zL
        This is pretty simple as we just have to deal with labels.
        Fr�ro)ri�
need_slicer�rv�
slice_indexerr3r4�steprqrw�_slice�take)rE�	slice_objrcrir$r�s      rGrSz_LocIndexer._get_slice_axis�s���
�h�h���)�$��8�8��8�'�'����t�$���&�&�y���	���	���W���g�u�%��8�8�?�?�7��?�6�6��8�8�=�=��t�=�4�4rIc�x�|jj|�}t|t�r|j	|d��St|t
�r8t|t�s(|jdkrt|�dkDrtd��d}t|t
�rtd�|D��}t|�st|t�rt|�r|s	|j|�St'||�r=|jdk(rtd	�|D��rtd��|j)|�St+|�rNt-|�rt/|�}t1j2|�rt5||�}|S|j7||�dS	|j|�S#t$rBt|t
�r/t|t�rt|�|jk(rd|icYS�Y��t $rt|t�s�Y��t"$rt%|�s�d|icYSwxYw#t$rt+|�sd|icYS�wxYw)
a�
        Convert indexing key into something we can use to do actual fancy
        indexing on a ndarray.

        Examples
        ix[:5] -> slice(0, 5)
        ix[[1,2,3]] -> [1,2,3]
        ix[['foo', 'bar', 'baz']] -> [i, j, k] (indices of foo, bar, baz)

        Going by Zen of Python?
        'In the face of ambiguity, refuse the temptation to guess.'
        raise AmbiguousIndexError with integer labels?
        - No, prefer label-based indexing
        rU)r�r�r�r�Fc3�<K�|]}t|t����y�wrCr�rs  rGr�z2_LocIndexer._convert_to_indexer.<locals>.<genexpr>�s���� C�s�!��A�u�!5�s�r�r~c3�<K�|]}t|t����y�wrCrr�s  rGr�z2_LocIndexer._convert_to_indexer.<locals>.<genexpr>�s����%H�C�q�j��E�&:�C�r�)rirvrqrw�_convert_slice_indexerrrr6rur�rr�r#rry�LookupErrorrPrr�rr�rTr2rr|r�r�r"rC)rEr~rcr$�contains_slices     rGr}z_LocIndexer._convert_to_indexer�s������#�#�D�)���c�5�!��0�0��5�0�A�A�
�s�E�"��v�z�2��	�	�A�
��C��1��� 3�4�4����c�5�!� � C�s� C�C�N��S�>��v�z�*�{�3�/?��

$��~�~�c�*�*��3��'��y�y�A�~�#�%H�C�%H�"H�#�$7�8�8��?�?�3�'�'�
!�#�
&��3���3�i���"�"�3�'�(���5���
��1�1�#�t�<�Q�?�?�
��~�~�c�*�*��?�
��c�5�)�j���.L��3�x�6�>�>�1� %�s�|�+���$�
�!�&�*�5��6��
$�!�#����s�|�#�
$��.�
�+�C�0�!�3�<�'��	
�s7�F�H�AH� H�#H�?H�H�H9�7H9c��|jj|�}|jj|�}|j||�\}}||fS)aJ
        Transform a list-like of keys into a new index and an indexer.

        Parameters
        ----------
        key : list-like
            Targeted labels.
        axis:  int
            Dimension on which the indexing is being made.

        Raises
        ------
        KeyError
            If at least one key was requested but none was found.

        Returns
        -------
        keyarr: Index
            New index (coinciding with 'key' if the axis is unique).
        values : array-like
            Indexer for the return object, -1 denotes keys not found.
        )rirv�_get_axis_name�_get_indexer_strict)rEr~rcr��	axis_namerHr�s       rGrCz!_LocIndexer._get_listlike_indexer�sL��.�X�X�
�
��
%���H�H�+�+�D�1�	��0�0��i�@�����w��rIN)rcr9r-�r~rrr]rdr+r,r*�r\rwrcr:)rJrKrLrer.rbrr`r�r�rr=rFrIrrNr�r�rSr}rCrDrIrGrVrV�sy���I�t��	:��	�	�	'�	'�(�Q�)�Q�*��D<�0N�2
�>1�-�=�"/�H5�&N�`rIrVc��eZdZdZdZdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zdd
�Zdd�Z
d�Zddd
�Zdd�Zd�Zd d�Zd!d�Zd"d�Zd�Zd�Z		d#					d$d�Zd%d�Zy)&rRzlinteger, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean arrayTc�@�tj|�rVt|d�rIt|jt
�r/|jjdk(rtd��td��yt|t�ryt|�r|j||�yt|t�rtd��t|�r�t|t�r
|j }n#t#|�r|}nt%j&|�}t)|j*j-|��}t/|j0�st3d|����t)|�r3|j5�|k\s|j7�|krt3d��yytd|j8�d	���)
Nr��integerzDiLocation based boolean indexing on an integer type is not availablezBiLocation based boolean indexing cannot use an indexable as a maskr�z%.iloc requires numeric indexers, got �%positional indexers are out-of-boundsz#Can only index by location with a [�])r�r�r
rqr�r5�
inferred_typerr�rwr�_validate_integerrrrr2r(�_valuesrr�r/r�rirvr!r��
IndexError�max�minrb)rEr~rc�arr�len_axiss     rGr�z_iLocIndexer._validate_key&sg�����s�#��s�G�$��C�I�I�u�)E��9�9�*�*�i�7�-�+���
!�-���
��c�5�!��
��_��"�"�3��-�
��U�
#� � 3�4�4�
!�#�
&��#�y�)��k�k���s�#����h�h�s�m���4�8�8�-�-�d�3�4�H�$�C�I�I�.� �#H���!N�O�O��3�x�S�W�W�Y�(�2�c�g�g�i�8�)�6K� �!H�I�I�7L�x��B�4�CT�CT�BU�UV�W�X�XrIc���t|t�rtd��t|t�rt	d��t|t
�st
|j|�}t|jj|�D]b\}}t|t�r�t|�r�#t|�r|t|�k\s�=td��t|t�s�Ytd��y)z�
        Validate that a positional indexer cannot enlarge its target
        will raise if needed, does not modify the indexer externally.

        Returns
        -------
        bool
        z%iloc cannot enlarge its target objectzsDataFrame indexer for .iloc is not supported. Consider using .loc with a DataFrame indexer for automatic alignment.T)rq�dictrqr'r5rr�_tuplifyrurArir�rwr2rr�)rEr�r�r�s    rGr�z'_iLocIndexer._has_valid_setitem_indexerPs����g�t�$��D�E�E��g�|�,��X��
�
�'�5�)��t�y�y�'�2�G��������0�E�B���!�U�#��%�a�(���A����B��<�$�%L�M�M��A�t�$� �!H�I�I�1�rIc�X�t|�|jk7rytd�|D��S)r�Fc3�2K�|]}t|����y�wrC)rr�s  rGr�z1_iLocIndexer._is_scalar_access.<locals>.<genexpr>�s����.�#�Q�:�a�=�#�r�)r�rur�r�s  rGrz_iLocIndexer._is_scalar_accessts(���s�8�t�y�y� ���.�#�.�.�.rIc�x�t|jj|��}||k\s||krtd��y)a@
        Check that 'key' is a valid position in the desired axis.

        Parameters
        ----------
        key : int
            Requested position.
        axis : int
            Desired axis.

        Raises
        ------
        IndexError
            If 'key' is not a valid position in axis 'axis'.
        z*single positional indexer is out-of-boundsN)r�rirvrq)rEr~rcrus    rGroz_iLocIndexer._validate_integer�s=�� �t�x�x�)�)�$�/�0���(�?�c�X�I�o��I�J�J�.rIc��|j|�}tt�5|j|�cddd�S#1swYnxYw|j	|�SrC)r�rrrr�r�s  rGrz_iLocIndexer._getitem_tuple�sG���*�*�3�/��
�m�
$��)�)�#�.�%�
$�
$���+�+�C�0�0s	�<�Ac�x�	|jj||��S#t$r}td�|�d}~wwxYw)a
        Return Series values by list or array of integers.

        Parameters
        ----------
        key : list-like positional indexer
        axis : int

        Returns
        -------
        Series object

        Notes
        -----
        `axis` can only be zero.
        rorlN)rir#rq)rEr~rcr�s    rG�_get_list_axisz_iLocIndexer._get_list_axis�sB��"	O��8�8�.�.�s��.�>�>���	O��D�E�3�N��	O�s��	9�4�9c�l�|turtd�}nt|t�rt	d��t|t�r|j||��St
|�rt|�}t|t�rtj|�}tj|�r%|j||�|j||��St|�r|j||��St!|�}t#|�st%d��|j'||�|j(j+||��S)NzWDataFrame indexer is not allowed for .iloc
Consider using .loc for automatic alignment.roz5Cannot index by location index with a non-integer key)r�rwrqr'rqrSrr|r��asarrayr�r�r�r&r2r~r
rr5rori�_ixsr�s   rGr�z_iLocIndexer._getitem_axis�s���(�?���+�C�
��\�
*��?��
�
�c�5�!��'�'��$�'�7�7��s���s�)�C��c�4� ��*�*�S�/�C����s�#����s�D�)��%�%�c��%�5�5�"�#�
&��&�&�s��&�6�6�$�C�(�C��c�?�� W�X�X�
�"�"�3��-��8�8�=�=��4�=�0�0rIc���|j}t|�s|jd��S|j|�}|j	|�|jj||��S)NFr�ro)rirWr�rv�_validate_positional_slicerZ)rEr\rcrir$s     rGrSz_iLocIndexer._get_slice_axis�sW���h�h���)�$��8�8��8�'�'����t�$���)�)�)�4��x�x���y�t��4�4rIc��|S)zL
        Much simpler as we only have to deal with our valid types.
        rDr�s   rGr}z _iLocIndexer._convert_to_indexer�s	���
rIc��t|�rt|�}|j�!t|j|j|�}|SrC)rr|rcrtrur�s  rGr�z!_iLocIndexer._get_setitem_indexer�s8���s���s�)�C��9�9� �(����D�I�I�s�C�C��
rIc��|jj}|jjj}|s't	|t
�r|jj}|s�t
|jjj�ru|jdkDrft	|t�rt|j��n|}|jjjd}t|t|d���}t	|t�r�t
|�t
|jj�k(r^t!||jj�D];\}}	t	|	t"�s�t%|�r�#t'j(|�r�9d}nt	|t��rcg}
t+|�D�]F\}}t	|t��rt-|�\}}
|jdkD�r�||k(�r�t
|j�s't/|�st1d��||j|<yt'j(|d�r||j|<yt3|�r�t|d��}dt5j6t
|j�t4j8��z}t;j<||�}t	|t>�sUt	|t4j@�r"|jdk(rt
|�dk(r|d	}|||d<||j|<y||j|<nPtC|�s-tE|t
|j��|j|<ntG|�|j|<tI||jj�}|jK|||�y|jjM|�}tOjP�5tOjRd
dtT��|jWt
|�|�}ddd�t5jXt
|�dzt4j8��}d|d<||fi}|jj[|d�
�}|j|j_|jj]d��d|j_/|
ja|jc|����6|
ja|���It|
�}n#t-|�\}}|r|je||�y|dk(r|jg||�\}}|r|ji|||�y|jk|||�y#1swY��TxYw)a�
        _setitem_with_indexer is for setting values on a Series/DataFrame
        using positional indexers.

        If the relevant keys are not present, the Series/DataFrame may be
        expanded.

        This method is currently broken when dealing with non-unique Indexes,
        since it goes from positional indexers back to labels when calling
        BlockManager methods, see GH#12991, GH#22046, GH#15686.
        r�rT)�
extract_numpyz5cannot set a frame with no defined index and a scalarNr�r�)r.�ignore�<The behavior of Index.insert with object-dtype is deprecated��category)r@��clearrU)6ri�_info_axis_numberr��is_single_blockrqr'r��arraysrurwr|�valuesrr0rrr�rAr6rr�r�r��convert_missing_indexerr2r�rr��onesr��algos�take_ndr(r�r r)r*�"convert_from_missing_indexer_tupler�rvr��catch_warnings�filterwarningsr��insertr�rD�_maybe_update_cacher�_is_copy�appendry�_setitem_with_indexer_missingr�� _setitem_with_indexer_split_path�_setitem_single_block)rEr�r�rh�	info_axis�take_split_path�valrtr�r��nindexer�idxr~�_�taker�empty_value�new_indexerr�r$�
reindexers�new_obj�missings                      rGr�z"_iLocIndexer._setitem_with_indexer�se���H�H�.�.�	�#�h�h�m�m�;�;�;���:�e�\�#B�"'�*�*�"<�"<�<�O��3�t�x�x�}�}�';�';�#<����Q��*4�U�D�*A�$�u�|�|�~�&�u�C��(�(�-�-�&�&�q�)�C�"2��]�3�d�;�#��O��g�u�%�#�g�,�#�d�h�h�m�m�:L�*L��W�d�h�h�m�m�4���2��b�*�-��q�M�S�%6�%6�q�%9�&*�O��5��g�u�%��H�#�G�,���3��c�4�(�5�S�9�F�C���y�y�1�}��i��
 #�4�8�8�}�#7��#>�&0�%A�'"�!"�-2�D�H�H�S�M�"��,�,�W�Q�Z�8�,1�D�H�H�S�M�"�*�5�1�"/��T�"J�C�$&�����T�X�X��b�g�g�)N�$N�E�*/�-�-��U�*C�K�#-�e�Y�#?�%/�s�B�J�J�$?�(+���A�
�(+�C��A�
�+.�f�+�C�:=��G�A�J� 7�0;�����
� &�,7�D�H�H�S�M�!-�e�!4�,W� %�s�4�8�8�}�-�D�H�H�S�M�
-=�U�,C�D�H�H�S�M�&H�#�T�X�X�]�]�'���2�2�;��t�L��!�H�H�.�.�q�1�E�!�0�0�2� �/�/�$�,�%2�	�"'���c�%�j�#�!>��3��I�I�c�%�j�1�n�B�G�G�D�E� "�E�"�I�"#�f�e�_�!5�J�"�h�h�=�=�"�t�>��G�%,�L�L�D�H�H�M��H�H�1�1��1�=�(,�D�H�H�%��O�O�F�N�N�3�$7�8��O�O�C�(�A-�D�H�o�G�6�w�?��G�W���2�2�7�E�B���5�=�!�;�;�G�U�K�N�G�U���1�1�'�5�$�G��&�&�w��t�<�[3�2�s�+8U5�5U?	c��|jdk(sJ�t|t�st|j|�}t	|�|jkDrtd��t|dtj�r|djdkDrtd��t|t�r|dk7st|t�rddlm}|j|||��}|d}|j|�}|d}t||j j"�}t%|��r%t'|dd�dkD�rt|t(�r|j+|||�y
t
j|�dk(r|j-||�y
t	|�dk(r0|t	|�k(r"t/|�s|j1|d||�y
t	|�dk(rUd|cxk7rt	|�k7rAnn>t	|�dk(r%t3|�s|j5||df|d�Std	��|dk(r,t	|�t	|j j"�k(ry
|j7|�rFt9|j j:j<|d�r|j1|d||�y
t	|�t	|�k(r(t?||�D]\}	}
|j1|	|
|��y
t	|�dk(rDtAjB|�r/t	|j �dk(r|j1|d||�y
td	��|D]}	|j1|	||��y
)z&
        Setitem column-wise.
        r�ztoo many indices for arrayrzCannot set values with ndim > 2rQ�r>r�ruz@Must have equal len keys and value when setting with an iterableN)"rurqrrrxr�rqr�r�r�r(rw�pandasr>r��_ensure_iterable_column_indexerr4rir�r2r�r'�!_setitem_with_indexer_frame_value�_setitem_with_indexer_2d_valuer#�_setitem_single_columnrr�rr"�dtypesrprAr�r�)rEr�r�rhr>r��ilocsr��lplane_indexerrUrs           rGr�z-_iLocIndexer._setitem_with_indexer_split_path�s���
�y�y�A�~��~��'�5�)��t�y�y�'�2�G��w�<�$�)�)�#��9�:�:��g�a�j�"�*�*�-�'�!�*�/�/�A�2E��?�@�@��u�i�(�T�V�^�
�5�RV�@W�%��&�&�w��u�
�>�E��A�J�	��4�4�Y�?��
�Q�Z��*�2�t�x�x�~�~�>��
 ��&�7�5�&�!�+D�q�+H��%��.��6�6�w��t�L������1�$��3�3�G�U�C��U��q��^�s�5�z�%A�)�TV�-��+�+�E�!�H�e�R�@��U��q��Q�.�%F�C��J�%F�
�u�:��?�:�i�+@� �5�5�r�9�Q�<�6H�%�PQ�(�S�S� �4���
 �1�$��U��s�4�8�8�>�>�7J�)J���'�'��0�_������'�'��a��1�6��+�+�G�A�J��r�B��U��s�5�z�)�!�%��/�F�C���/�/��Q��;�0��U��q��S�%6�%6�r�%:�s�4�8�8�}�PQ�?Q��+�+�E�!�H�e�R�@�!�4������+�+�C���;�rIc�v�|d}|j|d�}t|�stj|t��}t|�|jdk7rtd��t|�D]F\}}|dd�|f}t|j�r|j�}|j|||��Hy)Nrr�r�z?Must have equal len keys and value when setting with an ndarray)
r�rr�r/rr�r�r�r�r"r��tolistr�)rEr�r�r�r�r�rU�	value_cols        rGr�z+_iLocIndexer._setitem_with_indexer_2d_value�s����Q�Z���4�4�W�Q�Z�@���U�#��H�H�U�&�1�E��u�:����Q��'��Q��
� ��&�F�A�s��a��d��I��y���/�%�,�,�.�	��'�'��Y��;�'rIc��|j|d�}t|�}|d}t|jjt
�}|jj}|dk(r:t|�D]+\}	}
|jdd�|	f}|j|
||��-y|s�|jj|jj�r{|D]u}
|jj|
}||vr3||d<|jt|�|jdd�|
f|�}ntj}|j|
||��wy|std��|D]q}
|jj|
}||vr/||d<|jt|�|||t!���}ntj}|j|
||��sy)Nr�rrQz/Setting with non-unique columns is not allowed.)�	using_cow)r�r|rqrir�r6�	is_uniquer�rQr��equalsr�rrr��nanr�r
)
rEr�r�rhr��sub_indexerr��multiindex_indexer�unique_colsr�rUr��items
             rGr�z._iLocIndexer._setitem_with_indexer_frame_values����4�4�W�Q�Z�@���7�m��
�Q�Z��'����(8�(8�*�E���m�m�-�-���6�>�#�E�*���3��j�j��A��&���+�+�C��b�9�+�����!5�!5�d�h�h�6F�6F�!G����x�x�'�'��,���5�=�%)�K��N��,�,��k�*��
�
�1�c�6�*�*��C��&�&�C��+�+�C��b�9����N�O�O����x�x�'�'��,���5�=�%)�K��N��,�,��k�*��d��*�"5�"7�	-��C��&�&�C��+�+�C��b�9�rIc��|}tj|�xs)tj|t|j��}tj
|�xst
|�xrt|�dk(}|ry|r+	|jjj|||d��n�|jjj|}|tjk(r:t/|t|j��|jjdd�|f<|jjj|||�|jj1�y#tttf$r�|jjj|}|tjt fvrA|jj"s+t%j&d|�d|�d�t(t+���|jj-||�Y��wxYw)	z�

        Parameters
        ----------
        loc : int
            Indexer for column position
        plane_indexer : int, slice, listlike[int]
            The indexer we use for setitem along axis=0.
        rNT)�inplace_onlyzgSetting an item of incompatible dtype is deprecated and will raise in a future error of pandas. Value 'z' has dtype incompatible with z5, please explicitly cast to a compatible dtype first.r�)r�r��
is_full_slicer�ri�is_empty_slicerr��column_setitemr�r5rr�rQr��voidr�emptyr�r�r�r�isetitemr)�_clear_item_cache)rErUr��
plane_indexerr��is_full_setter�is_null_setterr�s        rGr�z#_iLocIndexer._setitem_single_column?s������*�*�2�.�V�#�2C�2C�B��D�H�H�
�2V���+�+�B�/�U�=��3D�3U��R��TU�����
�
.����
�
�,�,����D�-��>�H�H�O�O�(�(��-�E������)T��3�t�x�x�=�)����
�
�a��f�%�
�H�H�M�M�(�(��m�U�C����"�"�$��S�	�+<�=�
.������,�,�S�1������&� 1�1�$�(�(�.�.��M�M�"�"'��(F�u�g�NN�N�&�#3�#5�
����!�!�#�u�-�1
.�s�;)E�B,H�Hc��ddlm}t|t�r|dk7st|t�r|j|||��}|jj}|jj|�}t|t�r�|jt|�cxk(rdk(rwnntt|d�rftj|d�rN|||}t|j|g��dk(r(|j!|�}|j#|||d�yt%|�}t|t&�r!|dk7r|j)||�j*}|jj-�|jj.j1||��|j_|jj3dd�	�y)
zQ
        _setitem_with_indexer for the case when we have a single Block.
        rr�rQr�r�N)r�r�T)r��inplace)r�r>rqr(rwr�rir�rvrrrur�rr�r��get_indexer_forryr��maybe_convert_ixr'r�rp�%_check_is_chained_assignment_possibler��setitemr�)	rEr�r�rhr>r��item_labels�colrUs	         rGr�z"_iLocIndexer._setitem_single_block�sm��	"��u�i�(�T�V�^�
�5�RV�@W��&�&�w��u�
�>�E��H�H�.�.�	��h�h�(�(��3���g�u�%�
�	�	�S��\�.�Q�.��w�q�z�*��%�%�g�a�j�1�!�'�)�"4�5���{�2�2�C�5�9�:�a�?�%�-�-�c�2�C��/�/��U�G�A�J�G��&��0�G��e�\�*�t�v�~��%�%�g�u�5�=�=�E�	
���6�6�8����
�
�-�-�g�U�-�K����
����%�%�D�$�%�?rIc�p	�ddlm}|jdk(�rw|jj}tj�5tjddt��|jt|�|�}ddd�|jr:|jdd�}|dk7j�r|j||d	�St|�sd}n�t!||jj"�rdt%|jj"�s!t'|jj"d
��}t)|jj"|�d}nxt+|�rd}nj|jj,sRt%|jj"�s3|jj"}t/|d|�}t)||�d}nd}||g|�
�j0}	t|jj0�r!t3|jj0|	g�}	|jj5|	|jj6��j8|j_|jj;d��y|jdk(�rt|jj<�st?d��tA|d�}
tC|tD�r/|jG|jj<d��}||_n�tC|tH�r%|||jj<|tJ��}n`tM|�r6t|�t|jj<�k7rt?d��|||jj<|��}t|j�s�|jO�jP}|jj}tC|tR�r
|jT}
n|j6}
tW|g|
��|_|
s|jYd
��}|j8|j_n4|jj[|�j8|j_|jj;d��yy#1swY��4xYw)zN
        Insert new row(s) or column(s) into the Series or DataFrame.
        rr�r�r�r�r�Nr�rUF)�compat�numpy_dtyper�)r�rhTr�r�z*cannot set a frame with no defined columnsr�)r�r�)r�rhr�z(cannot set a row with mismatched columns)rh�r�).r�r>rurir�r�r�r�r�r�r�r��get_indexerr�r�r#r+r�r"r-rr,r�r�rpr%�_constructorrhr�r�r�r�r
rqr(�reindexrwrr2�to_framer?r6�namesr5�
infer_objects�_append)rEr�r�r>r��	new_indexr��	new_dtype�
curr_dtype�
new_values�	has_dtype�dfr�rhs              rGr�z*_iLocIndexer._setitem_with_indexer_missing�s���	"��9�9��>��H�H�N�N�E��(�(�*��'�'��R�*��
"�L�L��U��W�=�	�+����$�/�/�	�"�#��?���2�%�*�*�,��5�5�k�5�%�P�P��U�#� �	�&�u�d�h�h�n�n�=�&�t�x�x�~�~�6�.�t�x�x�~�~�e�L�E�)�$�(�(�.�.�%�@��C�	��e�� �	��X�X�^�^�O�D�H�H�N�N�,K�"�X�X�^�^�
�$�Z��
�K�
�)�*�e�<�Q�?�	� �	����y�9�A�A�J��4�8�8�#�#�$�+�D�H�H�,<�,<�j�+I�J�
� �H�H�1�1��)�$�(�(�-�-�2���d�
�H�H�M�
�H�H�)�)��)�5�
�Y�Y�!�^��t�x�x�'�'�(� �!M�N�N���w�/�I��%��+��
�
�D�H�H�,<�,<�4�
�H��$��
��E�4�(������!1�!1��v���
(��.��5�z�S����)9�)9�%:�:�(�)S�T�T��u�D�H�H�,<�,<�7�K���t�x�x�=��^�^�%�'�'���h�h�n�n���c�:�.��9�9�D��8�8�D� �'���6��� ��)�)�u�)�5�B� "������
� $��� 0� 0�� 7� <� <����
��H�H�)�)��)�5�U�q+�*�s�8R+�+R5c�d�t|�r|g}|St|t�r7tjt|jj��|}|St|tj�r<|jjdk(r#tjt|��|}|S|}|S)zX
        Ensure that our column indexer is something that can be iterated over.
        �b)rrqrwr�r�r�rir�r�r�r�)rE�column_indexerr�s   rGr�z,_iLocIndexer._ensure_iterable_column_indexer	s���
�n�%�#�$�E������
.��I�I�c�$�(�(�"2�"2�3�4�^�D�E���
�~�r�z�z�2�~�7K�7K�7P�7P�TW�7W��I�I�c�.�1�2�>�B�E���#�E��rIc��t|ttjtt
f�r|f}t|t��rod�}t
t||��}|D�cgc]}tj|���}}t|�}|dk(}	|jdk(}
|j}|
r	|	xr|d}	||jk(r�td�|D��r�|j|jd|dd��j }t#|�dkDr@|s>t#|d�}
tj$||
�j'|
d�j(}|St+|�D�]C\}}|j|}t-|�st|t�r�|	rtj|�r�I||}t/|�s
t|g�}nt|�}|j0j3|�r"|r|cS|j j5�cS|j|�j cS|	s��|jjd}|j0j3|�st#|�s|j j5�cS|j|�j cSt?d	��t7|�r�|jdk(r�t9|jj:�r|S|jj=d�}|j0j3|�r|j j5�S|j|�j |St7|�rk|jj=d�}|j0j3|�r|j j5�S|j|�j St?d	��cc}w)
aT
        Parameters
        ----------
        indexer : tuple, slice, scalar
            Indexer used to get the locations that will be set to `ser`.
        ser : pd.Series
            Values to assign to the locations specified by `indexer`.
        multiindex_indexer : bool, optional
            Defaults to False. Should be set to True if `indexer` was from
            a `pd.MultiIndex`, to avoid unnecessary broadcasting.

        Returns
        -------
        `np.array` of `ser` broadcast to the appropriate shape for assignment
        to the locations selected by `indexer`
        c�Z�t|tj�r|j�S|SrC)rqr�r��ravel)r�s rGr�z)_iLocIndexer._align_series.<locals>.ravelH	s ��$.�q�"�*�*�$=�q�w�w�y�D�1�DrIr�r�rc3�2K�|]}t|����y�wrC)r$)r�r�s  rGr�z-_iLocIndexer._align_series.<locals>.<genexpr>^	s����0Q��A��Q���r�Tr�r�z Incompatible indexer with Series) rqrwr�r�r|r5rr�mapr�r��sumrurir�r�r�rpr��tile�reshaper?r�r$r2r�r�r�rr"r�rvr�)rEr��serr�r�r�r��aligners�sum_aligners�single_aligner�is_frameri�
ser_values�len_indexerr�r��new_ixs                 rGr�z_iLocIndexer._align_series,	s(��.�g��r�z�z�4��?�@��j�G��g�u�%�
E��C��w�/�0�G�>E�F�g�s�C�-�-�c�2�2�g�H�F��x�=�L�)�Q�.�N��y�y�A�~�H��(�(�C��!/�!?�H�Q�K���t�y�y�(�S�0Q��0Q�-Q� �[�[����!��W�Q�Z�)@�t�[�L�T�T�
��w�<�!�#�,>�"%�g�a�j�/�K����
�K�8�@�@��b�Q�S�S��"�!�#�G�,���3��X�X�a�[���s�#�z�#�u�'=�%�#�*;�*;�C�*@� ���W�F�/��7�!&��x���!&�v����y�y�'�'��/�$�#&�J�"�{�{�/�/�1�1��;�;�v�.�6�6�6�$������q�)�B��y�y�'�'��+�3�r�7�"�{�{�/�/�1�1��;�;�r�?�2�2�2�3-�Z�;�<�<�%��
 �T�Y�Y�!�^��t�x�x�~�~�.��
����#�#�A�&�B��y�y����#��{�{�'�'�)�)��;�;�r�?�*�*�7�3�3�
��
 ����#�#�A�&�B��y�y����#��{�{�'�'�)�)��;�;�r�?�*�*�*��;�<�<��UGs�Oc���|jdk(}t|t�r�d\}}g}t|�D]�\}}|jj
|}	t
|�st|t�r<t|tj�r|j�}|�|	|}�l|�|	|}�tn|j|���|��/|��,|jj|�r-|jj|�r|j�}
|
S|j!||��}
|
St|t�st#|�r�|r�|jj|}	|jj|	�r|j�}
|
St|	t$�rHt|jt$�r.|	j&|jj&k7rt)d��|j!|	��}
|
St+d��)Nr�r')r�zAcannot align on a multi-index with out specifying the join levels)r�z#Incompatible indexer with DataFrame)rurqrrr�rir�r$rwr�r�r�r�r�r�r�r�r�r2r6rPr5r�)rEr�r�r�r��cols�	sindexersr��ixr�r�s           rGr�z_iLocIndexer._align_frame�	s����9�9��>���g�u�%�"�I�C���I�"�7�+���2��X�X�]�]�1�%���r�?�j��U�&;�!�"�b�j�j�1��X�X�Z���{� ��f����!�"�v����$�$�Q�'�,���4�#3��8�8�?�?�3�'�B�J�J�,=�,=�d�,C��'�'�)�C��
��*�*�S�$�*�7�C��
���%�(�,@��,I�x�������(�B��x�x���r�"��g�g�i���J��r�:�.�"�2�8�8�Z�8��
�
�b�h�h�&6�&6�6�#�5���
�j�j�r�j�*���J��>�?�?rINr*r-rg)r~zint | np.integerrcr:r]r)r,rh)rQ)rhra)r�r=rhra)rU�intr]r))rhrar]r))FF)r�r>r�rdr�rd)r�r=r]r=)rJrKrLrbrer�r�rrorr~r�rSr}r�r�r�r�r�r�r�r�r�r�r�rDrIrGrRrRs���	B���I�
(Y�T"�H
/�K�,1�O�.#1�J	5���_=�BY<�v<�,2:�hB%�H(@�Tl6�\�*$)��k=��k=�!�	k=�
�k=�Z/@rIrRc�0�eZdZUdZded<d�Zd�Zdd�Zy)	�_ScalarAccessIndexerz!
    Access scalars quickly.
    rdrec��t|��rCr�r�s  rG�_convert_keyz!_ScalarAccessIndexer._convert_key�	rrIc���t|t�st|�s|f}ntd��|j	|�}|j
j|d|ji�S)N�)Invalid call for scalar access (getting)!r)rqrrr2r�rrirrer�s  rGrHz _ScalarAccessIndexer.__getitem__�	sW���#�u�%�'��,��f�� �!L�M�M�����$��"�t�x�x�"�"�C�A�$�.�.�A�ArIc���t|t�rt�fd�|D��}n tj|�j�}t|t�st�j|�}t�j|��}t|��jk7rtd���jj||�jd��y)Nc3�^�K�|]$}tj|�j����&y�wrCr�r�s  �rGr�z3_ScalarAccessIndexer.__setitem__.<locals>.<genexpr>�	r�r�z0Not enough indexers for scalar access (setting)!)r�r)
rqrrr�r�rirxrur|rr�r��
_set_valuere)rEr~r�s`  rGr�z _ScalarAccessIndexer.__setitem__�	s�����c�5�!��H�C�H�H�C��'�'��T�X�X�6�C��#�u�%��4�9�9�c�*�C��4�$�$�S�)�*���s�8�t�y�y� ��O�P�P�������S�����GrINr()rJrKrLrMr.rrHr�rDrIrGrr�	s���
�O�(�	B�
HrIrc�F��eZdZdZd�Zedd��Z�fd�Zd�fd�Z�xZ	S)rYFc�F�|jdk(rt|�dkDr|f}|S)zd
        Require they keys to be the same type as the index. (so we don't
        fallback)
        r�)rur�r�s  rGrz_AtIndexer._convert_key�	s%���9�9��>�c�#�h��l��&�C��
rIc��|jdk(sJ�|jjjxr |jjjS)Nr�)rurir�r�r�rSs rG�_axes_are_uniquez_AtIndexer._axes_are_unique
s=���y�y�A�~��~��x�x�~�~�'�'�F�D�H�H�,<�,<�,F�,F�FrIc����|jdk(rR|jsFt|t�rt	d�|D��std��|jj|St�|�%|�S)Nr�c3�2K�|]}t|����y�wrC�r#r�s  rGr�z)_AtIndexer.__getitem__.<locals>.<genexpr>
�����4O�3�a�Y�q�\�3�r�r)
rurrqrrr�r�rirU�superrH)rEr~�	__class__s  �rGrHz_AtIndexer.__getitem__
s\����9�9��>�$�"7�"7��c�5�)��4O�3�4O�1O� �!L�M�M��8�8�<�<��$�$��w�"�3�'�'rIc����|jdk(rS|jsGt|t�rt	d�|D��std��||jj|<yt�|�%||�S)Nr�c3�2K�|]}t|����y�wrCrr�s  rGr�z)_AtIndexer.__setitem__.<locals>.<genexpr>
rr�z)Invalid call for scalar access (setting)!)
rurrqrrr�r�rirUrr�)rEr~r�rs   �rGr�z_AtIndexer.__setitem__
s`����9�9��>�$�"7�"7��c�5�)��4O�3�4O�1O� �!L�M�M� %�D�H�H�L�L�����w�"�3��.�.rIr-r()
rJrKrLrerr^rrHr��
__classcell__)rs@rGrYrY�	s2����I���G��G�
(�	/�	/rIrYc��eZdZdZd�Zy)r\Tc�@�|D]}t|�r�td��|S)zH
        Require integer args. (and convert to label arguments)
        z1iAt based indexing can only have integer indexers)rr�)rEr~r�s   rGrz_iAtIndexer._convert_key!
s(���A��a�=� �!T�U�U���
rIN)rJrKrLrerrDrIrGr\r\
s���I�rIr\c�p�t|�D�cgc]}tdd���}}||d<t|�Scc}w)z�
    Given an indexer for the first dimension, create an equivalent tuple
    for indexing over all dimensions.

    Parameters
    ----------
    ndim : int
    loc : object

    Returns
    -------
    tuple
    Nr)r{rwrr)rurUr��_tups    rGrxrx+
s;��(-�T�{�3�{�!�E�$���{�D�3��D��G���;���4s�3c�@�td�g|z}|||<t|�S)zI
    If we have an axis, adapt the given key to be axis-independent.
    N)rwrr)rurcr~r�s    rGrtrt?
s'���T�{�m�d�"�G��G�D�M���>�rIc���|}t|t�r�|jj|�st|jj	|�}d|vrtd��|j
|�}t|jt�s|jt�jSt|�rtj|t��}nt|�st!|t��}t#||�S)aL
    Check if key is a valid boolean indexer for an object with such index and
    perform reindexing or conversion if needed.

    This function assumes that is_bool_indexer(key) == True.

    Parameters
    ----------
    index : Index
        Index of the object on which the indexing is done.
    key : list-like
        Boolean indexer to check.

    Returns
    -------
    np.array
        Resulting key.

    Raises
    ------
    IndexError
        If the key does not have the same length as index.
    IndexingError
        If the index of the key is unalignable to index.
    r�ztUnalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).r�)rqr(r�r�r�rr[r�r&�astyperdrpr"r�r�r�pd_arrayr1)r�r~�resultr�s    rGr"r"H
s���4�F��#�y�!�#�)�)�*:�*:�5�*A��,�,�.�.�u�5��
��=��4��
����W�%���&�,�,��7��=�=��&�.�.�.��s�����F�$�/��
�6�
"��&��-���u�f�-�-rIc�r�t|t�r$|d}t|t�rtd��|dfS|dfS)z�
    Reverse convert a missing indexer, which is a dict
    return the scalar indexer and a boolean indicating if we converted
    r~z.cannot use a single bool to index into setitemTF)rqrwrdrx)r�s rGr�r�|
sA��
�'�4� ��%�.���g�t�$��K�L�L���}���E�>�rIc�J����fd��t�fd�t|�D��S)zK
    Create a filtered indexer that doesn't have any missing indexers.
    c�V��t|t�r�|j|d�S|S)Nr~)rqrwry)�_i�_idxr�s  �rGr�z7convert_from_missing_indexer_tuple.<locals>.get_indexer�
s*���0:�4��0F�t�B�x����U��,�P�D�PrIc3�6�K�|]\}}�||����y�wrCrD)r�r!r"r�s   �rGr�z5convert_from_missing_indexer_tuple.<locals>.<genexpr>�
s�����J�7I�8�2�t��R��&�7I�r�)rrr�)r�r�r�s `@rGr�r��
s!���
Q��J�y��7I�J�J�JrIc��|D]0}t|tjttt
f�r�.|cStj|�S)z3
    We likely want to take the cross-product.
    )rqr�r�r|r(r5�ix_)�argsrFs  rGr�r��
s:�����#��
�
�D�)�U�C�D��K���6�6�4�=�rIc��t|t�sy|D]/}t|�st|t�s�t|t�cSy)�&
    Returns
    -------
    bool
    F)rqrrr rwr6)r�r$r�s   rGr�r��
s=���c�5�!��
����?�j��E�2��f�j�1�1��rIc�T�t|t�xrt|�xr|tuS)r()rqrwr2r��r~s rGr�r��
s3��
�s�E�"�"�	 �$�S�)�)�	 ��x��rIc��|jduxs/|jduxs|jduxr|jdk7S)r(Nr�)r3r4rY)ris rGrWrW�
sD��	�	�	���	4��8�8�4��	4��H�H�D� �2�S�X�X��]�rIc��t|t�s"t|t�rtd�|D��rt	d��t|t
�s"t|t�rtd�|D��rt	d��yy)zX
    Check if the indexer is or contains a dict or set, which is no longer allowed.
    c3�<K�|]}t|t����y�wrC)rq�setr�s  rGr�z-check_dict_or_set_indexers.<locals>.<genexpr>�
s����0�C�q�
�1�c�"�C�r�zAPassing a set as an indexer is not supported. Use a list instead.c3�<K�|]}t|t����y�wrC)rqrwr�s  rGr�z-check_dict_or_set_indexers.<locals>.<genexpr>�
s����1�S��
�1�d�#�S�r�zBPassing a dict as an indexer is not supported. Use a list instead.N)rqr.rrr�r5rwr*s rGrsrs�
st��
	�3����c�5�!��0�C�0�0��O�
�	
�
	�3����c�5�!��1�S�1�1��P�
�	
�
2�"rI)rur�rUr7r]ztuple[Hashable | slice, ...])rur�rcr:r]rr)r�r5r]z
np.ndarrayr-)rirwr]rdr()x�
__future__r�
contextlibrr��typingrrrrr	r��numpyr��pandas._configr
r�pandas._libs.indexingr�pandas._libs.libr
�
pandas.compatr�
pandas.errorsrrrrrrrr�pandas.util._decoratorsr�pandas.util._exceptionsr�pandas.core.dtypes.castrr�pandas.core.dtypes.commonrrrrrr r!r"r#r$�pandas.core.dtypes.concatr%�pandas.core.dtypes.dtypesr&�pandas.core.dtypes.genericr'r(�pandas.core.dtypes.missingr)r*r+r,r-�pandas.corer.r��pandas.core.common�core�commonr��pandas.core.constructionr/rr0�pandas.core.indexersr1r2r3r4�pandas.core.indexes.apir5r6�collections.abcr7r8�pandas._typingr9r:r;r<r�r=r>r?rwr�r�rA�
IndexSlicerOr`rUrVrQrRrrXrYr[r\rxrtr"r�r�r�r�r�rWrsrDrIrG�<module>rKs���"��
������
5�.��	�	�	�(�4�����4�4����,� � �����
��
���
�C�L���D�$���B��)�)�X�]�
�v(�v(�rf<�)�f<�R�]����Y�"�Y��Y�x
�]����l@�#�l@��l@�^#H�-�#H�L�]����(/�%�(/��(/�V�]����
�&�
��
��(�1.�h
� K���"�
�
rI

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists