
    OwgR                    H   d dl mZ d dlmZmZmZmZmZ d dlZd dl	Z
d dlmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dl m!Z!m"Z" d dl#m$Z$ d d	l%m&Z& d d
l'm(Z( d dl)m*Z* d dl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 d dl2m3Z3 d dl4m5Z5m6Z6m7Z7m8Z8 d dl9m:Z;m<Z<mZm=Z=m>Z> d dl?m@Z@mAZAmBZBmCZCmDZD d dlEmFZFmGZG d dlHmIZI d dlJmKZK d dlLmMZM d dlNmOZO d dlPmQZRmSZSmTZT d dlUmVZV d dlWmXZX d dlYmZZZ er"d dl[m\Z\m]Z] d dl^m_Z_ d dl`maZa d dlmbZbmcZc d dl`mdZd d dlemfZg  G d  d!eKeO      Zh	 	 	 	 d#d"Ziy)$    )annotations)TYPE_CHECKINGAnyCallableLiteraloverloadN)libmissing)is_supported_dtype)	ArrayLike	AstypeArgAxisIntDtypeObjFillnaOptionsInterpolateOptionsNpDtypePositionalIndexerScalarScalarIndexerSelfSequenceIndexerShapenpt)IS64is_platform_windowsAbstractMethodError)doc)validate_fillna_kwargs)ExtensionDtype)is_boolis_integer_dtypeis_list_like	is_scalaris_string_dtypepandas_dtype)BaseMaskedDtype)array_equivalentis_valid_na_for_dtypeisnanotna)
algorithms	arrayliker
   nanopsops)factorize_arrayisin	map_arraymodetake)masked_accumulationsmasked_reductions)quantile_with_mask)OpsMixin)to_numpy_dtype_inference)ExtensionArray)arrayensure_wrapped_if_datetimelikeextract_array)check_array_indexer)invalid_comparison)
hash_array)IteratorSequence)SeriesBooleanArray)NumpySorterNumpyValueArrayLikeFloatingArray)functionc                      e Zd ZU dZded<   ded<   ded<   eZeZedgd       Z		 dh	 	 	 	 	 	 	 did
Z
edd	ddjd       Ze eej                        dkd              ZdhdldZedmd       Zednd       Zedod       ZdpdZdddd	 	 	 	 	 	 	 	 	 dqdZ eej*                        	 dr	 	 	 	 	 dsd       Zed	d	 	 	 	 	 dtd       Zd ZdudZdv fdZdwdZdxdZedyd       Zedxd        Zdzd!Zd{d|d#Zdzd$Z dzd%Z!edzd&       Z"d{d}d'Z#dzd(Z$dzd)Z%dzd*Z&dzd+Z'd~d,Z(dd	e)jT                  f	 	 	 	 	 	 	 dd-Z+ eejX                        d.        Z,eddd/       Z-eddd0       Z-eddd1       Z-ddd2Z-d3Z.	 d	 	 	 	 	 dd4Z/d5ed6<   dd7Z0dd8Z1edvd9       Z2	 	 	 	 dd:Z3d; Z4e4Z5dd<Z6	 	 	 	 dd=Z7d~d>Z8ed?        Z9edxd@       Z:e	 d{	 	 	 	 	 ddA       Z;	 	 	 	 	 	 	 	 ddBZ<d	dd"dC	 	 	 	 	 	 	 ddDZ=ddEZ>dzdFZ? eej                        	 d	 	 	 ddG       Z@dzdHZA eej                        	 	 d	 	 	 	 	 	 	 ddI       ZB eej                        	 d	 	 	 ddJ       ZC eej                        d~dK       ZDdddLZEdddMZF eej                        dvdN       ZG	 	 	 	 	 	 ddOZHdd	dP	 	 	 	 	 ddQZIddRZJdS ZK	 	 ddTZLdd"d"dU	 	 	 	 	 ddVZMdd"d"dU	 	 	 	 	 ddWZNdd"dXddYZOdd"dZd[	 	 	 	 	 dd\ZPdd"dZd[	 	 	 	 	 dd]ZQdd"dXdd^ZRdd"dXdd_ZSdd`ZTdd"dXddaZUdd"dXddbZV	 	 	 	 	 	 	 	 ddcZWddd	 	 	 	 	 ddeZX	 	 	 	 	 	 	 	 	 	 ddfZY xZZS )BaseMaskedArrayzf
    Base class for masked arrays (which use _data and _mask to store the data).

    numpy based
    r   _internal_fill_value
np.ndarray_datanpt.NDArray[np.bool_]_maskc                L    t         j                  |       }||_        ||_        |S N)rL   __new__rO   rQ   )clsvaluesmaskresults       P/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/core/arrays/masked.py_simple_newzBaseMaskedArray._simple_new|   s%     ((-    Fc                0   t        |t        j                        r|j                  t        j                  k(  st        d      |j                  |j                  k7  rt        d      |r |j                         }|j                         }|| _	        || _
        y )NzGmask should be boolean numpy array. Use the 'pd.array' function insteadz"values.shape must match mask.shape)
