§
    �’j6  ã                  óf  — d dl mZ d dlZd dlmZmZmZmZ d dl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 d d
lmZ d dlmZmZ erd dlZd dlmZm Z m!Z! d dlm"Z" e ed¦  «         G d„ de¦  «        ¦   «         ¦   «         Z#	 ddd„Z$ ed¦  «         G d„ de¦  «        ¦   «         Z%dS )é    )Ú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                  ó¶   — e Zd ZU dZdZded<   dZedd„¦   «         Zedd
„¦   «         Z	edd„¦   «         Z
dd„Zdd„Zedd„¦   «         Zedd„¦   «         Zdd„ZdS )ÚBooleanDtypeaP  
    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]ÚnameFÚreturnÚtypec                ó   — t           j        S ©N)ÚnpÚbool_©Úselfs    úHC:\Projects\DSCons\.venv\Lib\site-packages\pandas\core\arrays\boolean.pyr   zBooleanDtype.type_   s	   € åŒxˆó    Ústrc                ó   — dS )NÚb© r!   s    r#   ÚkindzBooleanDtype.kindc   s   € àˆsr$   únp.dtypec                ó*   — t          j        d¦  «        S )NÚbool)r   Údtyper!   s    r#   Únumpy_dtypezBooleanDtype.numpy_dtypeg   s   € åŒx˜ÑÔÐr$   útype_t[BooleanArray]c                ó   — t           S )zq
        Return the array type associated with this dtype.

        Returns
        -------
        type
        )ÚBooleanArrayr!   s    r#   Úconstruct_array_typez!BooleanDtype.construct_array_typek   s
   € õ Ðr$   c                ó   — dS )Nr   r(   r!   s    r#   Ú__repr__zBooleanDtype.__repr__u   s   € Øˆ~r$   r,   c                ó   — dS ©NTr(   r!   s    r#   Ú_is_booleanzBooleanDtype._is_booleanx   ó   € àˆtr$   c                ó   — dS r6   r(   r!   s    r#   Ú_is_numericzBooleanDtype._is_numeric|   r8   r$   Úarrayú$pyarrow.Array | pyarrow.ChunkedArrayr1   c                óþ  — ddl }|j         |j        ¦   «         k    r7|j                             |j        ¦  «        st          d|j        › d�¦  «        ‚t          ||j        ¦  «        r|g}t          |¦  «        }n|j	        }| 
                    ¦   «         }|j                             |j        ¦  «        rFt          j        |t          ¬¦  «        }t          j        |t          ¬¦  «        }t          ||¦  «        S g }|D �]}|                     ¦   «         }	|j                             |j        t          |¦  «        d|	d         g|j        ¬¦  «                             d¬	¦  «        }|j        dk    rU|j                             |j        t          |¦  «        d|	d         g|j        ¬¦  «                             d¬	¦  «        }| }n(t          j        t          |¦  «        t          ¬¦  «        }t          ||¦  «        }
|                     |
¦  «         �Œ|sLt          t          j        g t          j        ¬¦  «        t          j        g t          j        ¬¦  «        ¦  «        S t                               |¦  «        S )
zI
        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_buffersr@   Úto_numpyÚ
