
    Mh{                      S SK Jr  S SKJr  S SKrS SKJrJrJrJ	r	J
r
  S SKrS SKrS SKJrJr  S SKJr  S SKJr  S SKJr  S S	KJrJrJrJrJrJrJrJr  S S
K J!r!  S SK"J#r#  S SK$J%r%J&r&  S SK'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1  S SK2J3r3  S SK4J5r5  S SK6J7r7J8r8  S SK9J:r:J;r;J<r<J=r=J>r>  S SK?J@rA  S SKBJCs  JDrE  S SKFJGrHJIrI  S SKJJKrKJLrLJMrMJNrN  S SKOJPrPJQrQ  \(       a  S SKRJSrSJTrT  S SKUJVrVJWrWJXrXJYrY  S SKZJ[r[J\r\  \" S5      r]\^" SS5      r_Sr` " S S5      ra\a" 5       rb " S S5      rc " S S \5      rd\!" \cR                  5       " S! S"\d5      5       rf\!" \cR                  5       " S# S$\d5      5       rh " S% S&\5      ri\!" \cR                  5       " S' S(\i5      5       rk\!" \cR                  5       " S) S*\i5      5       rmS5S+ jrnS6S, jroS7S- jrpS. rqS/ rrS0 rsS8S1 jrtS8S2 jruS9S3 jrvS:S4 jrwg);    )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                      \ rS rSrSrS rSrg)_IndexSlicem   a  
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                    U$ N )selfargs     F/var/www/html/env/lib/python3.13/site-packages/pandas/core/indexing.py__getitem___IndexSlice.__getitem__   s    
    rE   N)__name__
__module____qualname____firstlineno____doc__rI   __static_attributes__rE   rK   rH   rA   rA   m   s    %NrK   rA   c                  h    \ rS rSrSr\S	S j5       r\S
S j5       r\SS j5       r\SS j5       r	Sr
g)IndexingMixin   z@
Mixin for adding .loc/.iloc/.at/.iat to Dataframes and Series.
c                    [        SU 5      $ )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rF   s    rH   rV   IndexingMixin.iloc   s    \ FD))rK   c                    [        SU 5      $ )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)_LocIndexerrX   s    rH   r[   IndexingMixin.loc1  s    `	 5$''rK   c                    [        SU 5      $ )a  
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)
_AtIndexerrX   s    rH   r_   IndexingMixin.atc  s    ~ $%%rK   c                    [        SU 5      $ )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)_iAtIndexerrX   s    rH   rc   IndexingMixin.iat  s    \ 5$''rK   rE   N)returnrW   )rf   r\   )rf   r`   )rf   rd   )rL   rM   rN   rO   rP   propertyrV   r[   r_   rc   rQ   rE   rK   rH   rS   rS      s^     M* M*^ o( o(b	 >& >&@ -( -(rK   rS   c                     \ rS rSr% S\S'   SrS\S'   S\S'   \S S!S	 jj5       rS
 r\S 5       r	\S"S#S jj5       r
\S#S j5       rS$S jr\S%S j5       r\S&S j5       r\S'S j5       r\S&S j5       r\S&S j5       r\S(S j5       r\S(S j5       r\S(S j5       rS$S jrS)S jr\S 5       rS*S jrS(S jrS$S jrS+S jr\S$S j5       rSrg),_LocationIndexeri  str_valid_typesNzAxisInt | Noneaxisbool	_takeablec                    [        U 5      " U R                  U R                  5      nUb  U R                  R                  U5      nOUnX2l        U$ rD   )typenameobj_get_axis_numberrl   )rF   rl   new_selfaxis_int_nones       rH   __call___LocationIndexer.__call__  sE     :dii2 HH55d;M M%rK   c                <   U R                   S:X  a  U R                  U5        [        U[        5      (       a  U H  n[	        U5        M     U R
                  b!  [        U R                  U R
                  U5      nU R                  R                  S5      n[        U[        5      (       ad  U R                   S:w  aT  [        U5      (       aD  [        U[        5      (       d/  [        [        [        5         UR!                  U5      sSSS5        $ [        U[        5      (       a*  [        ["        5         U R%                  U5      sSSS5        $ [        U[&        5      (       a  [)        U5      nU R+                  USS9$ ! , (       d  f       N}= f! , (       d  f       NO= f)zB
Convert a potentially-label-based key into a positional indexer.
r[   Nr   rV   rl   )rq   _ensure_listlike_indexer
isinstancetuplecheck_dict_or_set_indexersrl   _tupleize_axis_indexerndimrr   	_get_axisr6   r   slicer   KeyErrorr   get_locr   _convert_tuplerangelist_convert_to_indexer)rF   keyxaxs       rH   _get_setitem_indexer%_LocationIndexer._get_setitem_indexer  s1    99))#.c5!!*1-  99 (DIIsCCXX" r:&&		V#C  sE**($56zz# 76 c5!!-(**3/ )( c5!!s)C''!'44 76
 )(s   2E<1F<
F

Fc                   [        U[        5      (       Ga  [        U5      S:X  Ga  [        U[        [        45      (       Gac  Uu  p4UR
                  n[        R                  " U5      (       Ga4  [        U5      [        U5      :X  Ga  UR                  5       S   n[        X@R
                  S-
  5      (       a1  US:X  a+  U R                  R                  R                  X5      nXd4nX4$ [        U[        R                  5      (       a  UR                  R                   S:X  a  [        U5      S:X  ar  US:X  a+  U R                  R                  R                  X5      nXd4nX4$ US:X  a;  UR"                  S   S:X  a(  U R                  R                  R%                  X5      nXd4nX4$ [        R                  " U5      (       a  UR                  5       S   nX4$ )z
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)r{   r|   lenr(   r'   r   comis_bool_indexernonzeror3   rr   rV   _align_seriesnpndarraydtypekindshape_align_frame)rF   indexervaluepiicolsr   newkeys          rH   _maybe_mask_setitem_value*_LocationIndexer._maybe_mask_setitem_value  s    w&&G!59l";<<IB::D""2&&3u:R+@a$UIIM::tqy !HHMM77GE%oG* ~% ubjj11((C/E
aqy !% ; ;G K#)/ ~ u{{1~': $ : :7 J#)/ ~   ))oo'*G~rK   c                   SnU R                   S:w  a  g[        U[        5      (       a  [        U5      S:  a  X   nUnX$:X  Ga  [        U R                  R
                  [        5      (       Gdc  [        U5      (       GaQ  [        R                  " U5      (       Gd4  [        S U 5       5      (       Ga  U R                  R
                  R                  USS9n[        U5      R                  U R                  R
                  SS9n[        U5      (       a  [        R                  " [        U5      [        R                   S9nSU[        U R                  R
                  5      S& U R                  R"                  R%                  XWS	S
S
S9nXR                  l        gU R                  R"                  R'                  US	S
S9U R                  l        gggggg)z
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   Nc              3  8   #    U  H  n[        U5      v   M     g 7frD   )r   .0ks     rH   	<genexpr><_LocationIndexer._ensure_listlike_indexer.<locals>.<genexpr>Z  s     0CqKNNC   F)sortr   r   T)r   rl   
only_sliceuse_na_proxy)rl   r   )r   r{   r|   r   rr   columnsr6   r2   r   r   allunionr5   
differencer   arangeintp_mgrreindex_indexerreindex_axis)	rF   r   rl   r   column_axiskeysdiffr   new_mgrs	            rH   rz   )_LocationIndexer._ensure_listlike_indexer=  s     99>c5!!c#hl "CD txx//<<$S))'',,0C000 88##))#E):D:(()9)9(FD4yy ))CIRWW=35DHH,,-/0((--77dQU 8  !( HHMM66t!PT6UDHHM- 1 - * =  rK   c                  ^  [         (       dR  [        5       (       aC  [        R                  " T R                  5      S::  a  [
        R                  " [        [        SS9  O[         (       d  [        5       (       ds  [        R                  " T R                  5      nSn[        5       (       d  [        T R                  5      (       a  US-  nX4::  a  [
        R                  " [        [        SS9  [        U5        [        U[        5      (       a(  [        S U 5       5      n[        U 4S jU 5       5      nO2[         R"                  " UT R                  5      nT R%                  X5      nT R'                  U5      nT R)                  U5        T R*                  S:X  a  T OT R                  R,                  nUR/                  XbT R*                  5        g )Nr   
stacklevelr   c              3  \   #    U  H"  n[        U5      (       a  [        U5      OUv   M$     g 7frD   r   r   r   r   s     rH   r   /_LocationIndexer.__setitem__.<locals>.<genexpr>  !     F#Q;q>>Qq8#   *,c              3  f   >#    U  H&  n[         R                  " UTR                  5      v   M(     g 7frD   r   apply_if_callablerr   r   r   rF   s     rH   r   r     %     HCq--a::C   .1rV   )r   r
   sysgetrefcountrr   warningswarnr   r   r   r   r   FutureWarningr}   r{   r|   r   r    _check_deprecated_callable_usager   _has_valid_setitem_indexerrq   rV   _setitem_with_indexer)rF   r   r   ctr	ref_countmaybe_callabler   rV   s   `       rH   __setitem___LocationIndexer.__setitem__r  sE   t+--txx(A-+-CPQ 133//$((+CI%''M$((,C,CQ	3]q 	#3'c5!!F#FFCHCHHC 223AN77LC++C0'',yyF*t""7499=rK   c                    [        U 5      e)as  
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   rF   r   rl   s      rH   _validate_key_LocationIndexer._validate_key  s    ( "$''rK   c                   [        S U 5       5      (       am  UR                  [        5      S:  a  [        [        5      e[        U5      U R                  :X  a,  UR                  [        5      nUSU [        4-   XS-   S -   nU$ U$ )z\
If a tuple key includes an Ellipsis, replace it with an appropriate
number of null slices.
c              3  0   #    U  H  o[         L v   M     g 7frD   )Ellipsisr   s     rH   r   4_LocationIndexer._expand_ellipsis.<locals>.<genexpr>  s     *cH}cs   r   N)	anycountr   r   _one_ellipsis_messager   r   index_NS)rF   tupr   new_keys       rH   _expand_ellipsis!_LocationIndexer._expand_ellipsis  s}     *c***yy"Q&#$9::3x499$ IIh'bq'SF*SQ\9 
rK   c                    U R                  U5      nU R                  U5      n[        U5       H  u  p# U R                  X25        M     U$ ! [         a  n[	        SU R
                   S35      UeSnAff = f)z1
Check the key for valid keys across my indexer.
z'Location based indexing can only have [z] typesN)_validate_key_lengthr   	enumerater   
ValueErrorrk   )rF   r   r   r   errs        rH   _validate_tuple_indexer(_LocationIndexer._validate_tuple_indexer  s    
 '',##C(cNDA""1( # 
   ))*'3 s   A
