
    Mh7L                   >   % S r SSKJr  SSKrSSKJrJr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  SS
KJr  SSK J!r!J"r"J#r#  SSK$J%r%  SSK&J'r'J(r(J)r)  SSK*J+r+  SSK,J-r-J.r.J/r/  SSK0J1r1  SSK2J3r3J4r4J5r5  SSK6J7r7J8r8J9r9J:r:J;r;J<r<J=r=  SSK>J?r?  SSK@JArA  SSKBJCrCJDrD  \(       a4  SSKEJFrFJGrG  SSKHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrY  SSKZJ[r[  0 r\S\]S'    " S S5      r^ " S S\^5      r_ " S S 5      r` " S! S"\`5      rag)#z
An interface for extending pandas with custom arrays.

.. warning::

   This is an experimental API and subject to breaking changes
   without warning.
    )annotationsN)TYPE_CHECKINGAnyCallableClassVarLiteralcastoverload)algoslib)set_function_name)functionAbstractMethodError)AppenderSubstitutioncache_readonly)find_stack_level)validate_bool_kwargvalidate_fillna_kwargsvalidate_insert_loc)maybe_cast_pointwise_result)is_list_like	is_scalarpandas_dtype)ExtensionDtype)ABCDataFrameABCIndex	ABCSeriesisna)	arraylikemissing	roperator)
duplicatedfactorize_arrayisin	map_arraymoderankunique)quantile_with_mask)_fill_limit_area_1d)
nargminmaxnargsort)IteratorSequence)	ArrayLike	AstypeArgAxisIntDtypeDtypeObjFillnaOptionsInterpolateOptionsNumpySorterNumpyValueArrayLikePositionalIndexerScalarIndexerSelfSequenceIndexerShapeSortKindTakeIndexernpt)Indexzdict[str, str]_extension_array_shared_docsc                     \ rS rSr% SrSrSr\SSS.SbS jj5       r\ScS	 j5       r	\SSS.   SbS
 jj5       r
\S 5       r\SdS j5       r\SeS j5       rSfS jrSgS jrShS jrSiS jrSjS jrSkS jrSkS jrSS\R*                  4       SlS jjr\SmS j5       r\SnS j5       r\ShS j5       r\ShS j5       r\ShS j5       r\SoSpS jj5       r\SoSqS jj5       r\SoSrS jj5       rSsSrS jjrStS  jr\SuS! j5       rSvS" jr SS#S$S%.       SwS& jjr!SsSxS' jjr"SsSxS( jjr#          SyS) jr$SSSS*.         SzS+ jjr%    S{         S|S, jjr&S}S- jr' S~   SS/ jjr(SSS0 jjr)S}S1 jr*  S       SS2 jjr+SS3 jr,SS4 jr-SS5 jr. Ss   SS6 jjr/S7\0S8'   \1" S S99\2" \0S8   5      SSS: jj5       5       r3SSS;.       SS< jjr4S}S= jr5SSS> jjr6SS? jr7SS@ jr8SSA jr9SSSB jjr:SSC jr;\SSD j5       r<SSSE jjr=\SSF j5       r>\?SuSG j5       r@SSH.     SSI jjrASSSJ.     SSK jjrBSL\CSM'   SvSN jrD        SSO jrESSP jrFSSQ jrGSSR jrHSSS jrISST jrJSSU jrK        SSV jrLSWSXS.SSSY.         SSZ jjrM\SS[ j5       rNSS\ jrOSsSS] jjrPSS^ jrQSS_ jrR            SS` jrSSarTg)ExtensionArrayn   a  
Abstract base class for custom 1-D array types.

pandas will recognize instances of this class as proper arrays
with a custom type and will not attempt to coerce them to objects. They
may be stored directly inside a :class:`DataFrame` or :class:`Series`.

Attributes
----------
dtype
nbytes
ndim
shape

Methods
-------
argsort
astype
copy
dropna
duplicated
factorize
fillna
equals
insert
interpolate
isin
isna
ravel
repeat
searchsorted
shift
take
tolist
unique
view
_accumulate
_concat_same_type
_explode
_formatter
_from_factorized
_from_sequence
_from_sequence_of_strings
_hash_pandas_object
_pad_or_backfill
_reduce
_values_for_argsort
_values_for_factorize

Notes
-----
The interface includes the following abstract methods that must be
implemented by subclasses:

* _from_sequence
* _from_factorized
* __getitem__
* __len__
* __eq__
* dtype
* nbytes
* isna
* take
* copy
* _concat_same_type
* interpolate

A default repr displaying the type, (truncated) data, length,
and dtype is provided. It can be customized or replaced by
by overriding:

* __repr__ : A default repr for the ExtensionArray.
* _formatter : Print scalars inside a Series or DataFrame.

Some methods require casting the ExtensionArray to an ndarray of Python
objects with ``self.astype(object)``, which may be expensive. When
performance is a concern, we highly recommend overriding the following
methods:

* fillna
* _pad_or_backfill
* dropna
* unique
* factorize / _values_for_factorize
* argsort, argmax, argmin / _values_for_argsort
* searchsorted
* map

The remaining methods implemented on this class should be performant,
as they only compose abstract methods. Still, a more efficient
implementation may be available, and these methods can be overridden.

One can implement methods to handle array accumulations or reductions.

* _accumulate
* _reduce

One can implement methods to handle parsing from strings that will be used
in methods such as ``pandas.io.parsers.read_csv``.

* _from_sequence_of_strings

This class does not inherit from 'abc.ABCMeta' for performance reasons.
Methods and properties required by the interface raise
``pandas.errors.AbstractMethodError`` and no ``register`` method is
provided for registering virtual subclasses.

ExtensionArrays are limited to 1 dimension.

They may be backed by none, one, or many NumPy arrays. For example,
``pandas.Categorical`` is an extension array backed by two arrays,
one for codes and one for categories. An array of IPv6 address may
be backed by a NumPy structured array with two fields, one for the
lower 64 bits and one for the upper 64 bits. Or they may be backed
by some other storage type, like Python lists. Pandas makes no
assumptions on how the data are stored, just that it can be converted
to a NumPy array.
The ExtensionArray interface does not impose any rules on how this data
is stored. However, currently, the backing data cannot be stored in
attributes called ``.values`` or ``._values`` to ensure full compatibility
with pandas internals. But other names as ``.data``, ``._data``,
``._items``, ... can be freely used.

If implementing NumPy's ``__array_ufunc__`` interface, pandas expects
that

1. You defer by returning ``NotImplemented`` when any Series are present
   in `inputs`. Pandas will extract the arrays and call the ufunc again.
2. You define a ``_HANDLED_TYPES`` tuple as an attribute on the class.
   Pandas inspect this to determine whether the ufunc is valid for the
   types present.

See :ref:`extending.extension.ufunc` for more.

By default, ExtensionArrays are not hashable.  Immutable subclasses may
override this behavior.

Examples
--------
Please see the following:

https://github.com/pandas-dev/pandas/blob/main/pandas/tests/extension/list/array.py
	extensioni  NFdtypecopyc                   [        U 5      e)aI  
Construct a new ExtensionArray from a sequence of scalars.

Parameters
----------
scalars : Sequence
    Each element will be an instance of the scalar type for this
    array, ``cls.dtype.type`` or be converted into this type in this method.
dtype : dtype, optional
    Construct for this particular dtype. This should be a Dtype
    compatible with the ExtensionArray.
copy : bool, default False
    If True, copy the underlying data.

Returns
-------
ExtensionArray

Examples
--------
>>> pd.arrays.IntegerArray._from_sequence([4, 5])
<IntegerArray>
[4, 5]
Length: 2, dtype: Int64
r   )clsscalarsrJ   rK   s       I/var/www/html/env/lib/python3.13/site-packages/pandas/core/arrays/base.py_from_sequenceExtensionArray._from_sequence      6 "#&&    c                    U R                  XSS9$ ! [        [        4 a    e [         a    [        R
                  " S[        5       S9  e f = f)aL  
Strict analogue to _from_sequence, allowing only sequences of scalars
that should be specifically inferred to the given dtype.

Parameters
----------
scalars : sequence
dtype : ExtensionDtype

Raises
------
TypeError or ValueError