null_countÚzerosÚappendr;   Ú_concat_same_type)r"   r;   rB   rI   rJ   ÚmaskÚdataÚresultsÚarrÚbuflistÚbool_arrs              r#   Ú__from_arrow__zBooleanDtype.__from_arrow__€   sK  € ð 	ˆˆˆàŒ:˜˜œ™œÒ(Ð(°´×1FÒ1FÀuÄzÑ1RÔ1RÐ(ÝÐWÀ5Ä:ÐWÐWÐWÑXÔXÐXå�e˜Wœ]Ñ+Ô+ð 	$Ø�WˆFÝ˜‘Z”ZˆFˆFð ”\ˆFØ—\’\‘^”^ˆFàŒ=× Ò  ¤Ñ,Ô,ð 	,Ý”7˜6­Ð.Ñ.Ô.ˆDå”8˜F­$Ð/Ñ/Ô/ˆDÝ  dÑ+Ô+Ð+àˆØð 	%ñ 	%ˆCØ—k’k‘m”mˆGØÔ'×4Ò4Ø”�#˜c™(œ( T¨7°1¬:Ð$6¸s¼zð 5ñ ô çŠh eˆhÑ,Ô,ð ð Œ~ Ò"Ð"ØÔ+×8Ò8Ø”H�c #™hœh¨¨w°q¬zÐ(:À3Ä:ð 9ñ ô ç’(¨%�(Ñ0Ô0ð ð �u��å”x¥ C¡¤µÐ5Ñ5Ô5�å# D¨$Ñ/Ô/ˆHØ�NŠN˜8Ñ$Ô$Ð$Ñ$àð 	;ÝÝ”˜¥2¤8Ð,Ñ,Ô,­b¬h°rÅÄÐ.JÑ.JÔ.Jñô ð õ  ×1Ò1°'Ñ:Ô:Ð:r$   N)r   r   )r   r%   )r   r*   )r   r/   )r   r,   )r;   r<   r   r1   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__Ú_internal_fill_valueÚpropertyr   r)   r.   r2   r4   r7   r:   rZ   r(   r$   r#   r   r   *   s  € € € € € € ð)ð )ðV $€DÐ#Ð#Ð#Ñ#ð !Ðð ðð ð ñ „Xðð ðð ð ñ „Xðð ð ð  ð  ñ „Xð ðð ð ð ðð ð ð ð ðð ð ñ „Xðð ðð ð ñ „Xðð/;ð /;ð /;ð /;ð /;ð /;r$   r   FÚcopyr,   r   útuple[np.ndarray, np.ndarray]c                ó¸  — t          | t          ¦  «        rM|�t          d¦  «        ‚| j        | j        }} |r(|                      ¦   «         } |                     ¦   «         }| |fS d}t          | t          j        ¦  «        r-| j        t          j	        k    r|r|                      ¦   «         } �nót          | t          j        ¦  «        r»| j        j
        dv r­t          | ¦  «        }t          j        t          | ¦  «        t          ¬¦  «        }| |                               t          ¦  «        || <   t          j        ||                               | j        ¦  «        | |          k    ¦  «        st#          d¦  «        ‚|} �nt          j        | t&          ¬¦  «        }t)          j        |d¬¦  «        }d}|d	d
g|¢R vrt#          d¦  «        ‚t-          dt          |¦  «        ¦  «        }t          j        t          | ¦  «        t          ¬¦  «        } ||                               t          ¦  «        | | <   ||v ret          j        | |                               t.          ¦  «        ||                               t.          ¦  «        k    ¦  «        st#          d¦  «        ‚|€#|€!t          j        | j        t          ¬¦  «        }nu|€|}npt          |t          j        ¦  «        r4|j        t          j	        k    r|�||z  }n9|r|                     ¦   «         }n"t          j        |t          ¬¦  «        }|�||z  }| j        |j        k    rt          d¦  «        ‚| |fS )a  
    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   rL   únpt.NDArray[np.bool_]z&values.shape and mask.shape must match)rF   r1   Ú