A4A//A4c                   ^ [        S U R                  R                   5       5      (       a)  [        U4S jU R                  R                   5       5      $ g)
Returns
-------
bool
c              3  B   #    U  H  n[        U[        5      v   M     g 7frD   )r{   r6   )r   r   s     rH   r   <_LocationIndexer._is_nested_tuple_indexer.<locals>.<genexpr>  s     BMbz"j))M   c              3  <   >#    U  H  n[        TU5      v   M     g 7frD   )is_nested_tuple)r   r   r   s     rH   r   r     s     H-BsB//-s   F)r   rr   axesrF   r   s    `rH   _is_nested_tuple_indexer)_LocationIndexer._is_nested_tuple_indexer  s:     BDHHMMBBBH$((--HHHrK   c           	         U R                  U5        [        U5       VVs/ s H  u  p#U R                  X2S9PM     nnn[        U5      $ s  snnf Nry   )r   r   r   r|   )rF   r   r   r   keyidxs        rH   r   _LocationIndexer._convert_tuple  sJ     	!!#&BKC.Q.$!$**1*5.QV} Rs   A	c                    [        U5      U R                  :  aF  US   [        L a/  USS  n[        U;   a  [        [        5      eU R                  U5      $ [        S5      eU$ )Nr   r   Too many indexers)r   r   r   r   r   r   rF   r   s     rH   r   %_LocationIndexer._validate_key_length  s^    s8dii1v!!"gs?'(=>>0055 344
rK   c                   U R                   nU R                  [        U5      -
  S-   n[        [	        U5      5       Hr  u  pEU R                  U-
  U-
  n[
        R                  " U5      (       a  M4  [        X R                  5      R                  XTS9nUR                  U R                  :X  a  Mr   e   X R                   L a  UR                  SS9nU$ )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   ry   Fdeep)rr   r   r   r   reversedr   is_null_slicegetattrrq   _getitem_axiscopy)rF   r   retval	start_valr   r   s         rH   _getitem_tuple_same_dim(_LocationIndexer._getitem_tuple_same_dim  s     YYS)Q.	.FA		A	)A  %%VYY/==c=JF ;;$))+++ / XX [[e[,FrK   c                   U R                   b4  U R                  R                  U R                   5      nU R                  XS9$ U R	                  U5      (       a  U R                  U5      $ U R                  R                  S5      n[        U[        5      (       a_  U R                  S:w  aO  [        S U 5       5      (       d8  [        [        5         [        [        U 5      R                  U5      sS S S 5        $ U R!                  U5      n[#        U5       H  u  pE[%        U5      (       d  M  U R                  XTS9nUR&                  U R&                  :X  a  US U [(        4-   XS-   S  -   nO!US U XS-   S  -   n[+        U5      S:X  a  US   n[,        R.                  " U5      (       a  Us  $ [1        X`R                  5      U   s  $    [        S5      e! , (       d  f       N= f)Nry   r   rV   c              3  B   #    U  H  n[        U[        5      v   M     g 7frD   r{   r   r   s     rH   r   5_LocationIndexer._getitem_lowerdim.<locals>.<genexpr>  s     :c
1e,,cr   r   znot applicable)rl   rr   rs   r  r   _getitem_nested_tupler   r{   r6   rq   r   r   r   r   r\   "_handle_lowerdim_multi_index_axis0r   r   is_label_liker   r   r   r   r
  r  )rF   r   rl   ax0r   r   sectionr   s           rH   _getitem_lowerdim"_LocationIndexer._getitem_lowerdim  s    99 88,,TYY7D%%c%55 ((----c22 hh  # sJ''		V#:c::: -(K.QQRUV )( '',nFAS!! ,,S,9
 <<499, ""1g.UW=G ""1gEG4G7|q(")!* $$W--"Nw		27;;9 %< ,--G )(s   G
Gc                ^  ^ SS jmU H  n[        U5        M     [        U5      U R                  :  a  U R                  S:w  a  [	        S5      e[        U4S jU 5       5      (       a8  [        [        5         [        [        U 5      R                  U5      sS S S 5        $ [        U R                  [        5      (       a"  [        S U 5       5      (       a  [        S5      eU R                  =(       d    SnU R!                  XS9$ U R                  n[        U5      S	-
  nUS S S
2    Hp  n["        R$                  " U5      (       a  US	-  nM%  ['        X@R                  5      R!                  X#S9nUS	-  n[)        U5      (       d  [+        US5      (       a  Mo    U$    U$ ! , (       d  f       N= f)Nc                ~    [        U [        5      (       a  [        S U  5       5      $ [        U [        5      (       a  gg)Nc              3  B   #    U  H  n[        U[        5      v   M     g 7frD   r  r   vs     rH   r   R_LocationIndexer._getitem_nested_tuple.<locals>._contains_slice.<locals>.<genexpr>M  s     ;A:a//r   TF)r{   r|   r   r   )r   s    rH   _contains_slice?_LocationIndexer._getitem_nested_tuple.<locals>._contains_sliceJ  s3    !U##;;;;Au%%rK   r[   zToo many indicesc              3     >#    U  HA  n[        U5      =(       a    T" U5      (       + =(       d    [        R                  " U5      v   MC     g 7frD   )r   r   r
  )r   r   r#  s     rH   r   9_LocationIndexer._getitem_nested_tuple.<locals>.<genexpr>\  s=      A Q:(:$:Ss?P?PQR?SSs   A	Ac              3  B   #    U  H  n[        U[        5      v   M     g 7frD   r{   r|   r   s     rH   r   r&  g  s      9.1
1e$$cr   r  r   ry   r   r   r   )r   objectrf   rm   )r}   r   r   rq   r   r   r   r   r   r\   r  r{   rr   r(   r   rl   r  r   r
  r  r#   hasattr)rF   r   r   rl   rr   r#  s        @rH   r  &_LocationIndexer._getitem_nested_tupleE  s   
	 C&s+  s8diiyyE! !344    m,T2UU -, DHHi00S 9.19 6 6 $$788 99>D%%c%55 hh 3x!|tt9C  %%	#yy)777GCAID ~~WS&%9%9
  
K -,s   8F
F,c                    [        U 5      erD   r   r   s      rH   r   $_LocationIndexer._convert_to_indexer      !$''rK   c                    U R                   S:X  aG  [        U5      (       a7  [        U[        5      (       a"  [        R
                  " S[        [        5       S9  U$ )NrV   zaReturning a tuple from a callable with iloc is deprecated and will be removed in a future versionr   )rq   callabler{   r|   r   r   r   r   )rF   r   r   s      rH   r   1_LocationIndexer._check_deprecated_callable_usage  sF    998C==ZPU5V5VMMH+-	 rK   c                  ^  [        U5        [        U5      [        L at  [        S U 5       5      n[        U 4S jU 5       5      nT R                  U5      (       a&  T R                  R
                  " UST R                  06$ T R                  U5      $ T R                  =(       d    Sn[        R                  " UT R                  5      nT R                  X5      nT R                  X2S9$ )Nc              3  \   #    U  H"  n[        U5      (       a  [        U5      OUv   M$     g 7frD   r   r   s     rH   r   /_LocationIndexer.__getitem__.<locals>.<genexpr>  r   r   c              3  f   >#    U  H&  n[         R                  " UTR                  5      v   M(     g 7frD   r   r   s     rH   r   r4    r   r   takeabler   ry   )r}   rp   r|   _is_scalar_accessrr   
_get_valuern   _getitem_tuplerl   r   r   r   r  )rF   r   rl   r   s   `   rH   rI   _LocationIndexer.__getitem__  s    "3'9F#FFCHCHHC%%c**xx**CI$..II&&s++ 99>D 223AN!BB3WN%%n%@@rK   c                    [        5       erD   NotImplementedErrorr  s     rH   r7  "_LocationIndexer._is_scalar_access      !##rK   c                    [        U 5      erD   r   r   s     rH   r9  _LocationIndexer._getitem_tuple  r.  rK   c                    [        5       erD   r<  r   s      rH   r  _LocationIndexer._getitem_axis  r?  rK   c                    [        U 5      erD   r   rF   r   s     rH   r   +_LocationIndexer._has_valid_setitem_indexer  r.  rK   c                    U R                   R                  U5      n[        X15      nUR                  5       S   nU R                   R	                  XBS9$ )Nr   ry   )rr   r   check_bool_indexerr   _take_with_is_copy)rF   r   rl   labelsindss        rH   _getbool_axis_LocationIndexer._getbool_axis  sJ     ##D) -{{}Qxx**4*;;rK   rE   rD   )rl   zAxis | Nonerf   r;   NNrf   Nonerl   r:   )r   r|   rf   r|   )r   r|   rf   r|   r   r|   rf   rm   r   r|   )r   r   r   r?   rf   r?   )r   r|   rf   rm   )rL   rM   rN   rO   __annotations__rl   r	   rv   r   r   rz   r   r   r   r   r   r   r   r  r  r  r   r   rI   r7  r9  r  r   rL  rQ   rE   rK   rH   ri   ri     sb   D. O
	 	$5L , ,\ 2V 2Vh > ><(,  *        	 	  6 :. :.x B BH(	 A A $($( < <rK   ri   c                      \ rS rSr% SrS\S'   Sr\" \R                  5      SS j5       r	SS jr
SS jrSS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)r\   i  Frm   rn   zlabels (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                (   U R                   R                  U5      n[        U[        5      (       a  [	        UR
                  5      (       df  UR
                  R                  S:X  dL  [        U[        5      (       a)  [	        UR                  S5      R
                  5      (       d  [        U S35      e[        U[        5      (       aM  [        UR                  [        5      (       d  [        UR                  [        5      (       a  [        U S35      eg g )Nbooleanr   z7: boolean label can not be used without a boolean indexz+: boolean values can not be used in a slice)rr   r   r{   rm   r   r   rq   r6   get_level_valuesr   r   startstop	TypeError)rF   r   rl   r   s       rH   r   _LocIndexer._validate_key  s     XX%c4  "((##xx}}	)"j))b11!4::;;%NO  c5!!syy$'':chh+E+Ese#NOPP ,F "rK   c                    g)NTrE   rE  s     rH   r   &_LocIndexer._has_valid_setitem_indexer  s    rK   c                Z   [        U5      U R                  :w  a  g[        U5       H  u  p#[        U5      (       d    gU R                  R
                  U   n[        U[        5      (       a    g[        U[        5      (       a  UR                  (       a    gUR                  (       a  M    g   g)r   FT)r   r   r   r#   rr   r   r{   r6   rj   !_supports_partial_string_indexing_index_as_unique)rF   r   r   r   r   s        rH   r7  _LocIndexer._is_scalar_access  s     s8tyy cNDAQ<<q!B"j))!S!!b&J&J &&& #  rK   c                `    [        S U 5       5      (       d  g[        S U 5       5      (       + $ )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`.
c              3  8   #    U  H  n[        U5      v   M     g 7frD   )r2   r   s     rH   r   6_LocIndexer._multi_take_opportunity.<locals>.<genexpr>  s     8Cq'**Cr   Fc              3  N   #    U  H  n[         R                  " U5      v   M     g 7frD   )r   r   r   s     rH   r   rf    s     ;s!s**1--ss   #%)r   r   r   s     rH   _multi_take_opportunity#_LocIndexer._multi_take_opportunity  s.    $ 8C888 ;s;;;;rK   c           	         [        XR                  R                  5       VVs0 s H  u  p#X0R                  X#5      _M     nnnU R                  R	                  USSS9$ s  snnf )aQ  
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)ziprr   _AXIS_ORDERS_get_listlike_indexer_reindex_with_indexers)rF   r   r   rl   ds        rH   _multi_take_LocIndexer._multi_take  sf    &  #3(=(=>
> ,,S77> 	
 
 xx..qt.MM	
s   Ac                    U R                  X5        U R                  X5      u  p4U R                  R                  X#U/0SSS9$ )ai  
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).
Trk  )r   ro  rr   rp  )rF   r   rl   keyarrr   s        rH   _getitem_iterable_LocIndexer._getitem_iterable6  sQ    . 	3% 44S?xx..G$%DT / 
 	
rK   c                ,   [        [        5         U R                  U5      nU R                  U5      sS S S 5        $ ! , (       d  f       O= fU R	                  U5      nU R                  U5      (       a  U R                  U5      $ U R                  U5      $ rD   )r   r   r   r  r   rh  rr  r  r   s     rH   r9  _LocIndexer._getitem_tupleU  s{    m$'',C))#. %$$
 **3/ '',,##C((++C00s	   "<
A
c                4    U R                   R                  XS9$ r   )rr   xs)rF   labelrl   s      rH   
_get_label_LocIndexer._get_labelc  s    xx{{5{,,rK   c                   U R                   =(       d    Sn U R                  XS9$ ! [         aS  nU R                  [	        U5      s=:  a&  U R
                  R                  R                  ::  a   Ue  [        S5      UeS nAff = f)Nr   ry   zNo label returned)	rl   r}  r   r   r   rr   r   nlevelsr   )rF   r   rl   eks       rH   r  ._LocIndexer._handle_lowerdim_multi_index_axis0g  sr    yy~A		=??3?22 	= yy3s8=txx~~'='== > 34"<	=s   & 
BAA>>Bc                   [        U5      n[        U5      (       a  [        U5      nU[        L a  [	        S 5      nU R
                  R                  U5      n[        U[        5      (       a   [        U[        5      (       a  [        U5      n[        U[        5      (       a   U R                  X5        U R                  XS9$ [        R                  " U5      (       a  U R                  XS9$ [        U5      (       a  [        U[        5      (       a  [        U[        5      (       d;  [!        US5      (       a  UR"                  S:  a  [%        S5      eU R'                  XS9$ [)        X5      (       aP  UR+                  U5      n[	        S 5      /U R"                  -  nXEU'   U R
                  R,                  [        U5         $ U R                  X5        U R/                  XS9$ )Nry   r   r   z&Cannot index with multidimensional key)r   r   r   r   r   rr   r   r{   r|   r6   r   _get_slice_axisr   r   rL  r2   r*  r   r   rv  r   get_locsrV   r}  )rF   r   rl   rJ  locsr   s         rH   r  _LocIndexer._getitem_axisu  s   $ss)C(?+C##D)c5!!j&D&D*Cc5!!s)'''77  %%%%c%55!#&&sE**z&*/M/M3''CHHqL$%MNN--c-== s++s+?DT{mdii>W $xx}}U7^44 	3%s..rK   c                j   U R                   n[        U5      (       d  UR                  SS9$ UR                  U5      nUR	                  UR
                  UR                  UR                  5      n[        U[        5      (       a  U R                   R                  XRS9$ U R                   R                  XRS9$ )z<
This is pretty simple as we just have to deal with labels.
Fr  ry   )rr   
need_slicer  r   slice_indexerrZ  r[  stepr{   r   _slicetake)rF   	slice_objrl   rr   rJ  r   s         rH   r  _LocIndexer._get_slice_axis  s    
 hh)$$888''t$&&y		Wgu%%88??7?66 88===44rK   c                4   U R                   R                  U5      n[        U[        5      (       a  UR	                  USS9$ [        U[
        5      (       a?  [        U[        5      (       d*  U R                  S:  a  [        U5      S:  a  [        S5      eSn[        U[
        5      (       a  [        S U 5       5      n[        U5      (       d,  [        U[        5      (       a)  [        U5      (       a  U(       d   UR                  U5      $ ['        X5      (       aC  U R                  S:X  a"  [        S	 U 5       5      (       a  [        S5      eUR)                  U5      $ [+        U5      (       aW  [-        U5      (       a  [/        U5      n[0        R2                  " U5      (       a  [5        X15      nU$ U R7                  X5      S   $  UR                  U5      $ ! [         aN    [        U[
        5      (       a5  [        U[        5      (       a   [        U5      UR                  :X  a  SU0s $ e  GN#[          a    [        U[        5      (       d  e  GNE["         a    [%        U5      (       d  e SU0s $ f = f! [         a    [+        U5      (       d  SU0s $ e f = f)
ay  
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
r[   )r   r   r   r  Fc              3  B   #    U  H  n[        U[        5      v   M     g 7frD   r  r   s     rH   r   2_LocIndexer._convert_to_indexer.<locals>.<genexpr>  s      Cs!Au!5!5sr   r   c              3  B   #    U  H  n[        U[        5      v   M     g 7frD   r(  r   s     rH   r   r    s     %HCqjE&:&:Cr   )rr   r   r{   r   _convert_slice_indexerr|   r6   r   r   r   r   r#   r   r   LookupErrorr  r   r   r   r   r  r2   r   r   r   r   rH  ro  )rF   r   rl   rJ  contains_slices        rH   r   _LocIndexer._convert_to_indexer  s*    ##D)c5!!0050AA sE""vz22		AC1 344 c5!!  Cs CCNS>>vz**{3/?/?
$~~c** 3''yyA~#%HC%H"H"H#$788??3''!#&&33i""3''(5
11#<Q??~~c**?  c5))j.L.L3x6>>1 %s|+$ !&*55 6 $!#s|#$.  +C00!3<'	s7   ;G I5 AI2+I2/I2I21I25JJc                    U R                   R                  U5      nU R                   R                  U5      nUR                  X5      u  pVXV4$ )a  
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.
)rr   r   _get_axis_name_get_indexer_strict)rF   r   rl   r   	axis_nameru  r   s          rH   ro  !_LocIndexer._get_listlike_indexer  sF    . XX%HH++D1	00@rK   rE   N)rl   r9   rT  r   r|   rf   rm   rR  rS  rQ  r  r   rl   r:   )rL   rM   rN   rO   rn   rU  rk   r   ri   r   r   r7  rh  rr  rv  r9  r}  r  r  r  r   ro  rQ   rE   rK   rH   r\   r\     sy    It	:  			'	'(Q )Q*D<0N2
>1-="/H5&N`rK   r\   c                      \ rS rSrSrSrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrS rS S!S jjrS!S jrS rS"S jrS#S jrS$S jrS rS r  S%     S&S jjrS'S jrSrg)(rW   i  zlinteger, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean arrayTc                   [         R                  " U5      (       aa  [        US5      (       aO  [        UR                  [
        5      (       a0  UR                  R                  S:X  a  [        S5      e[        S5      eg [        U[        5      (       a  g [        U5      (       a  U R                  X5        g [        U[        5      (       a  [        S5      e[        U5      (       a  [        U[        5      (       a  UR                   nO)[#        U5      (       a  UnO[$        R&                  " U5      n[)        U R*                  R-                  U5      5      n[/        UR0                  5      (       d  [3        SU 35      e[)        U5      (       a5  UR5                  5       U:  d  UR7                  5       U* :  a  [3        S5      eg g [        SU R8                   S	35      e)
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*  r{   r   r5   inferred_typer=  r   r   r   _validate_integerr|   r   r2   r(   _valuesr   r   r/   r   rr   r   r!   r   
IndexErrormaxminrk   )rF   r   rl   arrlen_axiss        rH   r   _iLocIndexer._validate_key&  s   s##sG$$CIIu)E)E99**i7-+ 
 !-  c5!!__""3-U##   344!#&&#y))kks##hhsm488--d34H $CII.. #H!NOO 3xxSWWY(2cggi8)6K !HII 7Lx B4CTCTBUUVWXXrK   c                   [        U[        5      (       a  [        S5      e[        U[        5      (       a  [	        S5      e[        U[
        5      (       d  [        U R                  U5      n[        U R                  R                  U5       Hz  u  p#[        U[        5      (       a  M  [        U5      (       a  M.  [        U5      (       a  U[        U5      :  a  [        S5      eMZ  [        U[        5      (       d  Mq  [        S5      e   g)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)r{   dictr  r'   r\  r|   _tuplifyr   rm  rr   r   r   r2   r   r   )rF   r   r   r   s       rH   r   '_iLocIndexer._has_valid_setitem_indexerP  s     gt$$DEEg|,,X 
 '5))tyy'2G0EB!U##%a((AB<$%LMM  At$$ !HII 1 rK   c                Z    [        U5      U R                  :w  a  g[        S U 5       5      $ )r   Fc              3  8   #    U  H  n[        U5      v   M     g 7frD   )r   r   s     rH   r   1_iLocIndexer._is_scalar_access.<locals>.<genexpr>  s     .#Q:a==#r   )r   r   r   r  s     rH   r7  _iLocIndexer._is_scalar_accesst  s(     s8tyy .#...rK   c                x    [        U R                  R                  U5      5      nX:  d  X* :  a  [        S5      eg)z
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   rr   r   r  )rF   r   rl   r  s       rH   r  _iLocIndexer._validate_integer  s9      txx))$/0?cIoIJJ .rK   c                    U R                  U5      n[        [        5         U R                  U5      sS S S 5        $ ! , (       d  f       O= fU R	                  U5      $ rD   )r   r   r   r  r  r   s     rH   r9  _iLocIndexer._getitem_tuple  sG    **3/m$))#. %$$ ++C00s	   <
A
c                r     U R                   R                  XS9$ ! [         a  n[        S5      UeSnAff = f)z
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.
ry   r  N)rr   rI  r  )rF   r   rl   r   s       rH   _get_list_axis_iLocIndexer._get_list_axis  s@    "	O88..s.>> 	ODE3N	Os    
616c                   U[         L a  [        S 5      nO [        U[        5      (       a  [	        S5      e[        U[        5      (       a  U R                  XS9$ [        U5      (       a  [        U5      n[        U[        5      (       a  [        R                  " U5      n[        R                  " U5      (       a   U R                  X5        U R                  XS9$ [        U5      (       a  U R                  XS9$ [!        U5      n[#        U5      (       d  [%        S5      eU R'                  X5        U R(                  R+                  XS9$ )NzWDataFrame indexer is not allowed for .iloc
Consider using .loc for automatic alignment.ry   z5Cannot index by location index with a non-integer key)r   r   r{   r'   r  r  r   r   r   asarrayr   r   r   rL  r2   r  r   r   r\  r  rr   _ixsr   s      rH   r  _iLocIndexer._getitem_axis  s   (?+C\**? 
 c5!!'''77ss)Cc4  **S/Cs##s)%%c%55 "#&&&&s&66 $C(Cc?? WXX ""3-88===00rK   c                    U R                   n[        U5      (       d  UR                  SS9$ UR                  U5      nUR	                  U5        U R                   R                  XS9$ )NFr  ry   )rr   r  r  r   _validate_positional_slicer  )rF   r  rl   rr   rJ  s        rH   r  _iLocIndexer._get_slice_axis  sX    hh)$$888''t$)))4xxy44rK   c                    U$ )z<
Much simpler as we only have to deal with our valid types.
rE   r   s      rH   r    _iLocIndexer._convert_to_indexer  s	     
rK   c                    [        U5      (       a  [        U5      nU R                  b!  [        U R                  U R                  U5      nU$ rD   )r   r   rl   r~   r   r  s     rH   r   !_iLocIndexer._get_setitem_indexer  s;    ss)C99 (DIIsCC
rK   c                   U R                   R                  nU R                   R                  R                  (       + nU(       d0  [	        U[
        5      (       a  UR                  R                  (       + nU(       d  [        U R                   R                  R                  5      (       a|  U R                  S:  al  [	        U[        5      (       a  [        UR                  5       5      OUnU R                   R                  R                  S   n[        U[        USS95      (       + n[	        U[        5      (       a  [        U5      [        U R                   R                  5      :X  ap  [!        XR                   R                  5       HM  u  p[	        U	["        5      (       d  M  [%        U5      (       a  M.  [&        R(                  " U5      (       a  MK  Sn  O   [	        U[        5      (       Ga{  / n
[+        U5       GH]  u  p[	        U[        5      (       Ga0  [-        U5      u  pU R                  S:  Ga  X:X  Ga  [        U R                   5      (       d+  [/        U5      (       d  [1        S5      eX R                   U'     g[&        R(                  " US   5      (       a  X R                   U'     g[3        U5      (       a  [        USS9nS[4        R6                  " [        U R                   5      [4        R8                  S9-  n[:        R<                  " X~5      n[	        U[>        5      (       dZ  [	        U[4        R@                  5      (       a$  UR                  S:X  a  [        U5      S:X  a  US	   nXUS   '   XR                   U'     gXR                   U'   OU[C        U5      (       d-  [E        U[        U R                   5      5      U R                   U'   O[G        U5      U R                   U'   [I        XR                   R                  5      nU RK                  UX#5          gU R                   RM                  U5      n[N        RP                  " 5          [N        RR                  " S
S[T        S9  URW                  [        U5      U5      nSSS5        [4        RX                  " [        U5      S-   [4        R8                  S9nSUS'   UWU40nU R                   R[                  USS9nUR                  U R                   l        U R                   R]                  SS9  SU R                   l/        U
Ra                  URc                  U5      5        GML  U
Ra                  U5        GM`     [        U
5      nO'[-        U5      u  nnU(       a  U Re                  X5        gUS:X  a  U Rg                  X5      u  pU(       a  U Ri                  XU5        gU Rk                  XU5        g! , (       d  f       GNZ= f)am  
_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   r   T)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)rl  clearr[   )6rr   _info_axis_numberr   is_single_blockr{   r'   r   arraysr   r  r   valuesr   r0   r|   r   rm  r6   r   r   r
  r   convert_missing_indexerr2   r   r   r   onesr   algostake_ndr(   r   r    r)   r*   "convert_from_missing_indexer_tupler   r   r   catch_warningsfilterwarningsr   insertr   rp  _maybe_update_cacher_is_copyappendr   _setitem_with_indexer_missingr    _setitem_with_indexer_split_path_setitem_single_block)rF   r   r   rq   	info_axistake_split_pathvalr  r   r   nindexeridxr   _takerempty_valuenew_indexerr   rJ  
reindexersnew_objmissings                         rH   r   "_iLocIndexer._setitem_with_indexer  so    HH..	 #hhmm;;;:e\#B#B"'**"<"<<O 3txx}}';';#<#<Q*4UD*A*A$u||~&uC((--&&q)C"2]3d;# O gu%%#g,#dhhmm:L*LWhhmm4b*--qMMS%6%6q%9%9&*O 5 gu%%H#G,c4(( 5S9FC yy1}
  #488}}#7#>#>&0%A'" !" -2HHSM" ,,WQZ88,1HHSM"*511"/T"JC$&TXXbgg)N$NE*/--*CK#-eY#?#? %/sBJJ$?$?(+A(+CA +.f+C:=GAJ 70; &,7HHSM!-e!4!4,W %s488}-DHHSM
 -=U,CDHHSM&H#XX]]' 22;L !HH..q1E!002 //$,%2	 "'c%j#!> 3 IIc%j1nBGGDE "E"I"#fe_!5J"hh=="t > G %,LLDHHMHH111=(,DHH%OOFNN3$78 OOC(A -D HoG6w?GW227B5=!;;GKNG 11'$G&&wt<[ 32s   
6W
W"	c                B   U R                   S:X  d   e[        U[        5      (       d  [        U R                   U5      n[	        U5      U R                   :  a  [        S5      e[        US   [        R                  5      (       a  US   R                   S:  a  [        S5      e[        U[        5      (       a  US:w  d  [        U[        5      (       a  SSKJn  U R                  X" U5      5      nUS   nU R                  U5      nUS   n[        XpR                   R"                  5      n[%        U5      (       GaK  ['        USS5      S:  Ga9  [        U[(        5      (       a  U R+                  XU5        g
[        R                   " U5      S:X  a  U R-                  X5        g
[	        U5      S:X  a5  U[	        U5      :X  a&  [/        U5      (       d  U R1                  US   X'5        g
[	        U5      S:X  a\  SUs=:w  a  [	        U5      :w  aF  O  OC[	        U5      S:X  a)  [3        U5      (       d  U R5                  XuS   4US   5      $ [        S	5      eUS:X  a-  [	        U5      [	        U R                   R"                  5      :X  a  g
U R7                  U5      (       aJ  [9        U R                   R:                  R<                  US      5      (       a  U R1                  US   X'5        g
[	        U5      [	        U5      :X  a'  [?        Xb5       H  u  pU R1                  XU5        M     g
[	        U5      S:X  aJ  [@        RB                  " U5      (       a/  [	        U R                   5      S:X  a  U R1                  US   X'5        g
[        S	5      eU H  n	U R1                  XU5        M     g
)z
Setitem column-wise.
r   ztoo many indices for arrayr   zCannot set values with ndim > 2rV   r>   r   r   z@Must have equal len keys and value when setting with an iterableN)"r   r{   r|   r  r   r  r   r   r   r(   r  pandasr>   r   _ensure_iterable_column_indexerr4   rr   r   r2   r  r'   !_setitem_with_indexer_frame_value_setitem_with_indexer_2d_valuer#   _setitem_single_columnr   r   r7  r"   dtypesr  rm  r   r
  )rF   r   r   rq   r>   r  ilocsr   lplane_indexerr[   r!  s              rH   r  -_iLocIndexer._setitem_with_indexer_split_path  s   
 yyA~~'5))tyy'2Gw<$))#9::gaj"**--'!*//A2E?@@ui((TV^
5RV@W@W%&&wu>E AJ	44Y?QZ*2xx~~>
  &&75&!+Dq+H%..66wtL1$ 33GCUq^s5z%A)TV--++E!He@UqQ.%FCJ%F
 u:?:i+@+@  55rQ<6H%PQ(SS 4 
  1$Us488>>7J)J''00_''a16 6 ++GAJBUs5z)!%/FC//; 0 UqS%6%6r%:%:s488}PQ?Q ++E!He@ !4  ++C; rK   c                   US   nU R                  US   5      n[        U5      (       d  [        R                  " U[        S9n[        U5      UR                  S   :w  a  [        S5      e[        U5       HJ  u  pVUS S 2U4   n[        UR                  5      (       a  UR                  5       nU R                  XgU5        ML     g )Nr   r   r   z?Must have equal len keys and value when setting with an ndarray)r  r   r   r/   r)  r   r   r   r   r"   r   tolistr  )rF   r   r   r   r  r   r[   	value_cols           rH   r  +_iLocIndexer._setitem_with_indexer_2d_value  s     QZ44WQZ@U##HHU&1Eu:Q'Q   &FAadIy//%,,.	''; 'rK   c                   U R                  US   5      n[        U5      nUS   n[        U R                  R                  [
        5      nUR                  R                  nUS:X  a:  [        U5       H*  u  pUR                  S S 2U	4   nU R                  XU5        M,     g U(       d  UR                  R                  U R                  R                  5      (       a|  U Hu  n
U R                  R                  U
   nX;   a2  XS'   U R                  [        U5      UR                  S S 2U
4   U5      nO[        R                  nU R                  XU5        Mw     g U(       d  [        S5      eU Hm  n
U R                  R                  U
   nX;   a*  XS'   U R                  [        U5      X,   U[!        5       S9nO[        R                  nU R                  XU5        Mo     g )Nr   r   rV   z/Setting with non-unique columns is not allowed.)	using_cow)r  r   r{   rr   r   r6   	is_uniquer   rV   r  equalsr   r|   r   nanr   r
   )rF   r   r   rq   r  sub_indexerr   multiindex_indexerunique_colsr   r[   r  items                rH   r  ._iLocIndexer._setitem_with_indexer_frame_value  s   44WQZ@7mQZ'(8(8*Emm-- 6>#E*jjA&++Cb9 + !5!5dhh6F6F!G!G xx'',=%)N,,k*

1c6**C &&C++Cb9  NOO xx'',=%)N,,k**"5"7	 - C &&C++Cb9 rK   c                L   Un[         R                  " U5      =(       d*    [         R                  " U[        U R                  5      5      n[         R
                  " U5      =(       d     [        U5      =(       a    [        U5      S:H  nU(       a  gU(       a'   U R                  R                  R                  XUSS9  OU R                  R                  R                  U   nU[        R                  :X  a:  [/        U[        U R                  5      5      U R                  R                  SS2U4'   U R                  R                  R                  XU5        U R                  R1                  5         g! [        [        [        4 a    U R                  R                  R                  U   nU[        R                  [         4;  aD  U R                  R"                  (       d)  [$        R&                  " SU SU S3[(        [+        5       S9  U R                  R-                  X5         Nf = f)	z

Parameters
----------
loc : int
    Indexer for column position
plane_indexer : int, slice, listlike[int]
    The indexer we use for setitem along axis=0.
r   NT)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   rr   is_empty_slicer   r   column_setitemr   r\  r   r  rV   r   voidr)  emptyr   r   r   r   isetitemr)   _clear_item_cache)rF   r[   r   plane_indexerr   is_full_setteris_null_setterr   s           rH   r  #_iLocIndexer._setitem_single_column?  s    **2.V#2C2CBDHH2V++B/U=3D3URTU.,,D - > HHOO((-E )T3txx=)af% HHMM((UC""$S 	+<= . ,,S1& 11$((.. MM""'(Fug NNN &#3#5 !!#-1.s   %E/ /B1H#"H#c                   SSK Jn  [        U[        5      (       a  US:w  d  [        U[        5      (       a  U R                  X" U5      5      nU R                  R                  nU R                  R                  U5      n[        U[        5      (       a  U R                  [        U5      s=:X  a  S:X  a  O  O~[        US   5      (       ak  [        R                  " US   5      (       aM  XaU      n[        UR                  U/5      5      S:X  a'  UR!                  U5      nU R#                  XUS   5        g[%        U6 n[        U[&        5      (       a!  US:w  a  U R)                  X5      R*                  nU R                  R-                  5         U R                  R.                  R1                  XS9U R                  l        U R                  R3                  SSS	9  g)
zA
_setitem_with_indexer for the case when we have a single Block.
r   r  rV   r   r   N)r   r   T)r  inplace)r  r>   r{   r(   r  r   rr   r  r   r|   r   r   r   r   r
  get_indexer_forr   r  maybe_convert_ixr'   r   r  %_check_is_chained_assignment_possibler   setitemr  )	rF   r   r   rq   r>   r  item_labelscolr[   s	            rH   r  "_iLocIndexer._setitem_single_block  sw    	"ui((TV^
5RV@W@W &&wu>EHH..	hh((3gu%%
 		S\.Q.wqz**%%gaj11!)"45{22C59:a?%--c2C//GAJG&0Ge\**tv~%%g5==E 	668 --g-K%%D$%?rK   c                	   SSK Jn  U R                  S:X  Ga  U R                  R                  n[
        R                  " 5          [
        R                  " SS[        S9  UR                  [        U5      U5      nSSS5        UR                  (       a>  UR                  WSS 5      nUS:g  R                  5       (       a  U R                  XbS	5      $ [        U5      (       d  SnGO[!        X R                  R"                  5      (       af  [%        U R                  R"                  5      (       d  ['        U R                  R"                  S
S9n[)        U R                  R"                  U5      S   nO[+        U5      (       a  SnOsU R                  R,                  (       dV  [%        U R                  R"                  5      (       d2  U R                  R"                  n[/        USU5      n[)        X5      S   nOSnU" U/US9R0                  n	[        U R                  R0                  5      (       a!  [3        U R                  R0                  U	/5      n	U R                  R5                  U	WU R                  R6                  S9R8                  U R                  l        U R                  R;                  SS9  gU R                  S:X  Ga  [        U R                  R<                  5      (       d  [?        S5      e[A        US5      n
[C        U[D        5      (       a+  URG                  U R                  R<                  SS9nXl        O[C        U[H        5      (       a!  U" X R                  R<                  U[J        S9nOb[M        U5      (       a7  [        U5      [        U R                  R<                  5      :w  a  [?        S5      eU" X R                  R<                  US9n[        U R                  5      (       d  URO                  5       RP                  nU R                  R                  n[C        U[R        5      (       a  URT                  nOUR6                  n[W        U/US9Ul        U
(       d  URY                  S
S9nUR8                  U R                  l        O4U R                  R[                  U5      R8                  U R                  l        U R                  R;                  SS9  gg! , (       d  f       GNh= f)z>
Insert new row(s) or column(s) into the Series or DataFrame.
r   r  r   r  r  r  Nr   r[   F)compatnumpy_dtyper   )r   rq   Tr  r   z*cannot set a frame with no defined columnsr   )r   r  )r   rq   r   z(cannot set a row with mismatched columns)rq   r  ).r  r>   r   rr   r   r   r  r  r   r  r   r  get_indexerr   r   r#   r+   r   r"   r-   r   r,   r  r  r  r%   _constructorrq   r   r  r   r   r*  r{   r(   reindexr  r)  r2   to_framer?   r6   namesr5   infer_objects_append)rF   r   r   r>   r   	new_indexr  	new_dtype
curr_dtype
new_values	has_dtypedfr  rq   s                 rH   r  *_iLocIndexer._setitem_with_indexer_missing  s    	" 99>HHNNE((*''R*
 "LLUW=	 +  $//	"#?2%**,,55k%PP U## 	&uhhnn==&txx~~66.txx~~eLE)$((..%@C	e 	XX^^ODHHNN,K,K "XX^^
$Z
K
)*<Q?	 	y9AAJ488##$$ +DHH,<,<j+IJ
 HH11)$((-- 2 d HHM HH)))5YY!^txx''(( !MNNw/I%++DHH,<,<4H$
E4((!1!1v
 (..5zS)9)9%::()STTuHH,<,<7Ktxx== ^^%''hhnnc:..99D88D '6  ))u)5B " $ 0 0 7 < <HH)))5U q +*s   6S
S)c                   [        U5      (       a  U/nU$ [        U[        5      (       a8  [        R                  " [        U R                  R                  5      5      U   nU$ [        U[        R                  5      (       a>  UR                  R                  S:X  a$  [        R                  " [        U5      5      U   nU$ UnU$ )zH
Ensure that our column indexer is something that can be iterated over.
b)r   r{   r   r   r   r   rr   r   r   r   r   )rF   column_indexerr  s      rH   r  ,_iLocIndexer._ensure_iterable_column_indexer	  s    
 n%%#$E  ..IIc$(("2"234^DE  ~rzz22~7K7K7P7PTW7WIIc.12>BE  #ErK   c                   [        U[        [        R                  [        [
        45      (       a  U4n[        U[        5      (       Ga  S n[        [        XQ5      5      nU Vs/ s H  n[        R                  " U5      (       + PM      nn[        U5      nUS:H  n	U R                  S:H  n
U R                  nU
(       a  U	=(       a    US   n	XR                  :X  a  [        S U 5       5      (       a  UR                  UR                  S   US      SS9R                   n[#        U5      S:  aE  U(       d>  [#        US   5      n[        R$                  " X5      R'                  US5      R(                  nU$ [+        U5       GHv  u  pUR                  U   n[-        U5      (       d  [        U[        5      (       a  U	(       a  [        R                  " U5      (       a  M^  X   n[/        U5      (       d  [        U/5      nO[        U5      nUR0                  R3                  U5      (       a'  U(       a  Us  $ UR                   R5                  5       s  $ UR                  U5      R                   s  $ U	(       d  M  U R                  R                  S   nUR0                  R3                  U5      (       d  [#        U5      (       d  UR                   R5                  5       s  $ UR                  U5      R                   s  $    GO9[7        U5      (       a  U R                  S:X  a  [9        U R                  R:                  5      (       a  U$ U R                  R=                  S5      nUR0                  R3                  U5      (       a  UR                   R5                  5       $ UR                  U5      R                   U   $ [7        U5      (       ap  U R                  R=                  S5      nUR0                  R3                  U5      (       a  UR                   R5                  5       $ UR                  U5      R                   $ [?        S	5      es  snf )
a  
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                d    [        U [        R                  5      (       a  U R                  5       $ U $ rD   )r{   r   r   ravel)r   s    rH   r5  )_iLocIndexer._align_series.<locals>.ravelH	  s#    $.q"**$=$=qwwyD1DrK   r   r   r   c              3  8   #    U  H  n[        U5      v   M     g 7frD   )r$   )r   r  s     rH   r   -_iLocIndexer._align_series.<locals>.<genexpr>^	  s     0QAQr   Tr   r   z Incompatible indexer with Series) r{   r   r   r   r   r5   r|   mapr   r
  sumr   rr   r   r#  r   r  r   tilereshaper?   r   r$   r2   r   r   r  r   r"   r   r   r   )rF   r   serr  r  r5  r  alignerssum_alignerssingle_aligneris_framerr   
ser_valueslen_indexerr   r   new_ixs                    rH   r   _iLocIndexer._align_series,	  s=   . grzz4?@@jGgu%%E C/0G>EFgsC--c22gHFx=L)Q.NyyA~H((C !/!?HQK yy(S0Q0Q-Q-Q [[!WQZ)@t[LTT
 w<!#,>"%gaj/K
8@@bQSS  "!#G,XXa[ s##z#u'='=%#*;*;C*@*@ WF/77!&x!&vyy''//$#&J"{{//11;;v.666 $^q)Byy''++3r77"{{//11;;r?2223 -6   TYY!^txx~~..
##A&Byy##{{''));;r?**733  ##A&Byy##{{''));;r?***;<<U Gs   $%Q c                d   U R                   S:H  n[        U[        5      (       Ga  Su  pE/ n[        U5       H  u  pxU R                  R
                  U   n	[        U5      (       d  [        U[        5      (       aC  [        U[        R                  5      (       a  UR                  5       nUc  X   nM{  Uc  X   nM    OUR                  U5        M     Ubf  Ubc  UR                  R                  U5      (       a2  UR                  R                  U5      (       a  UR                  5       n
U
$ UR!                  XES9n
U
$ O[        U[        5      (       d  [#        U5      (       a  U(       a  U R                  R                  U   n	UR                  R                  U	5      (       a  UR                  5       n
U
$ [        U	[$        5      (       aN  [        UR                  [$        5      (       a/  U	R&                  UR                  R&                  :w  a  [)        S5      eUR!                  U	S9n
U
$ [+        S5      e)Nr   rN  )r   zAcannot align on a multi-index with out specifying the join levels)r   z#Incompatible indexer with DataFrame)r   r{   r|   r   rr   r   r$   r   r   r   r5  r  r   r   r   r  r#  r2   r6   r  r\  r   )rF   r   r-  rA  r  cols	sindexersr   ixr   r  s              rH   r   _iLocIndexer._align_frame	  s   99>gu%%"ICI"7+XX]]1%r??jU&;&;!"bjj11XXZ{ f!v$$Q' , 4#388??3''BJJ,=,=d,C,C'')C 
 **S*7C
%((,@,I,Ix(Bxxr""ggi J r:.."288Z88

bhh&6&66#5 
 jjrj*J>??rK   rE   NrQ  rT  r  )r   zint | np.integerrl   r:   rf   rP  rS  r  )rV   )rq   rj   )r   r=   rq   rj   )r[   intrf   rP  )rq   rj   rf   rP  )FF)r=  r>   r  rm   r  rm   )r-  r=   rf   r=   )rL   rM   rN   rO   rk   rn   r   r   r7  r  r9  r  r  r  r   r   r   r  r  r  r  r  r  r  r   r   rQ   rE   rK   rH   rW   rW     s    	B  I
(YT"H/K,1O.#1J	5_=BY<v<,2:hB%H(@Tl6\* $)k= k= !	k=
 k=Z/@rK   rW   c                  :    \ rS rSr% SrS\S'   S rS rS
S jrSr	g	)_ScalarAccessIndexeri	  z
Access scalars quickly.
rm   rn   c                    [        U 5      erD   r   r  s     rH   _convert_key!_ScalarAccessIndexer._convert_key	  r.  rK   c                    [        U[        5      (       d  [        U5      (       d  U4nO[        S5      eU R	                  U5      nU R
                  R                  " USU R                  06$ )N)Invalid call for scalar access (getting)!r6  )r{   r|   r2   r   rO  rr   r8  rn   r  s     rH   rI    _ScalarAccessIndexer.__getitem__	  s[    #u%%',,f !LMM$xx""CA$..AArK   c                  ^  [        U[        5      (       a  [        U 4S jU 5       5      nO![        R                  " UT R                  5      n[        U[        5      (       d  [        T R                  U5      n[        T R                  U5      5      n[        U5      T R                  :w  a  [        S5      eT R                  R                  " XT R                  S.6  g )Nc              3  f   >#    U  H&  n[         R                  " UTR                  5      v   M(     g 7frD   r   r   s     rH   r   3_ScalarAccessIndexer.__setitem__.<locals>.<genexpr>	  r   r   z0Not enough indexers for scalar access (setting)!)r   r6  )r{   r|   r   r   rr   r  r   r   rO  r   r   
_set_valuern   )rF   r   r   s   `  rH   r    _ScalarAccessIndexer.__setitem__	  s    c5!!HCHHC ''TXX6C#u%%499c*C4$$S)*s8tyy OPPSGrK   rE   NrO  )
rL   rM   rN   rO   rP   rU  rO  rI   r   rQ   rE   rK   rH   rM  rM  	  s    
 O(	BHrK   rM  c                  V   ^  \ rS rSrSrS r\SS j5       rU 4S jrS	U 4S jjr	Sr
U =r$ )
r`   i	  Fc                J    U R                   S:X  a  [        U5      S:  a  U4nU$ )zL
Require they keys to be the same type as the index. (so we don't
fallback)
r   )r   r   r  s     rH   rO  _AtIndexer._convert_key	  s%     99>c#hl&C
rK   c                    U R                   S:X  d   eU R                  R                  R                  =(       a     U R                  R                  R                  $ )Nr   )r   rr   r   r  r   rX   s    rH   _axes_are_unique_AtIndexer._axes_are_unique
  s=     yyA~~xx~~''FDHH,<,<,F,FFrK   c                  > U R                   S:X  aa  U R                  (       dP  [        U[        5      (       a  [	        S U 5       5      (       d  [        S5      eU R                  R                  U   $ [        TU ]%  U5      $ )Nr   c              3  8   #    U  H  n[        U5      v   M     g 7frD   r#   r   s     rH   r   )_AtIndexer.__getitem__.<locals>.<genexpr>
       4O3aYq\\3r   rR  )
r   r]  r{   r|   r   r   rr   r[   superrI   )rF   r   	__class__s     rH   rI   _AtIndexer.__getitem__
  sb    99>$"7"7c5))4O34O1O1O !LMM88<<$$w"3''rK   c                  > U R                   S:X  aa  U R                  (       dP  [        U[        5      (       a  [	        S U 5       5      (       d  [        S5      eX R                  R                  U'   g [        TU ]%  X5      $ )Nr   c              3  8   #    U  H  n[        U5      v   M     g 7frD   ra  r   s     rH   r   )_AtIndexer.__setitem__.<locals>.<genexpr>
  rc  r   z)Invalid call for scalar access (setting)!)
r   r]  r{   r|   r   r   rr   r[   rd  r   )rF   r   r   re  s      rH   r   _AtIndexer.__setitem__
  sb    99>$"7"7c5))4O34O1O1O !LMM %HHLLw"3..rK   rE   rT  rO  )rL   rM   rN   rO   rn   rO  rg   r]  rI   r   rQ   __classcell__)re  s   @rH   r`   r`   	  s2    I G G
(	/ 	/rK   r`   c                      \ rS rSrSrS rSrg)rd   i
  Tc                N    U H  n[        U5      (       a  M  [        S5      e   U$ )z8
Require integer args. (and convert to label arguments)
z1iAt based indexing can only have integer indexers)r   r   )rF   r   r   s      rH   rO  _iAtIndexer._convert_key!
  s*     Aa== !TUU  
rK   rE   N)rL   rM   rN   rO   rn   rO  rQ   rE   rK   rH   rd   rd   
  s    IrK   rd   c                t    [        U 5       Vs/ s H  n[        SS5      PM     nnXS'   [        U5      $ s  snf )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   r   r|   )r   r[   r  _tups       rH   r  r  +
  s9     (-T{3{!E${D3G; 4s   5c                >    [        S5      /U -  nX#U'   [        U5      $ )zA
If we have an axis, adapt the given key to be axis-independent.
N)r   r|   )r   rl   r   r   s       rH   r~   r~   ?
  s%     T{md"GDM>rK   c                   Un[        U[        5      (       a  UR                  R                  U 5      (       d{  UR                  R	                  U 5      nSU;   a  [        S5      eUR                  U5      n[        UR                  [        5      (       d  UR                  [        5      R                  $ [        U5      (       a  [        R                  " U[        S9nO[        U5      (       d  [!        U[        S9n[#        X5      $ )a  
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   )r{   r(   r   r   r  r   r  r   r&   astyperm   r  r"   r   r  r   pd_arrayr1   )r   r   resultr   s       rH   rH  rH  H
  s    4 F#y!!#))*:*:5*A*A,,..u5=4  W% &,,77==&...sF$/6"" &-u--rK   c                    [        U [        5      (       a)  U S   n [        U [        5      (       a  [        S5      eU S4$ U S4$ )zw
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)r{   r  rm   r   )r   s    rH   r  r  |
  sG    
 '4  %.gt$$KLL}E>rK   c                N   ^^ U4S jm[        U4S j[        U 5       5       5      $ )zC
Create a filtered indexer that doesn't have any missing indexers.
c                `   > [        U[        5      (       a  TU    R                  US   5      $ U$ )Nr   )r{   r  r   )_i_idxr   s     rH   r!  7convert_from_missing_indexer_tuple.<locals>.get_indexer
  s-    0:40F0FtBxU,PDPrK   c              3  8   >#    U  H  u  pT" X5      v   M     g 7frD   rE   )r   ry  rz  r!  s      rH   r   5convert_from_missing_indexer_tuple.<locals>.<genexpr>
  s     J7I82R&&7Is   )r|   r   )r   r   r!  s    `@rH   r  r  
  s!    
Q Jy7IJJJrK   c                     U  H6  n[        U[        R                  [        [        [
        45      (       a  M4  U s  $    [        R                  " U 6 $ )z+
We likely want to take the cross-product.
)r{   r   r   r   r(   r5   ix_)argsrG   s     rH   r  r  
  s=     #

D)UCDDK  664=rK   c                    [        U [        5      (       d  gU  H:  n[        U5      (       d  [        U[        5      (       d  M*  [        U[        5      s  $    g)r   F)r{   r|   r    r   r6   )r   rJ  r   s      rH   r   r   
  sE     c5!!??jE22fj11  rK   c                x    [        U [        5      (       + =(       a    [        U 5      (       + =(       a    U [        L$ )r   )r{   r   r2   r   r   s    rH   r  r  
  s3     sE"" 	 $S))	 xrK   c                    U R                   SL=(       d9    U R                  SL=(       d$    U R                  SL=(       a    U R                  S:g  $ )r   Nr   )rZ  r[  r  )rr   s    rH   r  r  
  sD     			 	4884	4HHD 2SXX]rK   c                6   [        U [        5      (       d,  [        U [        5      (       a"  [        S U  5       5      (       a  [	        S5      e[        U [
        5      (       d,  [        U [        5      (       a#  [        S U  5       5      (       a  [	        S5      egg)zP
Check if the indexer is or contains a dict or set, which is no longer allowed.
c              3  B   #    U  H  n[        U[        5      v   M     g 7frD   )r{   setr   s     rH   r   -check_dict_or_set_indexers.<locals>.<genexpr>
  s     0Cq
1c""Cr   zAPassing a set as an indexer is not supported. Use a list instead.c              3  B   #    U  H  n[        U[        5      v   M     g 7frD   )r{   r  r   s     rH   r   r  
  s     1S
1d##Sr   zBPassing a dict as an indexer is not supported. Use a list instead.N)r{   r  r|   r   r\  r  r  s    rH   r}   r}   
  s    
 	3c5!!0C000O
 	

 	3c5!!1S111P
 	
 2 "rK   )r   rK  r[   r7   rf   ztuple[Hashable | slice, ...])r   rK  rl   r:   rf   r|   )r   r5   rf   z
np.ndarrayrT  )rr   r   rf   rm   rO  )x
__future__r   
contextlibr   r   typingr   r   r   r   r	   r   numpyr   pandas._configr
   r   pandas._libs.indexingr   pandas._libs.libr   pandas.compatr   pandas.errorsr   r   r   r   r   r   r   r   pandas.util._decoratorsr   pandas.util._exceptionsr   pandas.core.dtypes.castr   r   pandas.core.dtypes.commonr   r   r   r   r   r    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/   rt  r0   pandas.core.indexersr1   r2   r3   r4   pandas.core.indexes.apir5   r6   collections.abcr7   r8   pandas._typingr9   r:   r;   r<   r  r=   r>   r?   r   r   r   rA   
IndexSlicerS   ri   r[   r\   rV   rW   rM  r_   r`   rc   rd   r  r~   rH  r  r  r  r   r  r  r}   rE   rK   rH   <module>r     s   "  
   
 5 . 	 	 	 ( 4   4 4  ,     
 
 
 CLD$B ) )X ]
v( v(rf<) f<R ]Y" Y Yx
 ]l@# l@ l@^#H- #HL ](/% (/ (/V ]
& 
 
(1.h K"

rK   