Notes
-----
This is called in a try/except block when casting the result of a
pointwise operation.
FrI   zm_from_scalars should only raise ValueError or TypeError. Consider overriding _from_scalars where appropriate.
stacklevel)rP   
ValueError	TypeError	Exceptionwarningswarnr   )rM   rN   rJ   s      rO   _from_scalarsExtensionArray._from_scalars*  sY    (
	%%g%GGI& 	 	MMG+-
 	s	    9Ac                   [        U 5      e)a2  
Construct a new ExtensionArray from a sequence of strings.

Parameters
----------
strings : Sequence
    Each element will be an instance of the scalar type for this
    array, ``cls.dtype.type``.
dtype : dtype, optional
    Construct for this particular dtype. This should be a Dtype
    compatible with the ExtensionArray.
copy : bool, default False
    If True, copy the underlying data.

Returns
-------
ExtensionArray

Examples
--------
>>> pd.arrays.IntegerArray._from_sequence_of_strings(["1", "2", "3"])
<IntegerArray>
[1, 2, 3]
Length: 3, dtype: Int64
r   )rM   stringsrJ   rK   s       rO   _from_sequence_of_strings(ExtensionArray._from_sequence_of_stringsJ  s    : "#&&rS   c                    [        U 5      e)a  
Reconstruct an ExtensionArray after factorization.

Parameters
----------
values : ndarray
    An integer ndarray with the factorized values.
original : ExtensionArray
    The original ExtensionArray that factorize was called on.

See Also
--------
factorize : Top-level factorize method that dispatches here.
ExtensionArray.factorize : Encode the extension array as an enumerated type.

Examples
--------
>>> interv_arr = pd.arrays.IntervalArray([pd.Interval(0, 1),
...                                      pd.Interval(1, 5), pd.Interval(1, 5)])
>>> codes, uniques = pd.factorize(interv_arr)
>>> pd.arrays.IntervalArray._from_factorized(uniques, interv_arr)
<IntervalArray>
[(0, 1], (1, 5]]
Length: 2, dtype: interval[int64, right]
r   )rM   valuesoriginals      rO   _from_factorizedExtensionArray._from_factorizedi  rR   rS   c                    g N selfitems     rO   __getitem__ExtensionArray.__getitem__      rS   c                    g rh   ri   rj   s     rO   rm   rn     ro   rS   c                    [        U 5      e)a  
Select a subset of self.

Parameters
----------
item : int, slice, or ndarray
    * int: The position in 'self' to get.

    * slice: A slice object, where 'start', 'stop', and 'step' are
      integers or None

    * ndarray: A 1-d boolean NumPy ndarray the same length as 'self'

    * list[int]:  A list of int

Returns
-------
item : scalar or ExtensionArray

Notes
-----
For scalar ``item``, return a scalar value suitable for the array's
type. This should be an instance of ``self.dtype.type``.

For slice ``key``, return an instance of ``ExtensionArray``, even
if the slice is length 0 or 1.

For a boolean mask, return an instance of ``ExtensionArray``, filtered
to the values where ``item`` is True.
r   rj   s     rO   rm   rn     s    > "$''rS   c                0    [        [        U 5       S35      e)a  
Set one or more values inplace.

This method is not required to satisfy the pandas extension array
interface.

Parameters
----------
key : int, ndarray, or slice
    When called from, e.g. ``Series.__setitem__``, ``key`` will be
    one of

    * scalar int
    * ndarray of integers.
    * boolean ndarray
    * slice object

value : ExtensionDtype.type, Sequence[ExtensionDtype.type], or object
    value or values to be set of ``key``.

Returns
-------
None
z  does not implement __setitem__.)NotImplementedErrortype)rk   keyvalues      rO   __setitem__ExtensionArray.__setitem__  s    V "T$ZL0P"QRRrS   c                    [        U 5      e)z4
Length of this array

Returns
-------
length : int
r   rk   s    rO   __len__ExtensionArray.__len__  s     "$''rS   c              #  N   #    [        [        U 5      5       H	  nX   v   M     g7f)z%
Iterate over elements of the array.
N)rangelen)rk   is     rO   __iter__ExtensionArray.__iter__  s!      s4y!A'M "s   #%c                   [        U5      (       ak  [        U5      (       a[  U R                  (       d  gXR                  R                  L d$  [        XR                  R                  5      (       a  U R                  $ gX:H  R                  5       $ )z
Return for `item in self`.
F)	r   r!   _can_hold_narJ   na_value
isinstancert   _hasnaanyrj   s     rO   __contains__ExtensionArray.__contains__  sc     T??tDzz$$,,,
40Q0Q{{" L%%''rS   c                    [        U 5      e)z5
Return for `self == other` (element-wise equality).
r   rk   others     rO   __eq__ExtensionArray.__eq__       "$''rS   c                    X:H  ) $ )z8
Return for `self != other` (element-wise in-equality).
ri   r   s     rO   __ne__ExtensionArray.__ne__  s    
 rS   c                    [         R                  " XS9nU(       d  U[        R                  La  UR	                  5       nU[        R                  La  X4U R                  5       '   U$ )a  
Convert to a NumPy ndarray.

This is similar to :meth:`numpy.asarray`, but may provide additional control
over how the conversion is done.

Parameters
----------
dtype : str or numpy.dtype, optional
    The dtype to pass to :meth:`numpy.asarray`.
copy : bool, default False
    Whether to ensure that the returned value is a not a view on
    another array. Note that ``copy=False`` does not *ensure* that
    ``to_numpy()`` is no-copy. Rather, ``copy=True`` ensure that
    a copy is made, even if not strictly necessary.
na_value : Any, optional
    The value to use for missing values. The default value depends
    on `dtype` and the type of the array.

Returns
-------
numpy.ndarray
rJ   )npasarrayr   
no_defaultrK   r!   )rk   rJ   rK   r   results        rO   to_numpyExtensionArray.to_numpy  sJ    : D.83>>1[[]F3>>)"*499;rS   c                    [        U 5      e)z^
An instance of ExtensionDtype.

Examples
--------
>>> pd.array([1, 2, 3]).dtype
Int64Dtype()
r   rz   s    rO   rJ   ExtensionArray.dtypeC  r   rS   c                    [        U 5      4$ )zm
Return a tuple of the array dimensions.

Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr.shape
(3,)
)r   rz   s    rO   shapeExtensionArray.shapeO  s     D	|rS   c                B    [         R                  " U R                  5      $ )z&
The number of elements in the array.
)r   prodr   rz   s    rO   sizeExtensionArray.size\  s     wwtzz""rS   c                    g)zx
Extension Arrays are only allowed to be 1-dimensional.

Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr.ndim
1
   ri   rz   s    rO   ndimExtensionArray.ndime  s     rS   c                    [        U 5      e)zq
The number of bytes needed to store this object in memory.

Examples
--------
>>> pd.array([1, 2, 3]).nbytes
27
r   rz   s    rO   nbytesExtensionArray.nbytesr  s     "$''rS   c                    g rh   ri   rk   rJ   rK   s      rO   astypeExtensionArray.astype  ro   rS   c                    g rh   ri   r   s      rO   r   r     ro   rS   c                    g rh   ri   r   s      rO   r   r     ro   rS   Tc                   [        U5      nXR                  :X  a  U(       d  U $ U R                  5       $ [        U[        5      (       a   UR                  5       nUR                  XUS9$ [        R                  " US5      (       a  SSK	J
n  UR                  XUS9$ [        R                  " US5      (       a  SSK	Jn  UR                  XUS9$ U(       d  [        R                  " XS9$ [        R                  " XUS9$ )a  
Cast to a NumPy array or ExtensionArray with 'dtype'.

Parameters
----------
dtype : str or dtype
    Typecode or data-type to which the array is cast.
copy : bool, default True
    Whether to copy the data, even if not necessary. If False,
    a copy is made only if the old dtype does not match the
    new dtype.

Returns
-------
np.ndarray or pandas.api.extensions.ExtensionArray
    An ``ExtensionArray`` if ``dtype`` is ``ExtensionDtype``,
    otherwise a Numpy ndarray with ``dtype`` for its dtype.

Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr
<IntegerArray>
[1, 2, 3]
Length: 3, dtype: Int64

Casting to another ``ExtensionDtype`` returns an ``ExtensionArray``:

>>> arr1 = arr.astype('Float64')
>>> arr1
<FloatingArray>
[1.0, 2.0, 3.0]
Length: 3, dtype: Float64
>>> arr1.dtype
Float64Dtype()

Otherwise, we will get a Numpy ndarray:

>>> arr2 = arr.astype('float64')
>>> arr2
array([1., 2., 3.])
>>> arr2.dtype
dtype('float64')
rI   Mr   )DatetimeArraym)TimedeltaArrayr   )r   rJ   rK   r   r   construct_array_typerP   r   is_np_dtypepandas.core.arraysr   r   r   r   array)rk   rJ   rK   rM   r   r   s         rO   r   r     s    Z U#JJyy{"e^,,,,.C%%dd%CC__UC((8 ///MM__UC((9!000NN::d0088DD99rS   c                    [        U 5      e)a  
A 1-D array indicating if each value is missing.

Returns
-------
numpy.ndarray or pandas.api.extensions.ExtensionArray
    In most cases, this should return a NumPy ndarray. For
    exceptional cases like ``SparseArray``, where returning
    an ndarray would be expensive, an ExtensionArray may be
    returned.

Notes
-----
If returning an ExtensionArray, then

* ``na_values._is_boolean`` should be True
* `na_values` should implement :func:`ExtensionArray._reduce`
* ``na_values.any`` and ``na_values.all`` should be implemented

Examples
--------
>>> arr = pd.array([1, 2, np.nan, np.nan])
>>> arr.isna()
array([False, False,  True,  True])
r   rz   s    rO   r!   ExtensionArray.isna  s    4 "$''rS   c                P    [        U R                  5       R                  5       5      $ )zh
Equivalent to `self.isna().any()`.