ValueErrorÚ_dataÚ_maskrb   r   Úndarrayr-   r    r)   r   rQ   rH   r,   ÚastypeÚallrE   ÚasarrayÚobjectr   Úinfer_dtyper   ÚfloatÚshaper;   )ÚvaluesrT   rb   Úmask_valuesÚvalues_boolÚvalues_objectÚinferred_dtypeÚinteger_likes           r#   Úcoerce_to_arrayr|   ²   s0  € õ" �&�,Ñ'Ô'ð ØÐÝÐFÑGÔGÐGØ”| V¤\�ˆØð 	Ø—[’[‘]”]ˆFØ—9’9‘;”;ˆDØ�tˆ|Ðà€KÝ�&�"œ*Ñ%Ô%ð $=¨&¬,½"¼(Ò*BÐ*BØð 	#Ø—[’[‘]”]ˆFùÝ	�F�BœJÑ	'Ô	'ð !=¨F¬LÔ,=ÀÐ,HÐ,HÝ˜6‘l”lˆå”h�s 6™{œ{µ$Ð7Ñ7Ô7ˆØ$*¨K¨<Ô$8×$?Ò$?ÅÑ$EÔ$Eˆ�[�LÑ!åŒvØ˜˜Ô%×,Ò,¨V¬\Ñ:Ô:¸fÀkÀ\Ô>RÒRñ
ô 
ð 	=õ Ð;Ñ<Ô<Ð<àˆ‰åœ
 6µÐ8Ñ8Ô8ˆåœ¨¸tÐDÑDÔDˆØEˆØ )¨WÐ!D°|Ð!DÐ!DÐDÐDÝÐ;Ñ<Ô<Ð<õ Ð2µD¸Ñ4GÔ4GÑHÔHˆÝ”�#˜f™+œ+­TÐ2Ñ2Ô2ˆØ,¨k¨\Ô:×AÒAÅ$ÑGÔGˆ�ˆ|Ñð ˜lÐ*Ð*ÝŒFØ˜�|Ô$×+Ò+­EÑ2Ô2Ø  + Ô.×5Ò5µeÑ<Ô<ò=ñô ð +õ Ð;Ñ<Ô<Ð<à€|˜Ð+ÝŒx˜œ­DÐ1Ñ1Ô1ˆˆØ	ˆØˆˆÝ	�D�"œ*Ñ	%Ô	%ð &¨$¬*½¼Ò*@Ð*@ØÐ"Ø˜+Ñ%ˆDˆDØð 	Ø—9’9‘;”;ˆDøåŒx˜¥DÐ)Ñ)Ô)ˆØÐ"Ø˜+Ñ%ˆDà„|�t”zÒ!Ð!ÝÐAÑBÔBÐBà�4ˆ<Ðr$   zpandas.arraysc                  óì   ‡ — e Zd ZdZh d£Zh d£Zed)ˆ fd
„¦   «         Z	 d*d+ˆ fd„Ze	d,d„¦   «         Z
edddddœd-d„¦   «         Zej        ej        eej        fZeddœd.d „¦   «         Zd!„ Zd"d#œd/d(„Zˆ xZS )0r1   as  
    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.0Ú1ÚTRUEÚTrueÚtrue>   ú0.0Ú0ÚFALSEÚFalseÚfalserv   ú
np.ndarrayrT   rj   r   r   c                ór   •— t          ¦   «                              ||¦  «        }t          ¦   «         |_        |S r   )ÚsuperÚ_simple_newr   Ú_dtype)Úclsrv   rT   ÚresultÚ	__class__s       €r#   r‹   zBooleanArray._simple_newF  s,   ø€ å‘”×$Ò$ V¨TÑ2Ô2ˆÝ$™œˆŒØˆr$   Frb   r,   ÚNonec                óò   •— t          |t          j        ¦  «        r|j        t          j        k    st          d¦  «        ‚t          ¦   «         | _        t          ¦   «          	                    |||¬¦  «         d S )NzIvalues should be boolean numpy array. Use the 'pd.array' function instead©rb   )
rF   r   rn   r-   r    rE   r   rŒ   rŠ   Ú__init__)r"   rv   rT   rb   r�   s       €r#   r“   zBooleanArray.__init__L  sp   ø€ õ ˜6¥2¤:Ñ.Ô.ð 	°6´<Å2Ä8Ò3KÐ3KÝð2ñô ð õ #‘n”nˆŒÝ‰Œ×Ò˜ ¨DÐÑ1Ô1Ð1Ð1Ð1r$   r   c                ó   — | j         S r   )rŒ   r!   s    r#   r-   zBooleanArray.dtypeW  s
   € àŒ{Ðr$   N)rb   Útrue_valuesÚfalse_valuesÚnone_valuesÚstringsú	list[str]r-   r   r•   úlist[str] | Noner–   r—   c               ód  ‡‡
‡— | j                              |pg ¦  «        Š| j                             |pg ¦  «        Š
‰€g Šdˆ
ˆˆfd„}t          j        |t
          ¬¦  «        }t          |¦  «        }	t          t          |||	          ¦  «        ¦  «        ||	 <   |  	                    |||¬¦  «        S )Nr   úbool | Nonec                óL   •— | ‰v rdS | ‰v rdS | ‰v rd S t          | › d�¦  «        ‚)NTFz cannot be cast to bool)rk   )ÚsÚfalse_values_unionr—   Útrue_values_unions    €€€r#   Ú