isinstancenpndarraydtypebool_	TypeErrorshape
ValueErrorcopyrO   rQ   )selfrV   rW   re   s       rY   __init__zBaseMaskedArray.__init__   sx     4,rxx1G2  <<4::%ABB[[]F99;D

r[   Nr`   re   c               B    | j                  |||      \  }} | ||      S )Nrh   )_coerce_to_array)rU   scalarsr`   re   rV   rW   s         rY   _from_sequencezBaseMaskedArray._from_sequence   s*    ++G5t+L64  r[   c                   t        j                  ||j                        }|j                  | j                         t        j
                  |t              } | ||      }t        ||       r||j                  k7  rt        d| d      |S )Nr`   z5Default 'empty' implementation is invalid for dtype='')
r^   emptytypefillrM   onesboolr]   r`   NotImplementedError)rU   rc   r`   rV   rW   rX   s         rY   _emptyzBaseMaskedArray._empty   s{     %uzz2C,,-wwuD)VT"&#&%6<<*?%GwaP  r[   c                    t         S rS   )str)rf   boxeds     rY   
_formatterzBaseMaskedArray._formatter   s    
r[   c                    t        |       rS   r   rf   s    rY   r`   zBaseMaskedArray.dtype   s    !$''r[   c                     y rS    rf   items     rY   __getitem__zBaseMaskedArray.__getitem__       r[   c                     y rS   r~   r   s     rY   r   zBaseMaskedArray.__getitem__   r   r[   c                    t        | |      }| j                  |   }t        |      r'|r| j                  j                  S | j
                  |   S | j                  | j
                  |   |      S rS   )r>   rQ   r!   r`   na_valuerO   rZ   )rf   r   newmasks      rY   r   zBaseMaskedArray.__getitem__   sb    "4.**T"7zz***::d##

4 0'::r[   T)limit
limit_areare   c                  | j                   }|j                         rMt        j                  || j                        }| j
                  j                  }|j                  }|r!|j                         }|j                         }n||j                         } ||||       ||j                         s|j                  }| }	|	j                         }
t        |	      |	d d d   j                         z
  dz
  }|dk(  r)|d |
xxx |d |
 z  ccc ||dz   d xxx ||dz   d  z  ccc n|dk(  r||
dz   |xxx ||
dz   | z  ccc |r&| j                  |j                  |j                        S | S |r| j                         }|S | }|S )Nndimr   rW      insideoutside)rQ   anyr
   get_fill_funcr   rO   Tre   allargmaxlenrZ   )rf   methodr   r   re   rW   funcnpvaluesnew_maskneg_maskfirstlast
new_valuess                rY   _pad_or_backfillz BaseMaskedArray._pad_or_backfill   sv    zz88:((dii@Dzz||HvvH#==?#==?'yy{X6%dhhjvv 5 )8}x"~'<'<'>>B)Ve$Ve4$TAXZ(D,<<(9,UQY.$uqy42HH.''

HJJ??!YY[
  "
r[   c                <   t        ||      \  }}| j                  }t        j                  ||t	        |             }|j                         r|t        j                  || j                        }| j                  j                  }|j                  }|r |j                         }|j                         } ||||       | j                  |j                  |j                        S |r| j                         }	n| d d  }	||	|<   |	S |r| j                         }	|	S | d d  }	|	S )Nr   r   )r   rQ   r
   check_value_sizer   r   r   r   rO   r   re   rZ   )
rf   valuer   r   re   rW   r   r   r   r   s
             rY   fillnazBaseMaskedArray.fillna   s    /uf=vzz((c$i@88:!,,V$))D::<<66'}}H'}}HXU:''

HJJ?? !%J!%aJ#(
4  	 !YY[
  "!W
r[   re   c                   t        |       rS   r   )rU   rV   r`   re   s       rY   rj   z BaseMaskedArray._coerce_to_array  s     "#&&r[   c                   | j                   j                  }|dk(  rt        j                  |      ro|S |dk(  r,t        j                  |      st        j
                  |      r>|S t        j                  |      s%t        j
                  |      r|j	                         r|S t        dt        |       d| j                          )zy
        Check if we have a scalar that we can cast losslessly.

        Raises
        ------
        TypeError
        bfzInvalid value 'z' for dtype )r`   kindr	   r!   
is_integeris_floatrb   rx   )rf   r   r   s      rY   _validate_setitem_valuez'BaseMaskedArray._validate_setitem_value  s     zz3;{{5!S[~~e$U(; ~~e$e)<AQAQAS
 /#e*\$**NOOr[   c                Z   t        | |      }t        |      rVt        || j                        rd| j                  |<   y | j                  |      }|| j                  |<   d| j                  |<   y | j                  || j                        \  }}|| j                  |<   || j                  |<   y )NTFrn   )r>   r$   r)   r`   rQ   r   rO   rj   )rf   keyr   rW   s       rY   __setitem__zBaseMaskedArray.__setitem__3  s    !$,U$UDJJ7"&

3
  44U;"'

3"'

3++E+Dt

3

3r[   c                r   t        |      r|| j                  j                  ur|| j                  j                  j                  dk(  rYt        j                  |      rDt        t        j                  | j                        | j                   z  j                               S t        t        | 5  |            S )Nr   )r*   r`   r   rO   r   r	   r   rt   r^   isnanrQ   r   super__contains__)rf   r   	__class__s     rY   r   zBaseMaskedArray.__contains__D  s    9DJJ$7$77zz$$+S0ARXXdjj1TZZK?DDFGGEG(-..r[   c              #  B  K   | j                   dk(  rl| j                  s| j                  D ]  }|  y | j                  j                  }t        | j                  | j                        D ]  \  }}|r| |  y t        t        |             D ]	  }| |     y w)Nr   )	r   _hasnarO   r`   r   ziprQ   ranger   )rf   valr   isna_is        rY   __iter__zBaseMaskedArray.__iter__L  s     99>;;:: CI  ::.."%djj$**"= "JE3&!		" 3t9% 1gs   BBc                ,    t        | j                        S rS   )r   rO   r|   s    rY   __len__zBaseMaskedArray.__len__\  s    4::r[   c                .    | j                   j                  S rS   )rO   rc   r|   s    rY   rc   zBaseMaskedArray.shape_  s    zzr[   c                .    | j                   j                  S rS   )rO   r   r|   s    rY   r   zBaseMaskedArray.ndimc  s    zzr[   c                    | j                   j                  ||      }| j                  j                  ||      }| j                  ||      S rS   )rO   swapaxesrQ   rZ   )rf   axis1axis2datarW   s        rY   r   zBaseMaskedArray.swapaxesg  sA    zz""5%0zz""5%0d++r[   r   c                    t        j                  | j                  ||      }t        j                  | j                  ||      }| j	                  ||      S Naxis)r^   deleterO   rQ   rZ   )rf   locr   r   rW   s        rY   r   zBaseMaskedArray.deletel  sA    yySt4yySt4d++r[   c                     | j                   j                  |i |} | j                  j                  |i |}| j                  ||      S rS   )rO   reshaperQ   rZ   rf   argskwargsr   rW   s        rY   r   zBaseMaskedArray.reshapeq  sK    !tzz!!4262!tzz!!4262d++r[   c                     | j                   j                  |i |} | j                  j                  |i |} t        |       ||      S rS   )rO   ravelrQ   rq   r   s        rY   r   zBaseMaskedArray.ravelv  sK    tzz00tzz00tDz$%%r[   c                v    | j                  | j                  j                  | j                  j                        S rS   )rZ   rO   r   rQ   r|   s    rY   r   zBaseMaskedArray.T|  s%    

djjll;;r[   c                    | j                   j                  dk(  r| S t        j                  ||       t	        j
                  | j                  fd|i|}| j                  || j                  j                               S )a  
        Round each value in the array a to the given number of decimals.

        Parameters
        ----------
        decimals : int, default 0
            Number of decimal places to round to. If decimals is negative,
            it specifies the number of positions to the left of the decimal point.
        *args, **kwargs
            Additional arguments and keywords have no effect but might be
            accepted for compatibility with NumPy.

        Returns
        -------
        NumericArray
            Rounded values of the NumericArray.

        See Also
        --------
        numpy.around : Round values of an np.array.
        DataFrame.round : Round values of a DataFrame.
        Series.round : Round values of a Series.
        r   decimals)