Some ExtensionArray subclasses may be able to optimize this check.
)boolr!   r   rz   s    rO   r   ExtensionArray._hasna  s     DIIKOO%&&rS   c                .    [         R                  " U 5      $ )a/  
Return values for sorting.

Returns
-------
ndarray
    The transformed values should maintain the ordering between values
    within the array.

See Also
--------
ExtensionArray.argsort : Return the indices that would sort this array.

Notes
-----
The caller is responsible for *not* modifying these values in-place, so
it is safe for implementers to give views on ``self``.

Functions that use this (e.g. ``ExtensionArray.argsort``) should ignore
entries with missing values in the original array (according to
``self.isna()``). This means that the corresponding entries in the returned
array don't need to be modified to sort correctly.

Examples
--------
In most cases, this is the underlying Numpy array of the ``ExtensionArray``:

>>> arr = pd.array([1, 2, 3])
>>> arr._values_for_argsort()
array([1, 2, 3])
)r   r   rz   s    rO   _values_for_argsort"ExtensionArray._values_for_argsort  s    B xx~rS   	quicksortlast)	ascendingkindna_positionc          
         [         R                  " USU5      nU R                  5       n[        UUUU[        R
                  " U R                  5       5      S9$ )a"  
Return the indices that would sort this array.

Parameters
----------
ascending : bool, default True
    Whether the indices should result in an ascending
    or descending sort.
kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional
    Sorting algorithm.
na_position : {'first', 'last'}, default 'last'
    If ``'first'``, put ``NaN`` values at the beginning.
    If ``'last'``, put ``NaN`` values at the end.
*args, **kwargs:
    Passed through to :func:`numpy.argsort`.

Returns
-------
np.ndarray[np.intp]
    Array of indices that sort ``self``. If NaN values are contained,
    NaN values are placed at the end.

See Also
--------
numpy.argsort : Sorting implementation used internally.

Examples
--------
>>> arr = pd.array([3, 1, 2, 5, 4])
>>> arr.argsort()
array([1, 2, 0, 4, 3])
ri   )r   r   r   mask)nvvalidate_argsort_with_ascendingr   r/   r   r   r!   )rk   r   r   r   kwargsrc   s         rO   argsortExtensionArray.argsort   sR    Z 66y"fM	))+#DIIK(
 	