map_stringz:BooleanArray._from_sequence_of_strings.<locals>.map_stringl  sL   ø€ ØÐ%Ð%Ð%Ø�tØÐ(Ð(Ð(Ø�uØ�kÐ!Ð!Ø�tå  AÐ!>Ð!>Ð!>Ñ?Ô?Ð?r$   r>   )r-   rb   )r   rœ   )
Ú_TRUE_VALUESÚunionÚ_FALSE_VALUESr   r;   rr   r   ÚlistÚmapÚ_from_sequence)r�   r˜   r-   rb   r•   r–   r—   r¡   ÚscalarsrT   rŸ   r    s         `   @@r#   Ú_from_sequence_of_stringsz&BooleanArray._from_sequence_of_strings[  sÙ   øøø€ ð  Ô,×2Ò2°;Ð3DÀ"ÑEÔEÐØ Ô.×4Ò4°\Ð5GÀRÑHÔHÐàÐØˆKð	@ð 	@ð 	@ð 	@ð 	@ð 	@ð 	@ð 	@õ ”(˜7­&Ð1Ñ1Ô1ˆÝ�G‰}Œ}ˆÝ�c *¨g°t°e¬nÑ=Ô=Ñ>Ô>ˆ��‰Ø×!Ò! '°¸TÐ!ÑBÔBÐBr$   r’   r   rc   c               ó8   — |r|dk    sJ ‚t          ||¬¦  «        S )Nr   r’   )r|   )r�   Úvaluer-   rb   s       r#   Ú_coerce_to_arrayzBooleanArray._coerce_to_array}  s0   € ð ð 	&Ø˜IÒ%Ð%Ð%Ð%Ý˜u¨4Ð0Ñ0Ô0Ð0r$   c                ó   — |j         dv sJ ‚t          j        |¦  «        }d }t          |t          ¦  «        r|j        |j        }}nzt          |¦  «        r=t          j	        |d¬¦  «        }|j
        dk    rt          S t          |d¬¦  «        \  }}n.t          |t          j        ¦  «        r|                     ¦   «         }|rG|t          j        ur9t          j        |¦  «        s%t%          dt'          |¦  «        j         › d�¦  «        ‚|s/t)          | ¦  «        t)          |¦  «        k    rt+          d	¦  «        ‚|j         d
v r%t-          j        | j        || j        |¦  «        \  }}nR|j         dv r%t-          j        | j        || j        |¦  «        \  }}n$t-          j        | j        || j        |¦  «        \  }}|                      ||¦  «        S )N>   Úor_ÚxorÚand_Úror_ÚrxorÚrand_r,   r>   r?   Fr’   z+'other' should be pandas.NA or a bool. Got z	 instead.zLengths must match>   r®   r±   >   r°   r³   )r[   r   Ú	is_scalarrF   r1   rl   rm   r   r   rq   ÚndimÚNotImplementedr|   r    ÚitemÚ
libmissingÚNAÚis_boolrE   r   rH   rk   r   Ú	kleene_orÚ
kleene_andÚ
kleene_xorÚ_maybe_mask_result)r"   ÚotherÚopÚother_is_scalarrT   rŽ   s         r#   Ú_logical_methodzBooleanArray._logical_method…  sÍ  € ØŒ{ÐMÐMÐMÐMÐMÝœ-¨Ñ.Ô.ˆØˆå�e�\Ñ*Ô*ð 	!Øœ+ u¤{�4ˆEˆEÝ˜%Ñ Ô ð 	!Ý”J˜u¨FÐ3Ñ3Ô3ˆEØŒz˜AŠ~ˆ~Ý%Ð%Ý)¨%°eÐ<Ñ<Ô<‰KˆE�4�4Ý˜�rœxÑ(Ô(ð 	!Ø—J’J‘L”LˆEàð 	˜u­J¬MÐ9Ð9Å#Ä+ÈeÑBTÔBTÐ9Ýð7Ý˜E‘{”{Ô+ð7ð 7ð 7ñô ð ð
 ð 	3¥3 t¡9¤9µ°E±
´
Ò#:Ð#:ÝÐ1Ñ2Ô2Ð2àŒ;˜/Ð)Ð)Ýœ=¨¬°U¸D¼JÈÑMÔM‰LˆF�D�DØŒ[Ð-Ð-Ð-Ýœ>¨$¬*°e¸T¼ZÈÑNÔN‰LˆF�D�Dõ œ>¨$¬*°e¸T¼ZÈÑNÔN‰LˆF�Dð ×&Ò& v¨tÑ4Ô4Ð4r$   Trf   r   r%   rg   r   c               ó
  — | j         }| j        }|dv r:t          t          |¦  «        } |||fd|i|¤Ž\  }}|                      ||¦  «        S ddlm}   ||                     t          ¦  «        |¦  «        j	        |fd|i|¤ŽS )N)ÚcumminÚcummaxrg   r   )ÚIntegerArray)
rl   rm   Úgetattrr   r‹   Úpandas.core.arraysrÆ   ro   ÚintÚ_accumulate)r"   r   rg   ÚkwargsrU   rT   rÀ   rÆ   s           r#   rÊ   zBooleanArray._accumulate¨  s¿   € ð ŒzˆØŒzˆØÐ'Ð'Ð'ÝÕ-¨tÑ4Ô4ˆBØ˜˜D $Ð@Ð@¨vÐ@¸Ð@Ð@‰JˆD�$Ø×#Ò# D¨$Ñ/Ô/Ð/à7Ð7Ð7Ð7Ð7Ð7àC�<�< §¢­CÑ 0Ô 0°$Ñ7Ô7ÔCØðð Ø#ðØ'-ðð ð r$   )rv   rˆ   rT   rj   r   r   )F)rv   rˆ   rT   rˆ   rb   r,   r   r�   )r   r   )r˜   r™   r-   r   rb   r,   r•   rš   r–   rš   r—   rš   r   r1   )r-   r   rb   r,   r   rc   )r   r%   rg   r,   r   r   )r[   r\   r]   r^   r¢   r¤   Úclassmethodr‹   r“   ra   r-   r©   r   rn   ÚnumbersÚNumberr,   r    Ú_HANDLED_TYPESr¬   rÂ   rÊ   Ú__classcell__)r�   s   @r#   r1   r1     sf  ø€ € € € € ð8ð 8ðt 8Ð7Ð7€LØ;Ð;Ð;€Màðð ð ð ð ñ „[ðð BGð	2ð 	2ð 	2ð 	2ð 	2ð 	2ð 	2ð ðð ð ñ „Xðð ð Ø(,Ø)-Ø(,ðCð Cð Cð Cð Cñ „[ðCð> ”j '¤.°$¸¼ÐA€Nàà5:ð1ð 1ð 1ð 1ð 1ñ „[ð1ð!5ð !5ð !5ðH ,0ðð ð ð ð ð ð ð ð ð r$   r1   )NF)rb   r,   r   rc   )&Ú
__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   rB   Úpandas._typingr   r   r   r   r   r|   r1   r(   r$   r#   ú<module>rÝ      sO  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€ðð ð ð ð ð ð ð ð ð ð ð ð Ð Ð Ð ðð ð ð ð ð ð ð ð /Ð .Ð .Ð .Ð .Ð .à 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø >Ð >Ð >Ð >Ð >Ð >Ø +Ð +Ð +Ð +Ð +Ð +à Ð Ð Ð Ð Ð Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8ðð ð ð ð ð ð ð ð
 ð 	9Ø€N€N€Nðð ð ð ð ð ð ð ð ð ð 9Ð8Ð8Ð8Ð8Ð8ð Ø€ˆHÑÔðC;ð C;ð C;ð C;ð C;�?ñ C;ô C;ñ Ôñ ÔðC;ðN %*ðRð Rð Rð Rð Rðj €ˆOÑÔðnð nð nð nð n�?ñ nô nñ Ôðnð nð nr$   