r`   r   nvvalidate_roundr^   roundrO   _maybe_mask_resultrQ   re   )rf   r   r   r   rV   s        rY   r   zBaseMaskedArray.round  se    0 ::??c!K
$'$**BxB6B &&vtzz/@AAr[   c                l    | j                  | j                   | j                  j                               S rS   rZ   rO   rQ   re   r|   s    rY   
__invert__zBaseMaskedArray.__invert__  &    TZZ__->??r[   c                l    | j                  | j                   | j                  j                               S rS   r   r|   s    rY   __neg__zBaseMaskedArray.__neg__  r   r[   c                "    | j                         S rS   r   r|   s    rY   __pos__zBaseMaskedArray.__pos__  s    yy{r[   c                |    | j                  t        | j                        | j                  j	                               S rS   )rZ   absrO   rQ   re   r|   s    rY   __abs__zBaseMaskedArray.__abs__  s(    DJJ1BCCr[   c                8    t        j                  | t              S )Nrn   )r^   asarrayobjectr|   s    rY   _values_for_jsonz BaseMaskedArray._values_for_json  s    zz$f--r[   c                b   | j                   }t        | |||      \  }}|t        }|r|t        k7  r,t        |      s!|t        j
                  u rt        d| d      t        j                         5  t        j                  dt               | j                  j                  |      }ddd       || j                  <   |S t        j                         5  t        j                  dt               | j                  j                  ||      }ddd       |S # 1 sw Y   qxY w# 1 sw Y   S xY w)aF  
        Convert to a NumPy Array.

        By default converts to an object-dtype NumPy array. Specify the `dtype` and
        `na_value` keywords to customize the conversion.

        Parameters
        ----------
        dtype : dtype, default object
            The numpy dtype to convert to.
        copy : bool, default False
            Whether to ensure that the returned value is a not a view on
            the 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. This is typically
            only possible when no missing values are present and `dtype`
            is the equivalent numpy dtype.
        na_value : scalar, optional
             Scalar missing value indicator to use in numpy array. Defaults
             to the native missing value indicator of this array (pd.NA).

        Returns
        -------
        numpy.ndarray

        Examples
        --------
        An object-dtype is the default result

        >>> a = pd.array([True, False, pd.NA], dtype="boolean")
        >>> a.to_numpy()
        array([True, False, <NA>], dtype=object)

        When no missing values are present, an equivalent dtype can be used.

        >>> pd.array([True, False], dtype="boolean").to_numpy(dtype="bool")
        array([ True, False])
        >>> pd.array([1, 2], dtype="Int64").to_numpy("int64")
        array([1, 2])

        However, requesting such dtype will raise a ValueError if
        missing values are present and the default missing value :attr:`NA`
        is used.

        >>> a = pd.array([True, False, pd.NA], dtype="boolean")
        >>> a
        <BooleanArray>
        [True, False, <NA>]
        Length: 3, dtype: boolean

        >>> a.to_numpy(dtype="bool")
        Traceback (most recent call last):
        ...
        ValueError: cannot convert to bool numpy array in presence of missing values

        Specify a valid `na_value` instead

        >>> a.to_numpy(dtype="bool", na_value=False)
        array([ True, False, False])
        Nzcannot convert to 'zZ'-dtype NumPy array with missing values. Specify an appropriate 'na_value' for this dtype.ignorecategoryr   )r   r9   r   r%   
libmissingNArd   warningscatch_warningsfilterwarningsRuntimeWarningrO   astyperQ   )rf   r`   re   r   hasnar   s         rY   to_numpyzBaseMaskedArray.to_numpy  s   D 24%Px=E'.
- )% 1& &  ((* 0''>Jzz((/0  (D
  ((* ;''>Jzz((T(:; 0 0
; s   17D9D$D!$D.c                   | j                   dkD  r| D cg c]  }|j                          c}S | j                  rd n| j                  j                  }| j                  |t        j                        j                         S c c}w )Nr   r`   r   )r   tolistr   rO   r`   r   r   r   )rf   xr`   s      rY   r   zBaseMaskedArray.tolist  s`    99q=(,-1AHHJ--)9)9}}5:==}AHHJJ .s   Bc                     y rS   r~   rf   r`   re   s      rY   r   zBaseMaskedArray.astype  r   r[   c                     y rS   r~   r   s      rY   r   zBaseMaskedArray.astype  r   r[   c                     y rS   r~   r   s      rY   r   zBaseMaskedArray.astype   r   r[   c                   t        |      }|| j                  k(  r|r| j                         S | S t        |t              rt        j                         5  t        j                  dt               | j                  j                  |j                  |      }d d d        | j                  u r| j                  n| j                  j                         }|j                         } |||d      S t        |t              r$|j                         }|j                  | ||      S |j                   dk(  rt"        j$                  }n5|j                   dk(  rt#        j&                  d      }nt(        j*                  }|j                   d	v r| j,                  rt/        d
      |j                   dk(  r| j,                  rt/        d      | j1                  |||      }|S # 1 sw Y   CxY w)Nr   r   r   Frh   r   MNaTiuzcannot convert NA to integerr   z cannot convert float NaN to bool)r`   r   re   )r&   r`   re   r]   r'   r   r   r   r   rO   r   numpy_dtyperQ   construct_array_typer    rl   r   r^   nan
datetime64r	   
no_defaultr   rd   r   )rf   r`   re   r   rW   rU   eaclsr   s           rY   r   zBaseMaskedArray.astype$  s   U#DJJyy{"K e_-((* G''>Jzz(():):(FG "&!34::9JD,,.CtT..e^,..0E''E'EE
 ::vvHZZ3}}U+H~~H ::$++;<<::?@@}}58$}GCG Gs   AGG!i  c                &    | j                  |      S )z|
        the array interface, return my values
        We return an object array here to preserve our scalar values
        rn   )r   r   s      rY   	__array__zBaseMaskedArray.__array__T  s     }}5}))r[   ztuple[type, ...]_HANDLED_TYPESc                8  	
 |j                  dd      }||z   D ](  }t        || j                  t        fz         r"t        c S  t        j                  | ||g|i |}|t        ur|S d|v rt        j                  | ||g|i |S |dk(  r%t        j                  | ||g|i |}|t        ur|S t        j                  t        |       t              	g }|D ]N  }t        |t              r+	|j                  z  	|j                  |j                         >|j                  |       P d	fd
 t!        ||      |i |}|j"                  dkD  rt%        