rS   c                n    [        US5        U(       d  U R                  (       a  [        e[        U S5      $ )a|  
Return the index of minimum value.

In case of multiple occurrences of the minimum value, the index
corresponding to the first occurrence is returned.

Parameters
----------
skipna : bool, default True

Returns
-------
int

See Also
--------
ExtensionArray.argmax : Return the index of the maximum value.

Examples
--------
>>> arr = pd.array([3, 1, 2, 5, 4])
>>> arr.argmin()
1
skipnaargminr   r   rs   r.   rk   r   s     rO   r   ExtensionArray.argminX  *    : 	FH-$++%%$))rS   c                n    [        US5        U(       d  U R                  (       a  [        e[        U S5      $ )a|  
Return the index of maximum value.

In case of multiple occurrences of the maximum value, the index
corresponding to the first occurrence is returned.

Parameters
----------
skipna : bool, default True

Returns
-------
int

See Also
--------
ExtensionArray.argmin : Return the index of the minimum value.

Examples
--------
>>> arr = pd.array([3, 1, 2, 5, 4])
>>> arr.argmax()
3
r   argmaxr   r   s     rO   r   ExtensionArray.argmaxz  r   rS   c               D    [        [        U 5      R                   S35      e)a   
See DataFrame.interpolate.__doc__.

Examples
--------
>>> arr = pd.arrays.NumpyExtensionArray(np.array([0, 1, np.nan, 3]))
>>> arr.interpolate(method="linear",
...                 limit=3,
...                 limit_direction="forward",
...                 index=pd.Index([1, 2, 3, 4]),
...                 fill_value=1,
...                 copy=False,
...                 axis=0,
...                 limit_area="inside"
...                 )
<NumpyExtensionArray>
[0.0, 1.0, 2.0, 3.0]
Length: 4, dtype: float64
z does not implement interpolate)rs   rt   __name__)	rk   methodaxisindexlimitlimit_direction
limit_arearK   r   s	            rO   interpolateExtensionArray.interpolate  s(    @ "Dz""##BC
 	
rS   )r   r   rK   c               $   [        U 5      R                  [        R                  La{  [        U 5      R                  [        R                  L aU  [        R
                  " S[        [        5       S9  Ub!  [        [        U 5      R                   S35      eU R                  XS9$ U R                  5       nUR                  5       (       a  [        R                  " U5      n[        R                  " U5      nUb   UR!                  5       (       d  [#        Xs5        US:X  a$  [$        R&                  " XrS9nU R)                  USS	9$ [$        R&                  " USSS
2   US9SSS
2   nU SSS
2   R)                  USS	9$ U(       d  U $ U R+                  5       n	U	$ )a&  
Pad or backfill values, used by Series/DataFrame ffill and bfill.

Parameters
----------
method : {'backfill', 'bfill', 'pad', 'ffill'}
    Method to use for filling holes in reindexed Series:

    * pad / ffill: propagate last valid observation forward to next valid.
    * backfill / bfill: use NEXT valid observation to fill gap.

limit : int, default None
    This is the maximum number of consecutive
    NaN values to forward/backward fill. In other words, if there is
    a gap with more than this number of consecutive NaNs, it will only
    be partially filled. If method is not specified, this is the
    maximum number of entries along the entire axis where NaNs will be
    filled.

copy : bool, default True
    Whether to make a copy of the data before filling. If False, then
    the original should be modified and no new memory should be allocated.
    For ExtensionArray subclasses that cannot do this, it is at the
    author's discretion whether to ignore "copy=False" or to raise.
    The base class implementation ignores the keyword if any NAs are
    present.

Returns
-------
Same type as self

Examples
--------
>>> arr = pd.array([np.nan, np.nan, 2, 3, np.nan, np.nan])
>>> arr._pad_or_backfill(method="backfill", limit=1)
<IntegerArray>
[<NA>, 2, 2, 3, <NA>, <NA>]
Length: 6, dtype: Int64
zExtensionArray.fillna 'method' keyword is deprecated. In a future version. arr._pad_or_backfill will be called instead. 3rd-party ExtensionArray authors need to implement _pad_or_backfill.rU   Nz does not implement limit_area (added in pandas 2.2). 3rd-party ExtnsionArray authors need to add this argument to _pad_or_backfill.)r   r   padr   T
allow_fill)rt   fillnarF   _pad_or_backfillrZ   r[   DeprecationWarningr   rs   r   r!   r   r#   clean_fill_methodr   r   allr-   libalgosget_fill_indexertakerK   )
rk   r   r   r   rK   r   methnpmaskindexer
new_valuess
             rO   r   ExtensionArray._pad_or_backfill  si   f J^%:%::T
++~/N/NN MM$ #+- %)Dz**+ ,E E 
 ;;f;::yy{88::,,V4DZZ%F%fjjll#F7u}"33FHyyTy:: #33F4R4LNtQStTDbDzw4@@ JrS   c                   Ub9  [         R                  " S[        U 5      R                   S3[        [        5       S9  [        X5      u  pU R                  5       n[        R                  " X[        U 5      5      nUR                  5       (       a  Ub  [        R                  " U5      n[        R                  " U5      nUS:X  a$  [        R                   " XsS9nU R#                  USS9$ [        R                   " USSS	2   US9SSS	2   nU SSS	2   R#                  USS9$ U(       d  U SS n	OU R%                  5       n	XU'    U	$ U(       d  U SS n	U	$ U R%                  5       n	U	$ )
a<  
Fill NA/NaN values using the specified method.

Parameters
----------
value : scalar, array-like
    If a scalar value is passed it is used to fill all missing values.
    Alternatively, an array-like "value" can be given. It's expected
    that the array-like have the same length as 'self'.
method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None
    Method to use for filling holes in reindexed Series:

    * pad / ffill: propagate last valid observation forward to next valid.
    * backfill / bfill: use NEXT valid observation to fill gap.

    .. deprecated:: 2.1.0

limit : int, default None
    If method is specified, this is the maximum number of consecutive
    NaN values to forward/backward fill. In other words, if there is
    a gap with more than this number of consecutive NaNs, it will only
    be partially filled. If method is not specified, this is the
    maximum number of entries along the entire axis where NaNs will be
    filled.

    .. deprecated:: 2.1.0

copy : bool, default True
    Whether to make a copy of the data before filling. If False, then
    the original should be modified and no new memory should be allocated.
    For ExtensionArray subclasses that cannot do this, it is at the
    author's discretion whether to ignore "copy=False" or to raise.
    The base class implementation ignores the keyword in pad/backfill
    cases.

Returns
-------
ExtensionArray
    With NA/NaN filled.

Examples
--------
>>> arr = pd.array([np.nan, np.nan, 2, 3, np.nan, np.nan])
>>> arr.fillna(0)
<IntegerArray>
[0, 0, 2, 3, 0, 0]
Length: 6, dtype: Int64
NzThe 'method' keyword in z>.fillna is deprecated and will be removed in a future version.rU   r   r   Tr   r   )rZ   r[   rt   r   FutureWarningr   r   r!   r#   check_value_sizer   r   r   r   r   r   r   r   rK   )
rk   rv   r   r   rK   r   r   r   r   r   s
             rO   r   ExtensionArray.fillna  sc   n MM*4:+>+>*? @F F+-	 /u=yy{ ((T
 88::!008D)5=&77LG99W9>> '77ttERSWUWSWXG":??7t?DD !%aJ!%J#(4  	 !!W
  "YY[
rS   c                (    X R                  5       )    $ )z
Return ExtensionArray without NA values.

Returns
-------

Examples
--------
>>> pd.array([1, 2, np.nan]).dropna()
<IntegerArray>
[1, 2]
Length: 2, dtype: Int64
r    rz   s    rO   dropnaExtensionArray.dropna  s     YY[L!!rS   keepc                n    U R                  5       R                  [        R                  SS9n[	        XUS9$ )a  
Return boolean ndarray denoting duplicate values.

Parameters
----------
keep : {'first', 'last', False}, default 'first'
    - ``first`` : Mark duplicates as ``True`` except for the first occurrence.
    - ``last`` : Mark duplicates as ``True`` except for the last occurrence.
    - False : Mark all duplicates as ``True``.

Returns
-------
ndarray[bool]

Examples
--------
>>> pd.array([1, 1, 2, 3, 3], dtype="Int64").duplicated()
array([False,  True, False, False,  True])
F)rK   )rc   r   r   )r!   r   r   bool_r%   )rk   r   r   s      rO   r%   ExtensionArray.duplicated  s0    , yy{!!"((!7t<<rS   c           	     p   [        U 5      (       a  US:X  a  U R                  5       $ [        U5      (       a  U R                  R                  nU R                  U/[        [        U5      [        U 5      5      -  U R                  S9nUS:  a	  UnU SU*  nOU [        U5      S nUnU R                  XE/5      $ )aH  
Shift values by desired number.

Newly introduced missing values are filled with
``self.dtype.na_value``.

Parameters
----------
periods : int, default 1
    The number of periods to shift. Negative values are allowed
    for shifting backwards.

fill_value : object, optional
    The scalar value to use for newly introduced missing values.
    The default is ``self.dtype.na_value``.

Returns
-------
ExtensionArray
    Shifted.

Notes
-----
If ``self`` is empty or ``periods`` is 0, a copy of ``self`` is
returned.

If ``periods > len(self)``, then an array of size
len(self) is returned, with all values filled with
``self.dtype.na_value``.

For 2-dimensional ExtensionArrays, we are always shifting along axis=0.

Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr.shift(2)
<IntegerArray>
[<NA>, <NA>, 1]
Length: 3, dtype: Int64
r   r   N)	r   rK   r!   rJ   r   rP   minabs_concat_same_type)rk   periods
fill_valueemptyabs         rO   shiftExtensionArray.shift  s    V 4yyGqL99;
,,J##L3s7|SY77tzz $ 
 Q;AYwhAS\^$AA%%qf--rS   c                p    [        U R                  [        5      5      nU R                  XR                  S9$ )z
Compute the ExtensionArray of unique values.

Returns
-------
pandas.api.extensions.ExtensionArray

Examples
--------
>>> arr = pd.array([1, 2, 3, 1, 2, 3])
>>> arr.unique()
<IntegerArray>
[1, 2, 3]
Length: 3, dtype: Int64
r   )r+   r   objectrP   rJ   )rk   uniquess     rO   r+   ExtensionArray.unique  s/      V,-""7**"==rS   c                    U R                  [        5      n[        U[        5      (       a  UR                  [        5      nUR	                  XUS9$ )a  
Find indices where elements should be inserted to maintain order.

Find the indices into a sorted array `self` (a) such that, if the
corresponding elements in `value` were inserted before the indices,
the order of `self` would be preserved.

Assuming that `self` is sorted:

======  ================================
`side`  returned index `i` satisfies
======  ================================
left    ``self[i-1] < value <= self[i]``
right   ``self[i-1] <= value < self[i]``
======  ================================

Parameters
----------
value : array-like, list or scalar
    Value(s) to insert into `self`.
side : {'left', 'right'}, optional
    If 'left', the index of the first suitable location found is given.
    If 'right', return the last such index.  If there is no suitable
    index, return either 0 or N (where N is the length of `self`).
sorter : 1-D array-like, optional
    Optional array of integer indices that sort array a into ascending
    order. They are typically the result of argsort.

Returns
-------
array of ints or int
    If value is array-like, array of insertion points.
    If value is scalar, a single integer.

See Also
--------
numpy.searchsorted : Similar method from NumPy.

Examples
--------
>>> arr = pd.array([1, 2, 3, 5])
>>> arr.searchsorted([4])
array([3])
)sidesorter)r   r  r   rF   searchsorted)rk   rv   r  r  arrs        rO   r  ExtensionArray.searchsorted  sD    n kk&!e^,,LL(E@@rS   c                   [        U 5      [        U5      :w  a  g[        [        U5      nU R                  UR                  :w  a  g[	        U 5      [	        U5      :w  a  gX:H  n[        U[        5      (       a  UR                  S5      nU R                  5       UR                  5       -  n[        X#-  R                  5       5      $ )a  
Return if another array is equivalent to this array.

Equivalent means that both arrays have the same shape and dtype, and
all values compare equal. Missing values in the same location are
considered equal (in contrast with normal equality).

Parameters
----------
other : ExtensionArray
    Array to compare to this Array.

Returns
-------
boolean
    Whether the arrays are equivalent.

Examples
--------
>>> arr1 = pd.array([1, 2, np.nan])
>>> arr2 = pd.array([1, 2, np.nan])
>>> arr1.equals(arr2)
True
F)
rt   r	   rF   rJ   r   r   r   r!   r   r   )rk   r   equal_valuesequal_nas       rO   equalsExtensionArray.equals6  s    2 :e$^U+::$Y#e*$=L,77+2259yy{UZZ\1H055788rS   c                B    [        [        R                  " U 5      U5      $ )a^  
Pointwise comparison for set containment in the given values.

Roughly equivalent to `np.array([x in values for x in self])`

Parameters
----------
values : np.ndarray or ExtensionArray

Returns
-------
np.ndarray[bool]

Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr.isin([1])
<BooleanArray>
[True, False, False]
Length: 3, dtype: boolean
)r'   r   r   )rk   rc   s     rO   r'   ExtensionArray.isin_  s    , BJJt$f--rS   c                L    U R                  [        5      [        R                  4$ )a-  
Return an array and missing value suitable for factorization.

Returns
-------
values : ndarray
    An array suitable for factorization. This should maintain order
    and be a supported dtype (Float64, Int64, UInt64, String, Object).
    By default, the extension array is cast to object dtype.
na_value : object
    The value in `values` to consider missing. This will be treated
    as NA in the factorization routines, so it will be coded as
    `-1` and not included in `uniques`. By default,
    ``np.nan`` is used.

Notes
-----
The values returned by this method are also used in
:func:`pandas.util.hash_pandas_object`. If needed, this can be
overridden in the ``self._hash_pandas_object()`` method.

Examples
--------
>>> pd.array([1, 2, 3])._values_for_factorize()
(array([1, 2, 3], dtype=object), nan)
)r   r  r   nanrz   s    rO   _values_for_factorize$ExtensionArray._values_for_factorizew  s    6 {{6"BFF**rS   c                f    U R                  5       u  p#[        X!US9u  pEU R                  XP5      nXF4$ )al  
Encode the extension array as an enumerated type.

Parameters
----------
use_na_sentinel : bool, default True
    If True, the sentinel -1 will be used for NaN values. If False,
    NaN values will be encoded as non-negative integers and will not drop the
    NaN from the uniques of the values.

    .. versionadded:: 1.5.0

Returns
-------
codes : ndarray
    An integer NumPy array that's an indexer into the original
    ExtensionArray.
uniques : ExtensionArray
    An ExtensionArray containing the unique values of `self`.

    .. note::

       uniques will *not* contain an entry for the NA value of
       the ExtensionArray if there are any missing values present
       in `self`.

See Also
--------
factorize : Top-level factorize method that dispatches here.

Notes
-----
:meth:`pandas.factorize` offers a `sort` keyword as well.

Examples
--------
>>> idx1 = pd.PeriodIndex(["2014-01", "2014-01", "2014-02", "2014-02",
...                       "2014-03", "2014-03"], freq="M")
>>> arr, idx = idx1.factorize()
>>> arr
array([0, 0, 1, 1, 2, 2])
>>> idx
PeriodIndex(['2014-01', '2014-02', '2014-03'], dtype='period[M]')
)use_na_sentinelr   )r  r&   re   )rk   r"  r  r   codesr  
uniques_eas          rO   	factorizeExtensionArray.factorize  sA    p 224(8
 **79
  rS   a;  
        Repeat elements of a %(klass)s.

        Returns a new %(klass)s where each element of the current %(klass)s
        is repeated consecutively a given number of times.

        Parameters
        ----------
        repeats : int or array of ints
            The number of repetitions for each element. This should be a
            non-negative integer. Repeating 0 times will return an empty
            %(klass)s.
        axis : None
            Must be ``None``. Has no effect but is accepted for compatibility
            with numpy.

        Returns
        -------
        %(klass)s
            Newly created %(klass)s with repeated elements.

        See Also
        --------
        Series.repeat : Equivalent function for Series.
        Index.repeat : Equivalent function for Index.
        numpy.repeat : Similar method for :class:`numpy.ndarray`.
        ExtensionArray.take : Take arbitrary positions.

        Examples
        --------
        >>> cat = pd.Categorical(['a', 'b', 'c'])
        >>> cat
        ['a', 'b', 'c']
        Categories (3, object): ['a', 'b', 'c']
        >>> cat.repeat(2)
        ['a', 'a', 'b', 'b', 'c', 'c']
        Categories (3, object): ['a', 'b', 'c']
        >>> cat.repeat([1, 2, 3])
        ['a', 'b', 'b', 'c', 'c', 'c']
        Categories (3, object): ['a', 'b', 'c']
        repeat)klassc                    [         R                  " SSU05        [        R                  " [	        U 5      5      R                  U5      nU R                  U5      $ )Nri   r   )r   validate_repeatr   aranger   r'  r   )rk   repeatsr   inds       rO   r'  ExtensionArray.repeat  sC     	2~.iiD	"))'2yy~rS   )r   r  c                   [        U 5      e)a
  
Take elements from an array.

Parameters
----------
indices : sequence of int or one-dimensional np.ndarray of int
    Indices to be taken.
allow_fill : bool, default False
    How to handle negative values in `indices`.

    * False: negative values in `indices` indicate positional indices
      from the right (the default). This is similar to
      :func:`numpy.take`.

    * True: negative values in `indices` indicate
      missing values. These values are set to `fill_value`. Any other
      other negative values raise a ``ValueError``.

fill_value : any, optional
    Fill value to use for NA-indices when `allow_fill` is True.
    This may be ``None``, in which case the default NA value for
    the type, ``self.dtype.na_value``, is used.

    For many ExtensionArrays, there will be two representations of
    `fill_value`: a user-facing "boxed" scalar, and a low-level
    physical NA value. `fill_value` should be the user-facing version,
    and the implementation should handle translating that to the
    physical version for processing the take if necessary.

Returns
-------
ExtensionArray

Raises
------
IndexError
    When the indices are out of bounds for the array.
ValueError
    When `indices` contains negative values other than ``-1``
    and `allow_fill` is True.

See Also
--------
numpy.take : Take elements from an array along an axis.
api.extensions.take : Take elements from an array.

Notes
-----
ExtensionArray.take is called by ``Series.__getitem__``, ``.loc``,
``iloc``, when `indices` is a sequence of values. Additionally,
it's called by :meth:`Series.reindex`, or any other method
that causes realignment, with a `fill_value`.

Examples
--------
Here's an example implementation, which relies on casting the
extension array to object dtype. This uses the helper method
:func:`pandas.api.extensions.take`.

.. code-block:: python

   def take(self, indices, allow_fill=False, fill_value=None):
       from pandas.core.algorithms import take

       # If the ExtensionArray is backed by an ndarray, then
       # just pass that here instead of coercing to object.
       data = self.astype(object)

       if allow_fill and fill_value is None:
           fill_value = self.dtype.na_value

       # fill value should always be translated from the scalar
       # type for the array, to the physical storage type for
       # the data, before passing to take.

       result = take(data, indices, fill_value=fill_value,
                     allow_fill=allow_fill)
       return self._from_sequence(result, dtype=self.dtype)
r   )rk   indicesr   r  s       rO   r   ExtensionArray.take  s    z "$''rS   c                    [        U 5      e)z
Return a copy of the array.

Returns
-------
ExtensionArray

Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr2 = arr.copy()
>>> arr[0] = 2
>>> arr2
<IntegerArray>
[1, 2, 3]
Length: 3, dtype: Int64
r   rz   s    rO   rK   ExtensionArray.copyk  s    $ "$''rS   c                (    Ub  [        U5      eU SS $ )a*  
Return a view on the array.

Parameters
----------
dtype : str, np.dtype, or ExtensionDtype, optional
    Default None.

Returns
-------
ExtensionArray or np.ndarray
    A view on the :class:`ExtensionArray`'s data.

Examples
--------
This gives view on the underlying data of an ``ExtensionArray`` and is not a
copy. Modifications on either the view or the original ``ExtensionArray``
will be reflectd on the underlying data:

>>> arr = pd.array([1, 2, 3])
>>> arr2 = arr.view()
>>> arr[0] = 2
>>> arr2
<IntegerArray>
[2, 2, 3]
Length: 3, dtype: Int64
N)rs   )rk   rJ   s     rO   viewExtensionArray.view  s    @ %e,,AwrS   c                    U R                   S:  a  U R                  5       $ SSKJn  U" X R	                  5       SS9R                  S5      nS[        U 5      R                   S3nU R                  5       nU U S	U 3$ )
Nr   r   format_object_summaryFindent_for_name, 
<z>

)	r   _repr_2dpandas.io.formats.printingr9  
_formatterrstriprt   r   _get_repr_footer)rk   r9  data
class_namefooters        rO   __repr__ExtensionArray.__repr__  s~    99q===?"D
 %//#U

&. 	 d,,-S1
&&(dV2fX..rS   c                    U R                   S:  a  SU R                   SU R                   3$ S[        U 5       SU R                   3$ )Nr   zShape: z	, dtype: zLength: )r   r   rJ   r   rz   s    rO   rC  ExtensionArray._get_repr_footer  sC    99q=TZZL	$**>>#d)Idjj\::rS   c           	        SSK Jn  U  Vs/ s H'  nU" X R                  5       SS9R                  S5      PM)     nnSR	                  U5      nS[        U 5      R                   S3nU R                  5       nU S	U S
U 3$ s  snf )Nr   r8  Fr:  r<  z,
r=  >z
[
z
]
)r@  r9  rA  rB  joinrt   r   rC  )rk   r9  xlinesrD  rE  rF  s          rO   r?  ExtensionArray._repr_2d  s    D 	
  "!__%6NUU 	 	 
 zz% d,,-Q/
&&(U4&fX66
s   .A?c                (    U(       a  [         $ [        $ )a  
Formatting function for scalar values.

This is used in the default '__repr__'. The returned formatting
function receives instances of your scalar type.

Parameters
----------
boxed : bool, default False
    An indicated for whether or not your array is being printed
    within a Series, DataFrame, or Index (True), or just by
    itself (False). This may be useful if you want scalar values
    to appear differently within a Series versus on its own (e.g.
    quoted or not).

Returns
-------
Callable[[Any], str]
    A callable that gets instances of the scalar type and
    returns a string. By default, :func:`repr` is used
    when ``boxed=False`` and :func:`str` is used when
    ``boxed=True``.

Examples
--------
>>> class MyExtensionArray(pd.arrays.NumpyExtensionArray):
...     def _formatter(self, boxed=False):
...         return lambda x: '*' + str(x) + '*' if boxed else repr(x) + '*'
>>> MyExtensionArray(np.array([1, 2, 3, 4]))
<MyExtensionArray>
[1*, 2*, 3*, 4*]
Length: 4, dtype: int64
)strrepr)rk   boxeds     rO   rA  ExtensionArray._formatter  s    D JrS   c                    U SS $ )a  
Return a transposed view on this array.

Because ExtensionArrays are always 1D, this is a no-op.  It is included
for compatibility with np.ndarray.

Returns
-------
ExtensionArray

Examples
--------
>>> pd.array([1, 2, 3]).transpose()
<IntegerArray>
[1, 2, 3]
Length: 3, dtype: Int64
Nri   )rk   axess     rO   	transposeExtensionArray.transpose  s    $ AwrS   c                "    U R                  5       $ rh   )rX  rz   s    rO   TExtensionArray.T  s    ~~rS   c                    U $ )a|  
Return a flattened view on this array.

Parameters
----------
order : {None, 'C', 'F', 'A', 'K'}, default 'C'

Returns
-------
ExtensionArray

Notes
-----
- Because ExtensionArrays are 1D-only, this is a no-op.
- The "order" argument is ignored, is for compatibility with NumPy.

Examples
--------
>>> pd.array([1, 2, 3]).ravel()
<IntegerArray>
[1, 2, 3]
Length: 3, dtype: Int64
ri   )rk   orders     rO   ravelExtensionArray.ravel  s	    0 rS   c                    [        U 5      e)aJ  
Concatenate multiple array of this dtype.

Parameters
----------
to_concat : sequence of this type

Returns
-------
ExtensionArray

Examples
--------
>>> arr1 = pd.array([1, 2, 3])
>>> arr2 = pd.array([4, 5, 6])
>>> pd.arrays.IntegerArray._concat_same_type([arr1, arr2])
<IntegerArray>
[1, 2, 3, 4, 5, 6]
Length: 6, dtype: Int64
r   )rM   	to_concats     rO   r   ExtensionArray._concat_same_type*  rR   rS   c                .    U R                   R                  $ rh   )rJ   r   rz   s    rO   r   ExtensionArray._can_hold_naL  s    zz&&&rS   r   c               8    [        SU SU R                   35      e)a  
Return an ExtensionArray performing an accumulation operation.

The underlying data type might change.

Parameters
----------
name : str
    Name of the function, supported values are:
    - cummin
    - cummax
    - cumsum
    - cumprod
skipna : bool, default True
    If True, skip NA values.
**kwargs
    Additional keyword arguments passed to the accumulation function.
    Currently, there is no supported kwarg.

Returns
-------
array

Raises
------
NotImplementedError : subclass does not define accumulations

Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr._accumulate(name='cumsum')
<IntegerArray>
[1, 3, 6]
Length: 3, dtype: Int64
zcannot perform z with type )rs   rJ   )rk   namer   r   s       rO   _accumulateExtensionArray._accumulateP  s!    L "OD6TZZL"QRRrS   )r   keepdimsc          	         [        XS5      nUc2  [        S[        U 5      R                   SU R                   SU S35      eU" SSU0UD6nU(       a  [
        R                  " U/5      nU$ )a  
Return a scalar result of performing the reduction operation.

Parameters
----------
name : str
    Name of the function, supported values are:
    { any, all, min, max, sum, mean, median, prod,
    std, var, sem, kurt, skew }.
skipna : bool, default True
    If True, skip NaN values.
keepdims : bool, default False
    If False, a scalar is returned.
    If True, the result has dimension with size one along the reduced axis.

    .. versionadded:: 2.1

       This parameter is not required in the _reduce signature to keep backward
       compatibility, but will become required in the future. If the parameter
       is not found in the method signature, a FutureWarning will be emitted.
**kwargs
    Additional keyword arguments passed to the reduction function.
    Currently, `ddof` is the only supported kwarg.

Returns
-------
scalar

Raises
------
TypeError : subclass does not define reductions

Examples
--------
>>> pd.array([1, 2, 3])._reduce("min")
1
N'z' with dtype z does not support reduction 'r   ri   )getattrrX   rt   r   rJ   r   r   )rk   rh  r   rk  r   r   r   s          rO   _reduceExtensionArray._reducex  s}    P t4(<DJ''(djj\ B//3fA7  .V.v.XXvh'FrS   zClassVar[None]__hash__c                .    [         R                  " U 5      $ )a  
Specify how to render our entries in to_json.

Notes
-----
The dtype on the returned ndarray is not restricted, but for non-native
types that are not specifically handled in objToJSON.c, to_json is
liable to raise. In these cases, it may be safer to return an ndarray
of strings.
)r   r   rz   s    rO   _values_for_jsonExtensionArray._values_for_json  s     zz$rS   c               @    SSK Jn  U R                  5       u  pVU" XQX#S9$ )a  
Hook for hash_pandas_object.

Default is to use the values returned by _values_for_factorize.

Parameters
----------
encoding : str
    Encoding for data & key when strings.
hash_key : str
    Hash_key for string key to encode.
categorize : bool
    Whether to first categorize object arrays before hashing. This is more
    efficient when the array contains duplicate values.

Returns
-------
np.ndarray[uint64]

Examples
--------
>>> pd.array([1, 2])._hash_pandas_object(encoding='utf-8',
...                                      hash_key="1000000000000000",
...                                      categorize=False
...                                      )
array([ 6238072747940578789, 15839785061582574730], dtype=uint64)
r   )
hash_array)encodinghash_key
categorize)pandas.core.util.hashingrv  r  )rk   rw  rx  ry  rv  rc   _s          rO   _hash_pandas_object"ExtensionArray._hash_pandas_object  s)    < 	8..0	
 	
