a
    é´«j÷D  ã                   @  sô   d Z ddlmZ ddlZddlmZ ddl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dddœZG dd„ dƒZdddddœdd„Zddœdd„Zdddœdd„Zddœd d!„Zdddœd"d#„Zdddœd$d%„ZdS )&zn
Methods that can be shared by many array-like classes or subclasses:
    Series
    Index
    ExtensionArray
é    )ÚannotationsN)ÚAny)Úlib)Ú!maybe_dispatch_ufunc_to_dunder_op)Ú
ABCNDFrame)Ú	roperator©Úextract_array)Úunpack_zerodim_and_deferÚmaxÚminÚsumÚprod)ÚmaximumÚminimumÚaddÚmultiplyc                   @  sä  e Zd Zdd„ Zedƒdd„ ƒZedƒdd„ ƒZed	ƒd
d„ ƒZedƒdd„ ƒZedƒdd„ ƒZ	edƒdd„ ƒZ
dd„ Zedƒdd„ ƒZedƒdd„ ƒZedƒdd„ ƒZed ƒd!d"„ ƒZed#ƒd$d%„ ƒZed&ƒd'd(„ ƒZd)d*„ Zed+ƒd,d-„ ƒZed.ƒd/d0„ ƒZed1ƒd2d3„ ƒZed4ƒd5d6„ ƒZed7ƒd8d9„ ƒZed:ƒd;d<„ ƒZed=ƒd>d?„ ƒZed@ƒdAdB„ ƒZedCƒdDdE„ ƒZedFƒdGdH„ ƒZedIƒdJdK„ ƒZedLƒdMdN„ ƒZedOƒdPdQ„ ƒZedRƒdSdT„ ƒZ edUƒdVdW„ ƒZ!edXƒdYdZ„ ƒZ"d[S )\ÚOpsMixinc                 C  s   t S ©N©ÚNotImplemented©ÚselfÚotherÚop© r   úT/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/pandas/core/arraylike.pyÚ_cmp_method#   s    zOpsMixin._cmp_methodÚ__eq__c                 C  s   |   |tj¡S r   )r   ÚoperatorÚeq©r   r   r   r   r   r   &   s    zOpsMixin.__eq__Ú__ne__c                 C  s   |   |tj¡S r   )r   r   Úner!   r   r   r   r"   *   s    zOpsMixin.__ne__Ú__lt__c                 C  s   |   |tj¡S r   )r   r   Últr!   r   r   r   r$   .   s    zOpsMixin.__lt__Ú__le__c                 C  s   |   |tj¡S r   )r   r   Úler!   r   r   r   r&   2   s    zOpsMixin.__le__Ú__gt__c                 C  s   |   |tj¡S r   )r   r   Úgtr!   r   r   r   r(   6   s    zOpsMixin.__gt__Ú__ge__c                 C  s   |   |tj¡S r   )r   r   Úger!   r   r   r   r*   :   s    zOpsMixin.__ge__c                 C  s   t S r   r   r   r   r   r   Ú_logical_methodA   s    zOpsMixin._logical_methodÚ__and__c                 C  s   |   |tj¡S r   )r,   r   Úand_r!   r   r   r   r-   D   s    zOpsMixin.__and__Ú__rand__c                 C  s   |   |tj¡S r   )r,   r   Zrand_r!   r   r   r   r/   H   s    zOpsMixin.__rand__Ú__or__c                 C  s   |   |tj¡S r   )r,   r   Úor_r!   r   r   r   r0   L   s    zOpsMixin.__or__Ú__ror__c                 C  s   |   |tj¡S r   )r,   r   Zror_r!   r   r   r   r2   P   s    zOpsMixin.__ror__Ú__xor__c                 C  s   |   |tj¡S r   )r,   r   Úxorr!   r   r   r   r3   T   s    zOpsMixin.__xor__Ú__rxor__c                 C  s   |   |tj¡S r   )r,   r   Zrxorr!   r   r   r   r5   X   s    zOpsMixin.__rxor__c                 C  s   t S r   r   r   r   r   r   Ú_arith_method_   s    zOpsMixin._arith_methodÚ__add__c                 C  s   |   |tj¡S )a/  
        Get Addition of DataFrame and other, column-wise.

        Equivalent to ``DataFrame.add(other)``.

        Parameters
        ----------
        other : scalar, sequence, Series, dict or DataFrame
            Object to be added to the DataFrame.

        Returns
        -------
        DataFrame
            The result of adding ``other`` to DataFrame.

        See Also
        --------
        DataFrame.add : Add a DataFrame and another object, with option for index-
            or column-oriented addition.

        Examples
        --------
        >>> df = pd.DataFrame({'height': [1.5, 2.6], 'weight': [500, 800]},
        ...                   index=['elk', 'moose'])
        >>> df
               height  weight
        elk       1.5     500
        moose     2.6     800

        Adding a scalar affects all rows and columns.

        >>> df[['height', 'weight']] + 1.5
               height  weight
        elk       3.0   501.5
        moose     4.1   801.5

        Each element of a list is added to a column of the DataFrame, in order.

        >>> df[['height', 'weight']] + [0.5, 1.5]
               height  weight
        elk       2.0   501.5
        moose     3.1   801.5

        Keys of a dictionary are aligned to the DataFrame, based on column names;
        each value in the dictionary is added to the corresponding column.

        >>> df[['height', 'weight']] + {'height': 0.5, 'weight': 1.5}
               height  weight
        elk       2.0   501.5
        moose     3.1   801.5

        When `other` is a :class:`Series`, the index of `other` is aligned with the
        columns of the DataFrame.

        >>> s1 = pd.Series([0.5, 1.5], index=['weight', 'height'])
        >>> df[['height', 'weight']] + s1
               height  weight
        elk       3.0   500.5
        moose     4.1   800.5

        Even when the index of `other` is the same as the index of the DataFrame,
        the :class:`Series` will not be reoriented. If index-wise alignment is desired,
        :meth:`DataFrame.add` should be used with `axis='index'`.

        >>> s2 = pd.Series([0.5, 1.5], index=['elk', 'moose'])
        >>> df[['height', 'weight']] + s2
               elk  height  moose  weight
        elk    NaN     NaN    NaN     NaN
        moose  NaN     NaN    NaN     NaN

        >>> df[['height', 'weight']].add(s2, axis='index')
               height  weight
        elk       2.0   500.5
        moose     4.1   801.5

        When `other` is a :class:`DataFrame`, both columns names and the
        index are aligned.

        >>> other = pd.DataFrame({'height': [0.2, 0.4, 0.6]},
        ...                      index=['elk', 'moose', 'deer'])
        >>> df[['height', 'weight']] + other
               height  weight
        deer      NaN     NaN
        elk       1.7     NaN
        moose     3.0     NaN
        )r6   r   r   r!   r   r   r   r7   b   s    XzOpsMixin.__add__Ú__radd__c                 C  s   |   |tj¡S r   )r6   r   Zraddr!   r   r   r   r8   ¼   s    zOpsMixin.__radd__Ú__sub__c                 C  s   |   |tj¡S r   )r6   r   Úsubr!   r   r   r   r9   À   s    zOpsMixin.__sub__Ú__rsub__c                 C  s   |   |tj¡S r   )r6   r   Zrsubr!   r   r   r   r;   Ä   s    zOpsMixin.__rsub__Ú__mul__c                 C  s   |   |tj¡S r   )r6   r   Úmulr!   r   r   r   r<   È   s    zOpsMixin.__mul__Ú__rmul__c                 C  s   |   |tj¡S r   )r6   r   Zrmulr!   r   r   r   r>   Ì   s    zOpsMixin.__rmul__Ú__truediv__c                 C  s   |   |tj¡S r   )r6   r   Útruedivr!   r   r   r   r?   Ð   s    zOpsMixin.__truediv__Ú__rtruediv__c                 C  s   |   |tj¡S r   )r6   r   Zrtruedivr!   r   r   r   rA   Ô   s    zOpsMixin.__rtruediv__Ú__floordiv__c                 C  s   |   |tj¡S r   )r6   r   Úfloordivr!   r   r   r   rB   Ø   s    zOpsMixin.__floordiv__Z__rfloordivc                 C  s   |   |tj¡S r   )r6   r   Z	rfloordivr!   r   r   r   Ú__rfloordiv__Ü   s    zOpsMixin.__rfloordiv__Ú__mod__c                 C  s   |   |tj¡S r   )r6   r   Úmodr!   r   r   r   rE   à   s    zOpsMixin.__mod__Ú__rmod__c                 C  s   |   |tj¡S r   )r6   r   Zrmodr!   r   r   r   rG   ä   s    zOpsMixin.__rmod__Ú