fd|D              S |dk(  r(| j                  j'                         r| j(                  S |S  
|      S )	Noutr~   reducern   c                   ddl m}m}m} | j                  j
                  dk(  rj                         } || |      S | j                  j
                  dv rj                         } || |      S | j                  j
                  dk(  rUj                         }| j                  t        j                  k(  r| j                  t        j                        }  || |      S t        j                  | <   | S )Nr   )rE   rI   IntegerArrayr   r  r   )pandas.core.arraysrE   rI   r  r`   r   re   r^   float16r   float32r  )r   rE   rI   r  mrW   s        rY   reconstructz4BaseMaskedArray.__array_ufunc__.<locals>.reconstruct  s      ww||s"IIK#Aq))%IIK#Aq))$IIK77bjj( ,A$Q**&&$Hr[   r   c              3  .   K   | ]  } |        y wrS   r~   ).0r   r  s     rY   	<genexpr>z2BaseMaskedArray.__array_ufunc__.<locals>.<genexpr>  s     8AQ8s   )r   rN   )getr]   r
  rL   NotImplementedr-   !maybe_dispatch_ufunc_to_dunder_opdispatch_ufunc_with_outdispatch_reduction_ufuncr^   zerosr   rt   rQ   appendrO   getattrnouttupler   	_na_value)rf   ufuncr   inputsr   r  r   rX   inputs2rW   r  s            @@rY   __array_ufunc__zBaseMaskedArray.__array_ufunc___  s    jj## 	&Aa!4!47I!IJ%%	&
 <<%
"(
,2
 'MF?44eV&,06  X77eV&,06F ^+xxD	. 	"A!_-qww'q!	"	4 (';F;::>8888xzz~~~~%Mv&&r[   c                Z    ddl }|j                  | j                  | j                  |      S )z6
        Convert myself into a pyarrow Array.
        r   N)rW   rq   )pyarrowr;   rO   rQ   )rf   rq   pas      rY   __arrow_array__zBaseMaskedArray.__arrow_array__  s$     	xx

$x??r[   c                6    | j                   j                         S rS   )rQ   r   r|   s    rY   r   zBaseMaskedArray._hasna  s     zz~~r[   c                    |e| j                   j                         }|t        j                  u r|dz  }|S t	        |      r%t        |      t        |      k(  r|t        |      z  }|S | j                   |z  }|S )NT)rQ   re   r   r   r#   r   r*   )rf   rW   others      rY   _propagate_maskzBaseMaskedArray._propagate_mask  sz     <::??$D
%d{  e$Us4y)@d5k)
  ::$D r[   c                   |j                   }d }t        |d      s:t        |      r/t        |      t        |       k(  rt	        |      }t        |d      }t        |t              r|j                  |j                  }}nJt        |      r?t        |t              st        j                  |      }|j                  dkD  rt        d      t        j                   |t        |       f      }t        j"                  |      }t%        |      }|dv r%t        |t        j&                        rt)        |      }| j+                  ||      }|t,        j.                  u rt        j0                  | j                        }| j2                  j4                  dk(  r.|dv rt        d	| d
      |dv rd}nd}|j7                  |      }nd|v r| j2                  j4                  dk7  rp|j7                  t        j8                        }nP| j2                  j4                  dv r|dv r|}t        j:                  d      5   || j                  |      }d d d        |dk(  rt        j<                  | j                  dk(  | j                   z  d|      }|t        j<                  |dk(  | z  d|      }n|t,        j.                  urt        j<                  |dk(  d|      }n|dk(  r|t        j<                  |dk(  | z  d|      }n,|t,        j.                  urt        j<                  |dk(  d|      }t        j<                  | j                  dk(  | j                   z  d|      }| j?                  |      S # 1 sw Y   %xY w)Nr`   T)extract_numpyr   (can only perform ops with 1-d structures>   powrpowr   >   r2  r3  truedivfloordivrtruediv	rfloordivz
operator 'z!' not implemented for bool dtypes>   modrmodint8rt   r4  r   r  )r5  r8  r   )r   r2  Fr   r3  ) __name__hasattrr#   r   pd_arrayr=   r]   rL   rO   rQ   r:   r^   r   r   ru   r/   maybe_prepare_scalar_for_opget_array_opr<   ra   rt   r.  r   r   	ones_liker`   r   r   float64errstatewherer   )	rf   r-  opop_nameomaskpd_oprW   rX   r`   s	            rY   _arith_methodzBaseMaskedArray._arith_method  s   ++ w'U#E
c$i' UOE!%t<Ee_- ;;5E% e^4

5)zzA~)*TUU //D	|D  $.u5o%*UBHH*E KE##E51JMM!\\$**-Fzz#%   .$WI-NO  o-"E"Eu-g%$**//S*@  rzz2 zz$&76I+I * 2tzz512 e88TZZ1_;UDID xx!v 5udCjmm+xx
E48 xx!v 5udCjmm+xx
E4888TZZ1_;UDID&&vt44+2 2s   ,M##M-c                |   ddl m} d }t        |t              r|j                  |j
                  }}n\t        |      rQt        j                  |      }|j                  dkD  rt        d      t        |       t        |      k7  rt        d      |t        j                  u rWt        j                  | j                  j                   d      }t        j"                  | j                  j                   d      }nt%        j&                         5  t%        j(                  dd	t*               t%        j(                  dd	t,               t/        | j                  d