rS   c                    U R                  5       n[        R                  " [        U 5      4[        R                  S9nX4$ )a  
Transform each element of list-like to a row.

For arrays that do not contain list-like elements the default
implementation of this method just returns a copy and an array
of ones (unchanged index).

Returns
-------
ExtensionArray
    Array with the exploded values.
np.ndarray[uint64]
    The original lengths of each list-like for determining the
    resulting index.

See Also
--------
Series.explode : The method on the ``Series`` object that this
    extension array method is meant to support.

Examples
--------
>>> import pyarrow as pa
>>> a = pd.array([[1, 2, 3], [4], [5, 6]],
...              dtype=pd.ArrowDtype(pa.list_(pa.int64())))
>>> a._explode()
(<ArrowExtensionArray>
[1, 2, 3, 4, 5, 6]
Length: 6, dtype: int64[pyarrow], array([3, 1, 2], dtype=int32))
)r   rJ   )rK   r   onesr   uint64)rk   rc   countss      rO   _explodeExtensionArray._explode  s1    > D	|299=~rS   c                    U R                   S:  a   U  Vs/ s H  oR                  5       PM     sn$ [        U 5      $ s  snf )a  
Return a list of the values.

These are each a scalar type, which is a Python scalar
(for str, int, float) or a pandas scalar
(for Timestamp/Timedelta/Interval/Period)