__divmod__c                 C  s   |   |t¡S r   )r6   Údivmodr!   r   r   r   rH   è   s    zOpsMixin.__divmod__Ú__rdivmod__c                 C  s   |   |tj¡S r   )r6   r   Zrdivmodr!   r   r   r   rJ   ì   s    zOpsMixin.__rdivmod__Ú__pow__c                 C  s   |   |tj¡S r   )r6   r   Úpowr!   r   r   r   rK   ð   s    zOpsMixin.__pow__Ú__rpow__c                 C  s   |   |tj¡S r   )r6   r   Zrpowr!   r   r   r   rM   ô   s    zOpsMixin.__rpow__N)#Ú__name__Ú
__module__Ú__qualname__r   r
   r   r"   r$   r&   r(   r*   r,   r-   r/   r0   r2   r3   r5   r6   r7   r8   r9   r;   r<   r>   r?   rA   rB   rD   rE   rG   rH   rJ   rK   rM   r   r   r   r   r      sv   












Y













r   znp.ufuncÚstrr   )ÚufuncÚmethodÚinputsÚkwargsc                   sf  ddl m}m} ddlm‰ ddlm‰ m‰ tˆƒ}t	f i |¤Ž}t
ˆˆ	ˆg|¢R i |¤Ž}|turh|S tjj|jf}	|D ]P}
t|
dƒo’|
jˆjk}t|
dƒo¸t|
ƒj|	vo¸t|
ˆjƒ }|sÂ|rzt  S qztdd„ |D ƒƒ}‡fd	d
„t||ƒD ƒ‰tˆƒdk�r²t|ƒ}t|ƒdk�r:||h |¡�r:tdˆ	› d�ƒ‚ˆj}ˆdd… D ]4}tt||jƒƒD ]\}\}}| |¡||< �q`�qLttˆj|ƒƒ‰t‡‡fdd„t||ƒD ƒƒ}nttˆjˆjƒƒ‰ˆjdk�rdd
„ |D ƒ}tt|ƒƒdk�rø|d nd}d|i‰ni ‰‡‡	fdd„}‡ ‡‡‡‡‡‡fdd„‰d|v �r\tˆˆ	ˆg|¢R i |¤Ž}||ƒS ˆdk�rŽt ˆˆ	ˆg|¢R i |¤Ž}|tu�rŽ|S ˆjdk�rÜt|ƒdk�s´ˆ	j!dk�rÜtdd„ |D ƒƒ}t"ˆ	ˆƒ|i |¤Ž}n~ˆjdk�rtdd„ |D ƒƒ}t"ˆ	ˆƒ|i |¤Ž}nJˆdk�r<|�s<|d j#}| $t"ˆ	ˆƒ¡}nt%|d ˆ	ˆg|¢R i |¤Ž}||ƒ}|S )z˜
    Compatibility with numpy ufuncs.

    See also
    --------
    numpy.org/doc/stable/reference/arrays.classes.html#numpy.class.__array_ufunc__
    r   )Ú	DataFrameÚSeries©ÚNDFrame)ÚArrayManagerÚBlockManagerÚ__array_priority__Ú__array_ufunc__c                 s  s   | ]}t |ƒV  qd S r   )Útype©Ú.0Úxr   r   r   Ú	<genexpr>,  ó    zarray_ufunc.<locals>.<genexpr>c                   s   g | ]\}}t |ˆ ƒr|‘qS r   )Ú
issubclass©r`   ra   ÚtrX   r   r   Ú
<listcomp>-  rc   zarray_ufunc.<locals>.<listcomp>é   zCannot apply ufunc z& to mixed DataFrame and Series inputs.Nc                 3  s0   | ](\}}t |ˆ ƒr$|jf i ˆ¤Žn|V  qd S r   )rd   Zreindexre   )rY   Úreconstruct_axesr   r   rb   D  s   ÿc                 S  s    g | ]}t |d ƒrt|d ƒ‘qS )Úname)ÚhasattrÚgetattrr_   r   r   r   rg   L  rc   rj   c                   s(   ˆj dkr t‡ fdd„| D ƒƒS ˆ | ƒS )Nrh   c                 3  s   | ]}ˆ |ƒV  qd S r   r   r_   )Ú_reconstructr   r   rb   U  rc   z3array_ufunc.<locals>.reconstruct.<locals>.<genexpr>)ÚnoutÚtuple©Úresult)rm   rR   r   r   ÚreconstructR  s    
z array_ufunc.<locals>.reconstructc                   s‚   t  | ¡r| S | jˆjkr*ˆdkr&t‚| S t| ˆˆ fƒrJˆj| | jd�} nˆj| fi ˆ¤ˆ¤ddi¤Ž} tˆƒdkr~|  	ˆ¡} | S )NÚouter)ÚaxesÚcopyFrh   )
r   Z	is_scalarÚndimÚNotImplementedErrorÚ
isinstanceZ_constructor_from_mgrrt   Z_constructorÚlenZ__finalize__rp   )rZ   r[   Ú	alignablerS   ri   Úreconstruct_kwargsr   r   r   rm   Y  s(    
ÿÿÿÿ
z!array_ufunc.<locals>._reconstructÚoutÚreducec                 s  s   | ]}t  |¡V  qd S r   ©ÚnpZasarrayr_   r   r   r   rb   ˆ  rc   c                 s  s   | ]}t |d d�V  qdS )T)Zextract_numpyNr   r_   r   r   r   rb   Ž  rc   Ú__call__)&Zpandas.core.framerV   rW   Zpandas.core.genericrY   Zpandas.core.internalsrZ   r[   r^   Ú_standardize_out_kwargr   r   r   Zndarrayr]   rk   r\   rx   Z_HANDLED_TYPESro   Úzipry   ÚsetÚissubsetrw   rt   Ú	enumerateÚunionÚdictZ_AXIS_ORDERSrv   Údispatch_ufunc_with_outÚdispatch_reduction_ufuncrn   rl   Z_mgrÚapplyÚdefault_array_ufunc)r   rR   rS   rT   rU   rV   rW   Úclsrq   Zno_deferÚitemZhigher_priorityZhas_array_ufuncÚtypesZ	set_typesrt   ÚobjÚiZax1Zax2Únamesrj   rr   Zmgrr   )
rZ   r[   rY   rm   rz   rS   ri   r{   r   rR   r   Úarray_ufuncý   s‚    þ

þ
ÿý

ÿþ




&	
r’   r‡   )Úreturnc                  K  s@   d| vr<d| v r<d| v r<|   d¡}|   d¡}||f}|| d< | S )z²
    If kwargs contain "out1" and "out2", replace that with a tuple "out"

    np.divmod, np.modf, np.frexp can have either `out=(out1, out2)` or
    `out1=out1, out2=out2)`
    r|   Úout1Úout2)Úpop)rU   r”   r•   r|   r   r   r   r�   ¢  s    