|j0                   d
      } ||      }|t2        u rt5        | j                  ||      }d d d        | j7                  ||      } ||d      S # 1 sw Y   &xY w)Nr   rD   r   r1  zLengths must match to comparert   rn   r   elementwise__Fr   )r  rE   r]   rL   rO   rQ   r#   r^   r   r   ru   r   rd   r   r   r  rc   rs   r   r   r   FutureWarningDeprecationWarningr  r;  r  r?   r.  )rf   r-  rD  rE   rW   rX   r   s          rY   _cmp_methodzBaseMaskedArray._cmp_method,  s_   3e_-++u{{4E% JJu%EzzA~)*TUU4yCJ& !@AAJMM!
 XXdjj..f=F774::++6:D((* G ''-O''-AST r"++b-AB^+/

E2FFG ##D%0FDu55G Gs   BF22F;c                   t        |t              r)|\  }}| j                  ||      | j                  ||      fS |j                  j                  dk(  rddlm}  |||d      S |j                  j                  dk(  rddlm}  |||d      S t        j                  |j                  d      rdt        |j                        rOdd	lm} |j                  j                  d
      ||<   t        ||      s|j                  ||j                        S |S |j                  j                  dv rddlm}  |||d      S t        j                   ||<   |S )z
        Parameters
        ----------
        result : array-like or tuple[array-like]
        mask : array-like bool
        r   r   rH   Fr   r   rD   r  )TimedeltaArrayr   rn   r  r  )r]   r!  r   r`   r   r  rI   rE   r	   is_np_dtyper   rP  rq   rZ   r  r^   r  )	rf   rX   rW   divr8  rI   rE   rP  r  s	            rY   r   z"BaseMaskedArray._maybe_mask_resultT  s%    fe$HC''T2''T2 
 <<#8 E::\\#%7599__V\\3/4Fv||4T9!<<,,U3F4Lfn5%11&1MMM\\$&7599 66F4LMr[   c                6    | j                   j                         S rS   )rQ   re   r|   s    rY   r*   zBaseMaskedArray.isna  s    zz  r[   c                .    | j                   j                  S rS   r   r|   s    rY   r"  zBaseMaskedArray._na_value  s    zz"""r[   c                \    | j                   j                  | j                  j                  z   S rS   )rO   nbytesrQ   r|   s    rY   rW  zBaseMaskedArray.nbytes  s!    zz  4::#4#444r[   c                    t        j                  |D cg c]  }|j                   c}|      }t        j                  |D cg c]  }|j                   c}|      } | ||      S c c}w c c}w r   )r^   concatenaterO   rQ   )rU   	to_concatr   r   r   rW   s         rY   _concat_same_typez!BaseMaskedArray._concat_same_type  sV     ~~	:1qww:F~~	:1qww:F4 ;:s   A(A-c                   t        | j                  |||      }t        | j                  j                        || j                         <   |S )N)encodinghash_key
categorize)r@   rO   hashr`   r   r*   )rf   r]  r^  r_  hashed_arrays        rY   _hash_pandas_objectz#BaseMaskedArray._hash_pandas_object  sB     "JJH
 %))<)<$=TYY[!r[   )
allow_fill
fill_valuer   c                  t        |      r| j                  n|}t        | j                  ||||      }t        | j                  |d||      }|r-t        |      r"t        j                  |      dk(  }|||<   ||z  }| j                  ||      S )N)rd  rc  r   Tr   )	r*   rM   r4   rO   rQ   r+   r^   r   rZ   )	rf   indexerrc  rd  r   data_fill_valuerX   rW   	fill_masks	            rY   r4   zBaseMaskedArray.take  s     8<J7G$33ZJJ&!
 JJDZd
 %
+

7+r1I *F9)#D--r[   c                b    ddl m} t        j                  |      }t	         j
                  |      } j                  r8|j                  t        k(  xr t         fd|D              }|| j                  <   t        j                   j
                  j                  t              } |||d      S )Nr   rD   c              3  N   K   | ]  }|j                   j                  u   y wrS   r   )r  r   rf   s     rY   r  z'BaseMaskedArray.isin.<locals>.<genexpr>  s'      @/2tzz***@s   "%rn   Fr   )r  rE   r^   r   r1   rO   r   r`   r   r   rQ   r  rc   rt   )rf   rV   rE   
values_arrrX   values_have_NArW   s   `      rY   r1   zBaseMaskedArray.isin  s    3 ZZ'
djj*-;;'--7 C @6@@ =N "0F4::xx

((5FDu55r[   c                    | j                   j                         }| j                  j                         }| j                  ||      S rS   )rO   re   rQ   rZ   )rf   r   rW   s      rY   re   zBaseMaskedArray.copy  s5    zz zz d++r[   c                b    | j                   }| j                  }t        j                  |||      S )N)keeprW   )rO   rQ   algos
duplicated)rf   ro  rV   rW   s       rY   rq  zBaseMaskedArray.duplicated  s+     zzT==r[   c                    t        j                  | j                  | j                        \  }}| j	                  ||      S )z
        Compute the BaseMaskedArray of unique values.

        Returns
        -------
        uniques : BaseMaskedArray
        )rp  unique_with_maskrO   rQ   rZ   )rf   uniquesrW   s      rY   uniquezBaseMaskedArray.unique  s5     ..tzz4::F..r[   c                    | j                   rt        d      t        |t              r|j	                  t
              }| j                  j                  |||      S )NzOsearchsorted requires array to be sorted, which is impossible with NAs present.)sidesorter)r   rd   r]   r:   r   r   rO   searchsorted)rf   r   rw  rx  s       rY   ry  zBaseMaskedArray.searchsorted  sS     ;;$  e^,LL(Ezz&&u4&GGr[   c                   | j                   }| j                  }t        |d|      \  }}|j                  | j                  j                  k(  sJ |j                  | j                  f       |j                         }|s|st        |      }nt        |      dz   }t        j                  |t              }|sw|ru|j                         }	|	dk(  rt        j                  d      }
n|d |	 j                         dz   }
|||
k\  xx   dz  cc<   |
||dk(  <   t        j                  ||
d      }d||
<   | j                  ||      }||fS )NT)use_na_sentinelrW   r   rn   r   r   )rO   rQ   r0   r`   r  r   r   r^   r  rt   r   intpmaxinsertrZ   )rf   r{  arrrW   codesrt  has_nasizeuniques_maskna_indexna_code
uniques_eas               rY   	factorizezBaseMaskedArray.factorize  s-   
 jjzz )dNw }}

 6 66S

8SS6&w<D w<!#DxxD16{{}H1}''!*	*..014%7"#q(#!(E%2+ii!4G$(L!%%g|<
j  r[   c                    | j                   S rS   )rO   r|   s    rY   _values_for_argsortz#BaseMaskedArray._values_for_argsort'  s    zzr[   c                   ddl m}m} ddlm} t        j                  | j                  || j                        \  }}}t        j                  t        |      ft        j                        }|j                         }	|dkD  rd|d<    |||	      }
 | | j                  j                         ||            } ||