Returns
-------
list

Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr.tolist()
[1, 2, 3]
r   )r   tolistlist)rk   rN  s     rO   r  ExtensionArray.tolist
  s7    $ 99q=(,-1HHJ--Dz .s   <c                    [         R                  " [         R                  " [        U 5      5      U5      nU R	                  U5      $ rh   )r   deleter+  r   r   )rk   locr   s      rO   r  ExtensionArray.delete   s.    ))BIIc$i0#6yy!!rS   c                    [        U[        U 5      5      n[        U 5      R                  U/U R                  S9n[        U 5      R                  U SU X0US /5      $ )a  
Insert an item at the given position.

Parameters
----------
loc : int
item : scalar-like

Returns
-------
same type as self

Notes
-----
This method should be both type and dtype-preserving.  If the item
cannot be held in an array of this type/dtype, either ValueError or
TypeError should be raised.

The default implementation relies on _from_sequence to raise on invalid
items.

Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr.insert(2, -1)
<IntegerArray>
[1, 2, -1, 3]
Length: 4, dtype: Int64
r   N)r   r   rt   rP   rJ   r  )rk   r  rl   item_arrs       rO   insertExtensionArray.insert$  sY    < "#s4y1:,,dV4::,FDz++T$3Z:,NOOrS   c                :    [        U5      (       a  X!   nOUnX0U'   g)aq  
Analogue to np.putmask(self, mask, value)

Parameters
----------
mask : np.ndarray[bool]
value : scalar or listlike
    If listlike, must be arraylike with same length as self.

Returns
-------
None

