
    I jf4                    N   S SK Jr  S SKrS SKJrJrJrJ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  S S	KJr  S S
KJr  S SKJrJr  \(       a  S SKrS SKJrJ r J!r!  S SKJ"r"  \\" S5       " S S\5      5       5       r# S   SS jjr$\" S5       " S S\5      5       r%g)    )annotationsN)TYPE_CHECKINGClassVarSelfcast)libmissing)
set_module)is_list_like)register_extension_dtype)isna)ops)masked_accumulations)BaseMaskedArrayBaseMaskedDtype)DtypeObjnpttype_t)ExtensionDtypepandasc                      \ rS rSr% SrSrS\S'   Sr\SS j5       r	\SS j5       r
\SS	 j5       rSS
 jrSS jr\SS j5       r\SS j5       r    SS jrSrg)BooleanDtype*   a  
Extension dtype for boolean data.

This is a pandas Extension dtype for boolean data with support for
missing values. BooleanDtype is the dtype companion to :class:`.BooleanArray`,
which implements Kleene logic (sometimes called three-value logic) for
logical operations. See :ref:`boolean.kleene` for more.

.. warning::

    BooleanDtype is considered experimental. The implementation and
    parts of the API may change without warning.

Attributes
----------
None

Methods
-------
None

See Also
--------
arrays.BooleanArray : Array of boolean (True/False) data with missing values.
Int64Dtype : Extension dtype for int64 integer data.
StringDtype : Extension dtype for string data.

Examples
--------
>>> pd.BooleanDtype()
BooleanDtype

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