|dd	
      S )aA  
        Returns a Series containing counts of each unique value.

        Parameters
        ----------
        dropna : bool, default True
            Don't include counts of missing values.

        Returns
        -------
        counts : Series

        See Also
        --------
        Series.value_counts
        r   )IndexrC   rQ  dropnarW   rn   Tr   countF)indexnamere   )pandasr  rC   pandas.arraysr  rp  value_counts_arraylikerO   rQ   r^   r  r   ra   re   r`   r  )rf   r  r  rC   r  keysvalue_counts
na_counter
mask_indexrW   r  r  s               rY   r  zBaseMaskedArray.value_counts+  s    "	
 	/).)E)EJJvDJJ*
&lJ XXs<02"((C
 >!JrN<.-DJJ++-j

 cW5AAr[   c                >   |rRt        | j                  || j                        }t        j                  |j
                  t        j                        }n%t        | j                  || j                        \  }} t        |       ||      }||j                            S )Nr  rn   )	r3   rO   rQ   r^   r  rc   ra   rq   argsort)rf   r  rX   res_masks       rY   _modezBaseMaskedArray._modeS  sr    $**V$**EFxxBHH=H#DJJvDJJOFHdFH-fnn&''r[   c                B   t        |       t        |      k7  ry|j                  | j                  k7  ryt        j                  | j                  |j                        sy| j
                  | j                      }|j
                  |j                      }t        ||dd      S )NFT)
strict_nandtype_equal)rq   r`   r^   array_equalrQ   rO   r(   )rf   r-  leftrights       rY   equalszBaseMaskedArray.equals\  s|    :e$;;$**$ ~~djj%++6zz4::+&U[[L)e$OOr[   c                   t        | j                  | j                  t        j                  ||      }| j
                  r| j                  dk(  rt        | j                         j                         rpt        j                  |j                  t              }t        | j                        rt        j                  |j                  | j                  j                         }nKt        j                  |j                  t              }n%t        j                  |j                  t              }| j#                  ||      S )z
        Dispatch to quantile_with_mask, needed because we do not have
        _from_factorized.

        Notes
        -----
        We assume that all impacted cases are 1D-only.
        )rW   rd  qsinterpolation   rn   rW   )r7   rO   rQ   r^   r  r   r   ru   r*   r   rs   rc   rt   r"   r`   r  r  r   )rf   r  r  resout_masks        rY   	_quantilezBaseMaskedArray._quantilel  s     !JJ vv'
 ;; yyA~ *)yy{ 77399D9#DJJ/ ((399DJJ4J4JKC88CIIT:xx		6H&&s&::r[   )skipnakeepdimsc                  |dv r t        | |      dd|i|}nJ| j                  }| j                  }t        t        d|       }|j	                  dd       }	 ||f|	||d|}|r]t        |      r| j                  |dd      S |j                  d	      }t        j                  d	t        
      }| j                  ||      S t        |      rt        j                  S |S )N>	   r   r   r}  minstdsumvarmeanprodr  r  r   )r   r  rW   r   )r   )r  r   	mask_sizer   rn   r~   )r  rO   rQ   r.   popr*   _wrap_na_resultr   r^   r  rt   r   r   r   )
rf   r  r  r  r   rX   r   rW   rD  r   s
             rY   _reducezBaseMaskedArray._reduce  s     TT(WT4(AA&AF ::D::D3tf.B::fd+DL4TLVLFF|++A+NN*xx...vt<<<== Mr[   c                   t        |t        j                        rM|r| j                  j	                  |      }n| j                  j                  |      }| j                  ||      S |S r   )r]   r^   r_   rQ   r   r   r   )rf   r  rX   r  r   rW   s         rY   _wrap_reduction_resultz&BaseMaskedArray._wrap_reduction_result  sS    fbjj)zz~~4~0zz~~4~0**6488r[   c                  t        j                  |t              }| j                  dk(  rdnd}|dv r|}n{|dv s| j                  j                  dk(  r!| j                  j
                  j                  }n=t               xs t         }|rdnd	}|rd
nd}	|||	|d| j                  j                     }t        j                  dg|      }
| j                  |
|      S )Nrn   Float32r  rA  )r  medianr  r  skewkurt)r  r}     int32int64uint32uint64)r   r   ur   r   r  )r^   rs   rt   r`   itemsizer  r  r   r   r   r;   r   )rf   r  r   r  rW   
float_dtypnp_dtypeis_windows_or_32bitint_dtyp	uint_dtypr   s              rY   r  zBaseMaskedArray._wrap_na_result  s    wwy-"&**	"9Yy
CC!H^#tzz':':a'?zz--22H"5"7"Ct8"5w7H$7XI%H9:V

H !H-&&u4&88r[   c                   |dk(  rOt        |t        j                        r5| j                  |t        j                  |j
                  t                    S | j                  ||||      S )Nr   rn   r  r   )r]   r^   r_   r   r  rc   rt   r  )rf   r  rX   r  	min_countr   s         rY    _wrap_min_count_reduction_resultz0BaseMaskedArray._wrap_min_count_reduction_result  sU     >j<**6288FLLPT3UVV**4T*RRr[   r  r  r   c                   t        j                  d|       t        j                  | j                  | j
                  |||      }| j                  d||||      S )Nr~   r  r  )r   validate_sumr6   r  rO   rQ   r  rf   r  r  r   r   rX   s         rY   r  zBaseMaskedArray.sum  s^     	F#"&&JJJJ
 446&ID 5 
 	
r[   c                   t        j                  d|       t        j                  | j                  | j
                  |||      }| j                  d||||      S )Nr~   r  r  )r   validate_prodr6   r  rO   rQ   r  r  s         rY   r  zBaseMaskedArray.prod  s`     	V$"''JJJJ
 44F6YT 5 
 	
r[   r  c                   t        j                  d|       t        j                  | j                  | j
                  ||      }| j                  d|||      S )Nr~   r  r  )r   validate_meanr6   r  rO   rQ   r  rf   r  r   r   rX   s        rY   r  zBaseMaskedArray.mean  sR    
V$"''JJJJ	
 **66&t*TTr[   r   r  r   ddofc                   t        j                  d|d       t        j                  | j                  | j
                  |||      }| j                  d|||      S )Nr~   r  fnamer  r  )r   validate_stat_ddof_funcr6   r  rO   rQ   r  rf   r  r   r  r   rX   s         rY   r  zBaseMaskedArray.var  Y     	""2vU;"&&JJJJ
 **5&d*SSr[   c                   t        j                  d|d       t        j                  | j                  | j
                  |||      }| j                  d|||      S )Nr~   r  r  r  r  )r   r  r6   r  rO   rQ   r  r  s         rY   r  zBaseMaskedArray.std  r  r[   c                   t        j                  d|       t        j                  | j                  | j
                  ||      }| j                  d|||      S )Nr~   r  r  )r   validate_minr6   r  rO   rQ   r  r  s        rY   r  zBaseMaskedArray.min%  P    