Notes
-----
Unlike np.putmask, we do not repeat listlike values with mismatched length.
'value' should either be a scalar or an arraylike with the same length
as self.
N)r   )rk   r   rv   vals       rO   _putmaskExtensionArray._putmaskH  s"    ( +CCT
rS   c                `    U R                  5       n[        U5      (       a  X!)    nOUnXCU) '   U$ )z
Analogue to np.where(mask, self, value)

Parameters
----------
mask : np.ndarray[bool]
value : scalar or listlike

Returns
-------
same type as self
)rK   r   )rk   r   rv   r   r  s        rO   _whereExtensionArray._wherec  s6     ,CCurS   c                    [         R                  " U5      nU R                  [        5      nU" XRUR	                  5       S9  U R                  XPR                  S9nXc   X'   g)zq
Replace values in locations specified by 'mask' using pad or backfill.

See also
--------
ExtensionArray.fillna
)r   r   r   N)r#   get_fill_funcr   r  rK   rP   rJ   )rk   r   r   r   funcnpvaluesr   s          rO   _fill_mask_inplace!ExtensionArray._fill_mask_inplace{  sU     $$V,;;v& 	X5(((D
%
rS   r   averager   r   	na_optionr   pctc          	     R    US:w  a  [         e[        U R                  5       UUUUUS9$ )z
See Series.rank.__doc__.
r   r  )rs   r*   r   )rk   r   r   r  r   r  s         rO   _rankExtensionArray._rank  s9     19%%$$&
 	
rS   c                    U R                  / US9n[        R                  " [        R                  " S5      U5      nUR	                  USS9n[        XP5      (       a  X%R                  :w  a  [        SU S35      eU$ )z
Create an ExtensionArray with the given shape and dtype.

See also
--------
ExtensionDtype.empty
    ExtensionDtype.empty is the 'official' public version of this API.
r   r   Tr   z5Default 'empty' implementation is invalid for dtype='rm  )rP   r   broadcast_tointpr   r   rJ   rs   )rM   r   rJ   objtakerr   s         rO   _emptyExtensionArray._empty  sw       5 1U3%D1&&&%<<*?%GwaP  rS   c                    [         R                  " U R                  5       5      n[         R                  " U 5      n[         R                  n[	        XCXQU5      n[        U 5      R                  U5      $ )z
Compute the quantiles of self for each quantile in `qs`.

Parameters
----------
qs : np.ndarray[float64]
interpolation: str

Returns
-------
same type as self
)r   r   r!   r  r,   rt   rP   )rk   qsinterpolationr   r  r  
res_valuess          rO   	_quantileExtensionArray._quantile  sR     zz$))+&jjVV
':=Q
Dz((44rS   c                    [        XS9$ )z
Returns the mode(s) of the ExtensionArray.

Always returns `ExtensionArray` even if only one value.

Parameters
----------
dropna : bool, default True
    Don't consider counts of NA values.

Returns
-------
same type as self
    Sorted, if possible.
)r   )r)   )rk   r   s     rO   _modeExtensionArray._mode  s    $ D((rS   c                X   [        S U 5       5      (       a  [        $ [        R                  " XU/UQ70 UD6nU[        La  U$ SU;   a  [        R                  " XU/UQ70 UD6$ US:X  a&  [        R
                  " XU/UQ70 UD6nU[        La  U$ [        R                  " XU/UQ70 UD6$ )Nc              3  X   #    U  H   n[        U[        [        [        45      v   M"     g 7frh   )r   r   r   r   ).0r   s     rO   	<genexpr>1ExtensionArray.__array_ufunc__.<locals>.<genexpr>  s%      
PVuJuy(LABBPVs   (*outreduce)r   NotImplementedr"   !maybe_dispatch_ufunc_to_dunder_opdispatch_ufunc_with_outdispatch_reduction_ufuncdefault_array_ufunc)rk   ufuncr   inputsr   r   s         rO   __array_ufunc__ExtensionArray.__array_ufunc__  s     
PV
 
 
 "!<<
"(
,2
 'MF?44V&,06  X77V&,06F ^+,,T&T6TVTTrS   c                    [        XUS9$ )a3  
Map values using an input mapping or function.

Parameters
----------
mapper : function, dict, or Series
    Mapping correspondence.
na_action : {None, 'ignore'}, default None
    If 'ignore', propagate NA values, without passing them to the
    mapping correspondence. If 'ignore' is not supported, a
    ``NotImplementedError`` should be raised.

Returns
-------
Union[ndarray, Index, ExtensionArray]
    The output of the mapping function applied to the array.
    If the function returns a tuple with more than one element
    a MultiIndex will be returned.
)	na_action)r(   )rk   mapperr  s      rO   mapExtensionArray.map  s    ( ;;rS   c                  SSK Jn  SSKJn  UR	                  U5      n	U" XUS9n
[        U R                  U5      (       as  U
R                  S;  a@  U
R                  U
R                  U
R                  [        R                  " [        5      S5        U R                  [        [        R                  S9nO[        SU R                   35      eU
R                  " U4UUUS	S
.UD6nU
R                  U
R                   ;   a  U$ [        U R                  U5      (       a+  U R                  nUR#                  5       nUR%                  XS9$ [        e)a3  
Dispatch GroupBy reduction or transformation operation.

This is an *experimental* API to allow ExtensionArray authors to implement
reductions and transformations. The API is subject to change.

Parameters
----------
how : {'any', 'all', 'sum', 'prod', 'min', 'max', 'mean', 'median',
       'median', 'var', 'std', 'sem', 'nth', 'last', 'ohlc',
       'cumprod', 'cumsum', 'cummin', 'cummax', 'rank'}
has_dropped_na : bool
min_count : int
ngroups : int
ids : np.ndarray[np.intp]
    ids[i] gives the integer label for the group that self[i] belongs to.
**kwargs : operation-specific
    'any', 'all' -> ['skipna']
    'var', 'std', 'sem' -> ['ddof']
    'cumprod', 'cumsum', 'cummin', 'cummax' -> ['skipna']
    'rank' -> ['ties_method', 'ascending', 'na_option', 'pct']

Returns
-------
np.ndarray or ExtensionArray
r   )StringDtype)WrappedCythonOp)howr   has_dropped_na)r   r   F)r   z,function is not implemented for this dtype: N)	min_countngroupscomp_idsr   r   )pandas.core.arrays.string_r  pandas.core.groupby.opsr  get_kind_from_howr   rJ   r  _get_cython_functionr   r   r  r   r  rs   _cython_op_ndim_compatcast_blocklistr   rP   )rk   r  r  r  r  idsr   r  r  r   opr  r  rJ   string_array_clss                  rO   _groupby_opExtensionArray._groupby_op	  s-   H 	;;005O djj+..vv^+''&9I5Q}}Vbff}=H%>tzzlK  ..

 

 66R&&& djj+..JJE$99;#22:2KK &%rS   ri   )rJ   Dtype | NonerK   r   )rJ   r6   returnr=   )rl   r<   r  r   )rl   r>   r  r=   )rl   r;   r  z
Self | Anyr  None)r  int)r  zIterator[Any])rl   r  r  zbool | np.bool_)r   r  r  r2   )rJ   znpt.DTypeLike | NonerK   r   r   r  r  
np.ndarray)r  r   )r  r?   ).)rJ   znpt.DTypeLikerK   r   r  r  )rJ   r   rK   r   r  rF   )rJ   r3   rK   r   r  r2   )T)r  z)np.ndarray | ExtensionArraySupportsAnyAll)r  r   )r  r  )r   r   r   r@   r   rR  r  r  )r   r   r  r  )
r   r8   r   r  r   rC   rK   r   r  r=   )
r   r7   r   
int | Noner   z#Literal['inside', 'outside'] | NonerK   r   r  r=   )NNNT)
rv   zobject | ArrayLike | Noner   zFillnaOptions | Noner   r  rK   r   r  r=   )r  r=   )first)r   zLiteral['first', 'last', False]r  npt.NDArray[np.bool_])r   N)r  r  r  r  r  rF   )leftN)rv   z$NumpyValueArrayLike | ExtensionArrayr  zLiteral['left', 'right']r  zNumpySorter | Noner  znpt.NDArray[np.intp] | np.intp)r   r  r  r   )rc   r2   r  r  )r  ztuple[np.ndarray, Any])r"  r   r  z!tuple[np.ndarray, ExtensionArray]rh   )r,  zint | Sequence[int]r   zAxisInt | Noner  r=   )r0  rA   r   r   r  r   r  r=   )rJ   r  r  r2   )r  rR  )F)rT  r   r  zCallable[[Any], str | None])rW  r  r  rF   )r  rF   )C)r^  z"Literal['C', 'F', 'A', 'K'] | Noner  rF   )rb  zSequence[Self]r  r=   )rh  rR  r   r   r  rF   )rh  rR  r   r   rk  r   )rw  rR  rx  rR  ry  r   r  znpt.NDArray[np.uint64])r  z#tuple[Self, npt.NDArray[np.uint64]])r  r  )r  r;   r  r=   )r  r  r  r=   )r   r  r  r  )r   r  r  r=   )r   rR  r   r  r   r  r  r  )
r   r4   r   rR  r  rR  r   r   r  r   )r   r?   rJ   r   )r  znpt.NDArray[np.float64]r  rR  r  r=   )r   r   r  r=   )r  znp.ufuncr   rR  )r  rR  r  r   r  r  r  r  r  znpt.NDArray[np.intp]r  r2   )Ur   
__module____qualname____firstlineno____doc___typ__pandas_priority__classmethodrP   r\   r`   re   r
   rm   rw   r{   r   r   r   r   r   r   r   propertyrJ   r   r   r   r   r   r!   r   r   r   r   r   r   r   r   r   r%   r
  r+   r  r  r'   r  r%  rD   r   r   r'  r   rK   r5  rG  rC  r?  rA  rX  r[  r_  r  r   r   ri  ro  __annotations__rs  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  __static_attributes__ri   rS   rO   rF   rF   n   s   Nd D  >BQV ' '8  > /3%' ,';?' '< ' '>    (B+SZ(((
(  '+>>	"#" " 	"
 
"P 	( 	( 
 
 # # 
 
 ( ("      E:N(8 ' '!L $!6
 6
 	6

 6
 
6
p *D *D"
 #"
 	"

 "
 "
 
"
P !:>] ] 	]
 8] ] 
]B ,0'+ `(` %` 	`
 ` 
`D"$ 7>=3=	=2:.x>, *0%)	:A3:A ':A #	:A
 
(:Ax'9R.0+> !%?!?! 
+?!F(	 !X ()*845 6 * !](]( 	](
 ]( 
](~(("P/ ;7"$T(    4 ' 'B ' ' ,0&S&S$(&S	&SR ,0%22$(2;?2n  #
#
*-#
;?#
	#
J!F,""PH60&&",&4I&	&* 
 
 	

 
 
 
0  ,5()(U4<2J& J& 	J&
 J& J& "J& 
J&rS   rF   c                  8    \ rS rSrSS.SS jjrSS.SS jjrSrg)	ExtensionArraySupportsAnyAllid	  Trf  c                   [        U 5      erh   r   r   s     rO   r    ExtensionArraySupportsAnyAll.anye	      !$''rS   c                   [        U 5      erh   r   r   s     rO   r    ExtensionArraySupportsAnyAll.allh	  r  rS   ri   N)r   r   r  r   )r   r  r  r  r   r   r  ri   rS   rO   r  r  d	  s    $( ( %) ( (rS   r  c                      \ rS rSrSr\S 5       r\SS j5       r\S 5       r\SS j5       r	\S 5       r
\SS j5       rS	rg
)ExtensionOpsMixinil	  z
A base class for linking the operators to their dunder names.

.. note::

   You may want to set ``__array_priority__`` if you want your
   implementation to be called when involved in binary operations
   with NumPy arrays.
c                    [        U 5      erh   r   rM   r  s     rO   _create_arithmetic_method+ExtensionOpsMixin._create_arithmetic_methodw	      !#&&rS   c                0   [        U SU R                  [        R                  5      5        [        U SU R                  [        R
                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U S	U R                  [        R                  5      5        [        U S
U R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                   5      5        [        U SU R                  [        R"                  5      5        [        U SU R                  [$        5      5        [        U SU R                  [        R&                  5      5        g )N__add____radd____sub____rsub____mul____rmul____pow____rpow____mod____rmod____floordiv____rfloordiv____truediv____rtruediv__
__divmod____rdivmod__)setattrr  operatoraddr$   raddsubrsubmulrmulpowrpowmodrmodfloordiv	rfloordivtruedivrtruedivdivmodrdivmodrM   s    rO   _add_arithmetic_ops%ExtensionOpsMixin._add_arithmetic_ops{	  s   Y = =hll KLZ!>!>y~~!NOY = =hll KLZ!>!>y~~!NOY = =hll KLZ!>!>y~~!NOY = =hll KLZ!>!>y~~!NOY = =hll KLZ!>!>y~~!NO^S%B%B8CTCT%UV#"?"?	@S@S"T	
 	]C$A$A(BRBR$ST^S%B%B9CUCU%VW\3#@#@#HI]C$A$A)BSBS$TUrS   c                    [        U 5      erh   r   r  s     rO   _create_comparison_method+ExtensionOpsMixin._create_comparison_method	  r  rS   c                   [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R
                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        g )Nr   r   __lt____gt____le____ge__)	r  r&  r  eqneltgtleger"  s    rO   _add_comparison_ops%ExtensionOpsMixin._add_comparison_ops	  s    Xs<<X[[IJXs<<X[[IJXs<<X[[IJXs<<X[[IJXs<<X[[IJXs<<X[[IJrS   c                    [        U 5      erh   r   r  s     rO   _create_logical_method(ExtensionOpsMixin._create_logical_method	  r  rS   c                   [        U SU R                  [        R                  5      5        [        U SU R                  [        R
                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        [        U SU R                  [        R                  5      5        g )N__and____rand____or____ror____xor____rxor__)
r  r6  r  and_r$   rand_or_ror_xorrxorr"  s    rO   _add_logical_ops"ExtensionOpsMixin._add_logical_ops	  s    Y : :8== IJZ!;!;IOO!LMXs99(,,GHY : :9>> JKY : :8<< HIZ!;!;INN!KLrS   ri   Nr  )r   r  r  r  r  r  r  r#  r&  r3  r6  rE  r  ri   rS   rO   r  r  l	  s     ' ' V V( ' ' K K ' ' M MrS   r  c                  P    \ rS rSrSr\SS	S jj5       r\S 5       r\S 5       rSr	g)
ExtensionScalarOpsMixini	  a  
A mixin for defining ops on an ExtensionArray.

It is assumed that the underlying scalar objects have the operators
already defined.

Notes
-----
If you have defined a subclass MyExtensionArray(ExtensionArray), then
use MyExtensionArray(ExtensionArray, ExtensionScalarOpsMixin) to
get the arithmetic operators.  After the definition of MyExtensionArray,
insert the lines

MyExtensionArray._add_arithmetic_ops()
MyExtensionArray._add_comparison_ops()

to link the operators to your class.

.. note::

   You may want to set ``__array_priority__`` if you want your
   implementation to be called when involved in binary operations
   with NumPy arrays.
Nc                P   ^^^ UUU4S jnSTR                    S3n[        XEU 5      $ )a  
A class method that returns a method that will correspond to an
operator for an ExtensionArray subclass, by dispatching to the
relevant operator defined on the individual elements of the
ExtensionArray.

Parameters
----------
op : function
    An operator that takes arguments op(a, b)
coerce_to_dtype : bool, default True
    boolean indicating whether to attempt to convert
    the result to the underlying ExtensionArray dtype.
    If it's not possible to create a new ExtensionArray with the
    values, an ndarray is returned instead.

Returns
-------
Callable[[Any, Any], Union[ndarray, ExtensionArray]]
    A method that can be bound to a class. When used, the method
    receives the two arguments, one of which is the instance of
    this class, and should return an ExtensionArray or an ndarray.

    Returning an ndarray may be necessary when the result of the
    `op` cannot be stored in the ExtensionArray. The dtype of the
    ndarray uses NumPy's normal inference rules.

Examples
--------
Given an ExtensionArray subclass called MyExtensionArray, use

    __add__ = cls._create_method(operator.add)

in the class definition of MyExtensionArray to create the operator
for addition, that will be based on the operator implementation
of the underlying elements of the ExtensionArray
c                <  >^  U 4S jn[        U[        [        [        45      (       a  [        $ T nU" U5      n[        X45       VVs/ s H  u  pVT
" XV5      PM     nnnU	UU 4S jnT
R                  S;   a  [        U6 u  pVU" U5      U" U5      4$ U" U5      $ s  snnf )Nc                x   > [        U [        5      (       d  [        U 5      (       a  U nU$ U /[        T5      -  nU$ rh   )r   rF   r   r   )paramovaluesrk   s     rO   convert_valuesNExtensionScalarOpsMixin._create_method.<locals>._binop.<locals>.convert_values	  s=    e^44U8K8K#G   %gD	1GrS   c                   > T(       aG  [        U TR                  SS9n[        U[        T5      5      (       d  [        R
                  " U 5      nU$ [        R
                  " U TS9nU$ )NF)
same_dtyper   )r   rJ   r   rt   r   r   )r  rescoerce_to_dtyperesult_dtyperk   s     rO   _maybe_convertNExtensionScalarOpsMixin._create_method.<locals>._binop.<locals>._maybe_convert 
  sW    " 6c4::RWXC%c4:66 jjo 
 **S=C
rS   >   r   r!  )r   r   r   r   r  zipr   )rk   r   rN  lvaluesrvaluesr  r	  rR  rU  rS  r  rT  s   `        rO   _binop6ExtensionScalarOpsMixin._create_method.<locals>._binop	  s     %)X|!DEE%%G$U+G +.g*?@*?2a8*?C@ {{33Cy%a(.*;;;!#&&' As   B__)r   r   )rM   r  rS  rT  rZ  op_names    ```  rO   _create_method&ExtensionScalarOpsMixin._create_method	  s+    P$	'L r{{m2& #66rS   c                $    U R                  U5      $ rh   )r^  r  s     rO   r  1ExtensionScalarOpsMixin._create_arithmetic_method
  s    !!"%%rS   c                ,    U R                  US[        S9$ )NF)rS  rT  )r^  r   r  s     rO   r&  1ExtensionScalarOpsMixin._create_comparison_method
  s    !!"e$!OOrS   ri   )TN)rS  r   )
r   r  r  r  r  r  r^  r  r&  r  ri   rS   rO   rH  rH  	  sH    2 N7 N7` & & P PrS   rH  )br  
__future__r   r  typingr   r   r   r   r   r	   r
   rZ   numpyr   pandas._libsr   r   r   pandas.compatr   pandas.compat.numpyr   r   pandas.errorsr   pandas.util._decoratorsr   r   r   pandas.util._exceptionsr   pandas.util._validatorsr   r   r   pandas.core.dtypes.castr   pandas.core.dtypes.commonr   r   r   pandas.core.dtypes.dtypesr   pandas.core.dtypes.genericr   r   r   pandas.core.dtypes.missingr!   pandas.corer"   r#   r$   pandas.core.algorithmsr%   r&   r'   r(   r)   r*   r+    pandas.core.array_algos.quantiler,   pandas.core.missingr-   pandas.core.sortingr.   r/   collections.abcr0   r1   pandas._typingr2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   pandasrC   rD   r  rF   r  r  rH  ri   rS   rO   <module>r{     s   #      , . - 
 5  @ 
 5 
 , 
   @ 3
 
    ( /1 n 1s#& s#&lG(> (<M <M~qP/ qPrS   