>>> pd.array([True, False, None], dtype="boolean")
<BooleanArray>
[True, False, <NA>]
Length: 3, dtype: boolean
booleanzClassVar[str]nameFc                "    [         R                  $ N)npbool_selfs    k/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/pandas/core/arrays/boolean.pytypeBooleanDtype.type_   s    xx    c                    g)Nb r    s    r"   kindBooleanDtype.kindc   s    r%   c                .    [         R                  " S5      $ )Nbool)r   dtyper    s    r"   numpy_dtypeBooleanDtype.numpy_dtypeg   s    xxr%   c                    [         $ )zI
Return the array type associated with this dtype.

Returns
-------
type
)BooleanArrayr    s    r"   construct_array_type!BooleanDtype.construct_array_typek   s
     r%   c                    g)Nr   r(   r    s    r"   __repr__BooleanDtype.__repr__u   s    r%   c                    gNTr(   r    s    r"   _is_booleanBooleanDtype._is_booleanx       r%   c                    gr8   r(   r    s    r"   _is_numericBooleanDtype._is_numeric|   r;   r%   c                    SSK nUR                  UR                  " 5       :w  aC  UR                  R	                  UR                  5      (       d  [        SUR                   S35      e[        XR                  5      (       a  U/n[        U5      nOUR                  nUR                  5       nUR                  R	                  UR                  5      (       a=  [        R                  " U[        S9n[        R                  " U[        S9n[        Xe5      $ / nU H  nUR!                  5       n	UR                  R#                  UR                  [        U5      SU	S   /UR$                  S9R'                  SS	9nUR(                  S:w  aO  UR                  R#                  UR                  [        U5      SU	S   /UR$                  S9R'                  SS	9nU) nO"[        R*                  " [        U5      [        S9n[        Xe5      n
UR-                  U
5        M     U(       dN  [        [        R.                  " / [        R                  S9[        R.                  " / [        R                  S95      $ [        R1                  U5      $ )
z9
Construct BooleanArray from pyarrow Array/ChunkedArray.
r   Nz$Expected array of boolean type, got z insteadr-      )offsetF)zero_copy_only)pyarrowr#   r   typesis_null	TypeError
isinstanceArraylenchunkslengthr   onesr,   emptyr1   buffersfrom_buffersrB   to_numpy
null_countzerosappendarray_concat_same_type)r!   rU   rD   rK   rL   maskdataresultsarrbuflistbool_arrs              r"   __from_arrow__BooleanDtype.__from_arrow__   s    	::(1F1Fuzz1R1RB5::,hWXXe]]++WFZF \\F\\^F==  ,,776.D88F$/D++CkkmG''44#c(T71:$6szz 5 heh,  ~~"++88HHc#hwqz(:3:: 9 (%(0  uxxC5#D/HNN8$   288,bhhr.J   11'::r%   r(   N)returnr#   )r_   str)r_   znp.dtype)r_   ztype_t[BooleanArray])r_   r,   )rU   z$pyarrow.Array | pyarrow.ChunkedArrayr_   r1   )__name__
__module____qualname____firstlineno____doc__r   __annotations___internal_fill_valuepropertyr#   r)   r.   r2   r5   r9   r=   r]   __static_attributes__r(   r%   r"   r   r   *   s    )V $D-# !            /;9/;	/;r%   r   c                   [        U [        5      (       aO  Ub  [        S5      eU R                  U R                  pU(       a   U R                  5       n UR                  5       nX4$ Sn[        U [        R                  5      (       a7  U R                  [        R                  :X  a  U(       a  U R                  5       n GO[        U [        R                  5      (       a  U R                  R                  S;   a  [        U 5      n[        R                  " [        U 5      [        S9nX)    R                  [        5      XC) '   [        R                   " XC)    R                  U R                  5      X)    :H  5      (       d  [#        S5      eUn O[        R$                  " U [&        S9n[(        R*                  " USS9nSnUS	S
/UQ7;  a  [#        S5      e[-        S[        U5      5      n[        R                  " [        U 5      [        S9n XS)    R                  [        5      X) '   Xg;   aU  [        R                   " X)    R                  [.        5      XS)    R                  [.        5      :H  5      (       d  [#        S5      eUc'  Uc$  [        R                  " U R0                  [        S9nOUc  UnO}[        U[        R                  5      (       a>  UR                  [        R                  :X  a   Ub  X-  nO8U(       a  UR                  5       nO [        R2                  " U[        S9nUb  X-  nU R0                  UR0                  :w  a  [        S5      eX4$ )z
Coerce the input values array to numpy arrays with a mask.

Parameters
----------
values : 1D list-like
mask : bool 1D array, optional
copy : bool, default False
    if True, copy the input

Returns
-------
tuple of (values, mask)
Nz'cannot pass mask for BooleanArray inputiufcbr@   zNeed to pass bool-like valuesTskipna)floatingintegerzmixed-integer-floatr   rN   npt.NDArray[np.bool_]z&values.shape and mask.shape must match)rH   r1   
ValueError_data_maskcopyr   ndarrayr-   r   r)   r   rS   rJ   r,   astypeallrG   asarrayobjectr   infer_dtyper   floatshaperU   )valuesrW   rt   mask_valuesvalues_boolvalues_objectinferred_dtypeinteger_likes           r"   coerce_to_arrayr      s   " &,''FGG||V\\[[]F99;D|K&"**%%&,,"((*B[[]F	FBJJ	'	'FLL,=,=,H6lhhs6{$7$*<$8$?$?$EL!vv%,,V\\:f\>RR
 
 ;<<

68tDE)W!D|!DD;<< 2D4GH#f+T2,\:AA$G| *FF|$++E2 .55e<= 
 ;<<|+xxD1		D"**	%	%$***@"%D99;DxxD)"%D||tzz!ABB<r%   zpandas.arraysc                  N  ^  \ rS rSrSr1 Skr1 Skr\SU 4S jj5       r S       SU 4S jjjr	\
SS j5       r\SS	S	S	S
.             SS jj5       r\R                  \R                   \\R$                  4r\SS.     SS jj5       rS rSS.     SS jjrSrU =r$ )r1   i  a  
Array of boolean (True/False) data with missing values.

This is a pandas Extension array for boolean data, under the hood
represented by 2 numpy arrays: a boolean array with the data and
a boolean array with the mask (True indicating missing).

BooleanArray implements Kleene logic (sometimes called three-value
logic) for logical operations. See :ref:`boolean.kleene` for more.

To construct a BooleanArray from generic array-like input, use
:func:`pandas.array` specifying ``dtype="boolean"`` (see examples
below).

.. warning::

   BooleanArray is considered experimental. The implementation and
   parts of the API may change without warning.

Parameters
----------
values : numpy.ndarray
    A 1-d boolean-dtype array with the data.
mask : numpy.ndarray
    A 1-d boolean-dtype array indicating missing values (True
    indicates missing).
copy : bool, default False
    Whether to copy the `values` and `mask` arrays.

Attributes
----------
None

Methods
-------
None

Returns
-------
BooleanArray

See Also
--------
array : Create an array from data with the appropriate dtype.
BooleanDtype : Extension dtype for boolean data.
Series : One-dimensional ndarray with axis labels (including time series).
DataFrame : Two-dimensional, size-mutable, potentially heterogeneous tabular data.

Examples
--------
Create a BooleanArray with :func:`pandas.array`:

>>> pd.array([True, False, None], dtype="boolean")
<BooleanArray>
[True, False, <NA>]
Length: 3, dtype: boolean
>   1TRUETruetrue1.0>   0FALSEFalsefalse0.0c                D   > [         TU ]  X5      n[        5       Ul        U$ r   )super_simple_newr   _dtype)clsr}   rW   result	__class__s       r"   r   BooleanArray._simple_newF  s     $V2$r%   Fc                   > [        U[        R                  5      (       a  UR                  [        R                  :X  d  [        S5      e[        5       U l        [        TU ]%  XUS9  g )NzIvalues should be boolean numpy array. Use the 'pd.array' function insteadrt   )
rH   r   ru   r-   r   rG   r   r   r   __init__)r!   r}   rW   rt   r   s       r"   r   BooleanArray.__init__L  sT     62::..6<<2883K2  #nD1r%   c                    U R                   $ r   r   r    s    r"   r-   BooleanArray.dtypeW  s    {{r%   N)rt   true_valuesfalse_valuesnone_valuesc               T  ^^
^ U R                   R                  U=(       d    / 5      mU R                  R                  U=(       d    / 5      m
Tc  / mSU
UU4S jjn[        R                  " U[
        S9n[        U5      n	[        [        XxU	)    5      5      X) '   U R                  XUS9$ )Nc                J   > U T;   a  gU T;   a  gU T;   a  g [        U  S35      e)NTFz cannot be cast to bool)rq   )sfalse_values_unionr   true_values_unions    r"   
map_string:BooleanArray._from_sequence_of_strings.<locals>.map_stringl  s9    %%((k! A3&=!>??r%   r@   )r-   rt   )r_   zbool | None)
_TRUE_VALUESunion_FALSE_VALUESr   rU   ry   r   listmap_from_sequence)r   stringsr-   rt   r   r   r   r   scalarsrW   r   r   s         `   @@r"   _from_sequence_of_strings&BooleanArray._from_sequence_of_strings[  s      ,,22;3D"E ..44\5GRHK	@ 	@ ((7&1G}c*ten=>!!'T!BBr%   r   c               2    U(       a  US:X  d   e[        XS9$ )Nr   r   )r   )r   valuer-   rt   s       r"   _coerce_to_arrayBooleanArray._coerce_to_array}  s      I%%%u00r%   c                   UR                   S;   d   e[        R                  " U5      nS n[        U[        5      (       a  UR
                  UR                  pAOw[        U5      (       a8  [        R                  " USS9nUR                  S:  a  [        $ [        USS9u  pO/[        U[        R                  5      (       a  UR                  5       nU(       aP  U[        R                   La=  [        R"                  " U5      (       d"  [%        S['        U5      R                    S35      eU(       d#  [)        U 5      [)        U5      :w  a  [+        S	5      eUR                   S
;   a/  [,        R.                  " U R
                  XR                  U5      u  pTOmUR                   S;   a/  [,        R0                  " U R
                  XR                  U5      u  pTO.[,        R2                  " U R
                  XR                  U5      u  pTU R5                  XT5      $ )N>   or_xorand_ror_rxorrand_r,   r@   rA   Fr   z+'other' should be pandas.NA or a bool. Got z	 instead.zLengths must match>   r   r   >   r   r   )ra   r   	is_scalarrH   r1   rr   rs   r   r   rx   ndimNotImplementedr   r   item
libmissingNAis_boolrG   r#   rJ   rq   r   	kleene_or
kleene_and
kleene_xor_maybe_mask_result)r!   otheropother_is_scalarrW   r   s         r"   _logical_methodBooleanArray._logical_method  s   {{MMMM--.e\**++u{{4%  JJuF3EzzA~%%)%e<KE4rxx((JJLEuJMM9#++eBTBTE{++,I7 
 3t9E
#:122;;/)==UJJMLFD[[-->>$**eZZNLFD >>$**eZZNLF &&v44r%   Trl   c                  U R                   nU R                  nUS;   a.  [        [        U5      nU" XE4SU0UD6u  pEU R	                  XE5      $ SSKJn  U" UR                  [        5      U5      R                  " U4SU0UD6$ )N)cummincummaxrm   r   )IntegerArray)
rr   rs   getattrr   r   pandas.core.arraysr   rv   int_accumulate)r!   r   rm   kwargsrX   rW   r   r   s           r"   r   BooleanArray._accumulate  s     zzzz''-t4BD@v@@JD##D//7C 0$7CC#'- r%   r   )r}   
np.ndarrayrW   rp   r_   r   )F)r}   r   rW   r   rt   r,   r_   None)r_   r   )r   z	list[str]r-   r   rt   r,   r   list[str] | Noner   r   r   r   r_   r1   )r-   r   rt   r,   r_   tuple[np.ndarray, np.ndarray])r   r`   rm   r,   r_   r   )ra   rb   rc   rd   re   r   r   classmethodr   r   rh   r-   r   r   ru   numbersNumberr,   r   _HANDLED_TYPESr   r   r   ri   __classcell__)r   s   @r"   r1   r1     sQ   8t 8L;M  BG	2 	2(2	2:>	2		2 	2    (,)-(,CC 	C
 C &C 'C &C 
C C> jj'..$AN5:1&1.21	&1 1!5H ,0$(	 r%   r1   )NF)rt   r,   r_   r   )&
__future__r   r   typingr   r   r   r   numpyr   pandas._libsr   r	   r   pandas.util._decoratorsr
   pandas.core.dtypes.commonr   pandas.core.dtypes.dtypesr   pandas.core.dtypes.missingr   pandas.corer   pandas.core.array_algosr   pandas.core.arrays.maskedr   r   rD   pandas._typingr   r   r   r   r   r   r1   r(   r%   r"   <module>r      s    "    / 2 > +  8
   9 HC;? C;  C;N %*R!R"Rj On? n nr%   