F#"&&JJJJ	
 **5&d*SSr[   c                   t        j                  d|       t        j                  | j                  | j
                  ||      }| j                  d|||      S )Nr~   r  r}  )r   validate_maxr6   r}  rO   rQ   r  r  s        rY   r}  zBaseMaskedArray.max/  r  r[   c                :    t        | j                         ||      S )N)	na_action)r2   r   )rf   mapperr  s      rY   mapzBaseMaskedArray.map9  s    &IFFr[   c               d   t        j                  d|       | j                  j                         }t	        j
                  || j                  | j                         |j                         }|r|S |s(t        |       dk(  s| j                  j                         s|S | j                  j                  S )aY  
        Return whether any element is truthy.

        Returns False unless there is at least one element that is truthy.
        By default, NAs are skipped. If ``skipna=False`` is specified and
        missing values are present, similar :ref:`Kleene logic <boolean.kleene>`
        is used as for logical operations.

        .. versionchanged:: 1.4.0

        Parameters
        ----------
        skipna : bool, default True
            Exclude NA values. If the entire array is NA and `skipna` is
            True, then the result will be False, as for an empty array.
            If `skipna` is False, the result will still be True if there is
            at least one element that is truthy, otherwise NA will be returned
            if there are NA's present.
        axis : int, optional, default 0
        **kwargs : any, default None
            Additional keywords have no effect but might be accepted for
            compatibility with NumPy.

        Returns
        -------
        bool or :attr:`pandas.NA`

        See Also
        --------
        numpy.any : Numpy version of this method.
        BaseMaskedArray.all : Return whether all elements are truthy.

        Examples
        --------
        The result indicates whether any element is truthy (and by default
        skips NAs):

        >>> pd.array([True, False, True]).any()
        True
        >>> pd.array([True, False, pd.NA]).any()
        True
        >>> pd.array([False, False, pd.NA]).any()
        False
        >>> pd.array([], dtype="boolean").any()
        False
        >>> pd.array([pd.NA], dtype="boolean").any()
        False
        >>> pd.array([pd.NA], dtype="Float64").any()
        False

        With ``skipna=False``, the result can be NA if this is logically
        required (whether ``pd.NA`` is True or False influences the result):

        >>> pd.array([True, False, pd.NA]).any(skipna=False)
        True
        >>> pd.array([1, 0, pd.NA]).any(skipna=False)
        True
        >>> pd.array([False, False, pd.NA]).any(skipna=False)
        <NA>
        >>> pd.array([0, 0, pd.NA]).any(skipna=False)
        <NA>
        r~   r   )r   validate_anyrO   re   r^   putmaskrQ   _falsey_valuer   r   r`   r   rf   r  r   r   rV   rX   s         rY   r   zBaseMaskedArray.any<  s    ~ 	F#" 	

64::t'9'9:MTatzz~~/?zz***r[   c               h   t        j                  d|       | j                  j                         }t	        j
                  || j                  | j                         |j                  |      }|r|S |r(t        |       dk(  s| j                  j                         s|S | j                  j                  S )aL  
        Return whether all elements are truthy.

        Returns True unless there is at least one element that is falsey.
        By default, NAs are skipped. If ``skipna=False`` is specified and
        missing values are present, similar :ref:`Kleene logic <boolean.kleene>`
        is used as for logical operations.

        .. versionchanged:: 1.4.0

        Parameters
        ----------
        skipna : bool, default True
            Exclude NA values. If the entire array is NA and `skipna` is
            True, then the result will be True, as for an empty array.
            If `skipna` is False, the result will still be False if there is
            at least one element that is falsey, otherwise NA will be returned
            if there are NA's present.
        axis : int, optional, default 0
        **kwargs : any, default None
            Additional keywords have no effect but might be accepted for
            compatibility with NumPy.

        Returns
        -------
        bool or :attr:`pandas.NA`

        See Also
        --------
        numpy.all : Numpy version of this method.
        BooleanArray.any : Return whether any element is truthy.

        Examples
        --------
        The result indicates whether all elements are truthy (and by default
        skips NAs):

        >>> pd.array([True, True, pd.NA]).all()
        True
        >>> pd.array([1, 1, pd.NA]).all()
        True
        >>> pd.array([True, False, pd.NA]).all()
        False
        >>> pd.array([], dtype="boolean").all()
        True
        >>> pd.array([pd.NA], dtype="boolean").all()
        True
        >>> pd.array([pd.NA], dtype="Float64").all()
        True

        With ``skipna=False``, the result can be NA if this is logically
        required (whether ``pd.NA`` is True or False influences the result):

        >>> pd.array([True, True, pd.NA]).all(skipna=False)
        <NA>
        >>> pd.array([1, 1, pd.NA]).all(skipna=False)
        <NA>
        >>> pd.array([True, False, pd.NA]).all(skipna=False)
        False
        >>> pd.array([1, 0, pd.NA]).all(skipna=False)
        False
        r~   r   r   )r   validate_allrO   re   r^   r  rQ   _truthy_valuer   r   r   r`   r   r  s         rY   r   zBaseMaskedArray.all  s    ~ 	F#" 	

64::t'9'9:&MSY!^4::>>3Czz***r[   c                  | j                   j                  dk(  rP|r5| j                  j                         }	| j                  j                         }
n| j                  }	| j                  }
nh| j                   j                  dv r8d}| j                  j                  d      }	| j                  j                         }
nt        d| j                          t        j                  |	f|d|||||
d| |s| S | j                   j                  dk(  rt        |       j                  |	|
      S ddlm}  |j                  |	|
      S )	z2
        See NDFrame.interpolate.__doc__.
        r   r  Tf8z)interpolate is not implemented for dtype=r   )r   r   r  r   limit_directionr   rW   rH   )r`   r   rO   re   rQ   r   ru   r
   interpolate_2d_inplacerq   rZ   r  rI   )rf   r   r   r  r   r  r   re   r   r   rW   rI   s               rY   interpolatezBaseMaskedArray.interpolate  s     ::??c!zz(zz(zzzzZZ__$D::$$T*D::??$D%;DJJ<H  	&&
	
+!
	
 
	
 K::??c!:))$558,=,,T488r[   )r  c                   | j                   }| j                  }t        t        |      } |||fd|i|\  }}| j	                  ||      S )Nr  )rO   rQ   r  r5   rZ   )rf   r  r  r   r   rW   rD  s          rY   _accumulatezBaseMaskedArray._accumulate  sP     zzzz)40d<6<V<
dd++r[   c          	     F   ddl m} |j                  |      } ||||      }	| j                  }
|	j                  dk7  r|
j                         }nt        j                  |t              }|dk(  r|j                  d      dv rd	|d d   |	j                  | j                  f||||
|d
|}|	j                  dk(  rH|	j                  j                  |	j                  d      }t        j                  ||df      j                  }|	j                  dv r|S | j!                  ||      S )Nr   )WrappedCythonOp)howr   has_dropped_na	aggregatern   rank	na_option)topbottomF)r  ngroupscomp_idsrW   result_maskohlcr   )idxminidxmax)pandas.core.groupby.opsr  get_kind_from_howrQ   r   re   r^   r  rt   r  _cython_op_ndim_compatrO   r  _cython_aritytiler   r   )rf   r  r  r  r  idsr   r  r   rD  rW   r  
res_valuesaritys                 rY   _groupby_opzBaseMaskedArray._groupby_op!  s    	<0054O zz77k!))+K((7$7K&=VZZ48II"KN.R..JJ
#
 

 66V$$((3E''+qz:<<K66)) **:{CCr[   )rV   rN   rW   rP   returnr   )F)rV   rN   rW   rP   re   rt   r  None)re   rt   r  r   )rc   r   r`   r    )ry   rt   r  zCallable[[Any], str | None])r  r'   )r   r   r  r   )r   r   r  r   )r   r   r  z