r�   )rR   rS   c           
      O  s¶   |  d¡}|  dd¡}t||ƒ|i |¤Ž}|tu r6tS t|tƒr‚t|tƒrZt|ƒt|ƒkr^t‚t||ƒD ]\}}	t||	|ƒ qh|S t|tƒr¦t|ƒdkr¢|d }nt‚t|||ƒ |S )zz
    If we have an `out` keyword, then call the ufunc without `out` and then
    set the result into the given `out`.
    r|   ÚwhereNrh   r   )	r–   rl   r   rx   ro   ry   rw   r‚   Ú_assign_where)
r   rR   rS   rT   rU   r|   r—   rq   ZarrÚresr   r   r   rˆ   ±  s"    



rˆ   ÚNonec                 C  s(   |du r|| dd…< nt  | ||¡ dS )zV
    Set a ufunc result into 'out', masking with a 'where' argument if necessary.
    N)r   Zputmask)r|   rq   r—   r   r   r   r˜   Ô  s    r˜   c                   s@   t ‡ fdd„|D ƒƒst‚‡ fdd„|D ƒ}t||ƒ|i |¤ŽS )z�
    Fallback to the behavior we would get if we did not define __array_ufunc__.

    Notes
    -----
    We are assuming that `self` is among `inputs`.
    c                 3  s   | ]}|ˆ u V  qd S r   r   r_   ©r   r   r   rb   ç  rc   z&default_array_ufunc.<locals>.<genexpr>c                   s"   g | ]}|ˆ ur|nt  |¡‘qS r   r~   r_   r›   r   r   rg   ê  rc   z'default_array_ufunc.<locals>.<listcomp>)Úanyrw   rl   )r   rR   rS   rT   rU   Z
new_inputsr   r›   r   r‹   ß  s    r‹   c                 O  s’   |dksJ ‚t |ƒdks$|d | ur(tS |jtvr6tS t|j }t| |ƒsNtS | jdkrzt| tƒrjd|d< d|vrzd|d< t| |ƒf ddi|¤ŽS )z@
    Dispatch ufunc reductions to self's reduction methods.
    r}   rh   r   FZnumeric_onlyZaxisZskipna)	ry   r   rN   ÚREDUCTION_ALIASESrk   rv   rx   r   rl   )r   rR   rS   rT   rU   Úmethod_namer   r   r   r‰   ï  s    




r‰   )Ú__doc__Ú
__future__r   r   Útypingr   Únumpyr   Zpandas._libsr   Zpandas._libs.ops_dispatchr   Zpandas.core.dtypes.genericr   Zpandas.corer   Zpandas.core.constructionr	   Zpandas.core.ops.commonr
   r�   r   r’   r�   rˆ   r˜   r‹   r‰   r   r   r   r   Ú<module>   s0   ü _ &#