Self | Any)
r   r   r   
int | Noner   z#Literal['inside', 'outside'] | Nonere   rt   r  r   )NNNT)r   r  re   rt   r  r   )r`   r   re   rt   r  ztuple[np.ndarray, np.ndarray])r  r  )r  rt   )r  rA   )r  int)r  r   )r  r   )r   )r   r   r  r   )r   r  )r  rN   )r`   znpt.DTypeLike | Nonere   rt   r   r   r  rN   ).)r`   znpt.DTypeLikere   rt   r  rN   )r`   r    re   rt   r  r:   )r`   r   re   rt   r  r   )T)NN)r`   zNpDtype | Nonere   zbool | Noner  rN   )r#  znp.ufuncr   rx   rS   )rW   znpt.NDArray[np.bool_] | Noner  rP   )r  rE   )rX   z*np.ndarray | tuple[np.ndarray, np.ndarray]rW   rN   )rZ  zSequence[Self]r   r   r  r   )r]  rx   r^  rx   r_  rt   r  znpt.NDArray[np.uint64])rc  rt   rd  zScalar | Noner   r   r  r   )rV   r   r  rE   )r   )ro  zLiteral['first', 'last', False]r  rP   )r  N)r   z$NumpyValueArrayLike | ExtensionArrayrw  zLiteral['left', 'right']rx  zNumpySorter | Noner  znpt.NDArray[np.intp] | np.intp)r{  rt   r  z!tuple[np.ndarray, ExtensionArray])r  rt   r  rC   )r  rt   r  r   )r  znpt.NDArray[np.float64]r  rx   r  rL   )r  rx   r  rt   r  rt   )r  rx   )r  rt   r  r  r   AxisInt | None)r  rt   r   r  )r  rt   r   r  r  r  )r   r   r   r  re   rt   r  rI   )r  rx   r  rt   r  rL   )
r  rx   r  rt   r  r  r  r  r  znpt.NDArray[np.intp])[r;  
__module____qualname____doc____annotations__r   r  r  classmethodrZ   rg   rl   r   r:   rv   rz   propertyr`   r   r   r   r   rj   r   r   r   r   r   rc   r   r   r   r   r   r   r   r   r   r   r   r   r	   r  r   r   r   __array_priority__r	  r&  r*  r   r.  rH  _logical_methodrN  r   r*   r"  rW  r[  rb  r4   r1   re   rq  ru  ry  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r}  r  r   r   r  r  r  __classcell__)r   s   @rY   rL   rL   k   s    !    MM  MR (=EI	& .2 ! ! 			   	 ( (    
;  !:>* * 	*
 8* * 
*X 			NR.8GK	  B 6;'''/3'	&' '
P6"/       ,
,
,
& < <BF@@D
.
 '+>>	[#[ [ 	[
 
[z 			K  K      ,\  AE*#*2=*	* %$K'Z@    0	 [5z $O&6P-@-HR-^! # # 5 5  !  
	 *-;?	 !$( . 	 .
 " .  . 
 .H6(,
 		"	"#6=>3>	> $>	/ 		$	$% *0%)	H3H 'H #	H
 
(H &H  		!	!" !%"!"! 
+"! #"!H 		+	+, -&BP( 			P  P';)';:=';	';Z ,0%$(;?4	9&SS  
 
 	

 
0  
 
 	

 
* &*! U !%QATT,:TFIT !%QATT,:TFIT %) T %) TG %) O+b %) P+d29 #29 	29 29 
29j ,0	,	,$(	,		,-D -D 	-D
 -D -D "-Dr[   rL   c                   t        |       } | d   j                  }| D cg c]  }|j                  j                  dd        }}t	        j
                  |dt	        j                  t        |       t        | d         fd|j                              }| D cg c]  }|j                  j                  dd        }}t	        j
                  |dt	        j                  |t                    }|j                         }g }t        |j                  d         D ]+  }	 ||dd|	f   |dd|	f   	      }
|j                  |
       - |S c c}w c c}w )
zTranspose masked arrays in a list, but faster.

    Input should be a list of 1-dim masked arrays of equal length and all have the
    same dtype. The caller is responsible for ensuring validity of input data.
    r   r   r   F)orderr`   )r   r  rn   Nr  )listr`   rO   r   r^   rY  rp   r   r  rQ   
empty_likert   r  r   rc   r  )masked_arraysr`   r  rV   transposed_valuesmaskstransposed_masksarr_typetransposed_arraysr   transposed_arrs              rY   #transpose_homogeneous_masked_arraysr+  Q  sI    'M!""E2?@3cii2&@F@HH]1%5!67##
 2??#SYYq"%?E?~~A2==):$G ))+H/1$**1-. 1!"3AqD"9@PQRTUQU@VW  01 - A @s   #E#E)r$  zSequence[BaseMaskedArray]r  zlist[BaseMaskedArray])j
__future__r   typingr   r   r   r   r   r   numpyr^   pandas._libsr	   r
   r   pandas._libs.tslibsr   pandas._typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   pandas.compatr   r   pandas.errorsr   pandas.util._decoratorsr   pandas.util._validatorsr   pandas.core.dtypes.baser    pandas.core.dtypes.commonr!   r"   r#   r$   r%   r&   pandas.core.dtypes.dtypesr'   pandas.core.dtypes.missingr(   r)   r*   r+   pandas.corer,   rp  r-   r.   r/   pandas.core.algorithmsr0   r1   r2   r3   r4   pandas.core.array_algosr5   r6    pandas.core.array_algos.quantiler7   pandas.core.arrayliker8   pandas.core.arrays._utilsr9   pandas.core.arrays.baser:   pandas.core.constructionr;   r=  r<   r=   pandas.core.indexersr>   pandas.core.opsr?   pandas.core.util.hashingr@   collections.abcrA   rB   r  rC   r  rE   rF   rG   rI   pandas.compat.numpyrJ   r   rL   r+  r~   r[   rY   <module>rG     s    "    3     . ' : 2  6    @ * > 2 
 5 . / / 1 .cDh cDL/!,!!r[   