o
    Û­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„Zd)dd„Zd*dd „Zd+d"d#„Zd*d$d%„Z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  ó   t S ©N©ÚNotImplemented©ÚselfÚotherÚop© r   úR/var/www/html/CropPilot/venv/lib/python3.10/site-packages/pandas/core/arraylike.pyÚ_cmp_method#   ó   zOpsMixin._cmp_methodÚ__eq__c                 C  ó   |   |tj¡S r   )r   ÚoperatorÚeq©r   r   r   r   r   r    &   ó   zOpsMixin.__eq__Ú__ne__c                 C  r!   r   )r   r"   Úner$   r   r   r   r&   *   r%   zOpsMixin.__ne__Ú__lt__c                 C  r!   r   )r   r"   Últr$   r   r   r   r(   .   r%   zOpsMixin.__lt__Ú__le__c                 C  r!   r   )r   r"   Úler$   r   r   r   r*   2   r%   zOpsMixin.__le__Ú__gt__c                 C  r!   r   )r   r"   Úgtr$   r   r   r   r,   6   r%   zOpsMixin.__gt__Ú__ge__c                 C  r!   r   )r   r"   Úger$   r   r   r   r.   :   r%   zOpsMixin.__ge__c                 C  r   r   r   r   r   r   r   Ú_logical_methodA   r   zOpsMixin._logical_methodÚ__and__c                 C  r!   r   )r0   r"   Úand_r$   r   r   r   r1   D   r%   zOpsMixin.__and__Ú__rand__c                 C  r!   r   )r0   r   Úrand_r$   r   r   r   r3   H   r%   zOpsMixin.__rand__Ú__or__c                 C  r!   r   )r0   r"   Úor_r$   r   r   r   r5   L   r%   zOpsMixin.__or__Ú__ror__c                 C  r!   r   )r0   r   Úror_r$   r   r   r   r7   P   r%   zOpsMixin.__ror__Ú__xor__c                 C  r!   r   )r0   r"   Úxorr$   r   r   r   r9   T   r%   zOpsMixin.__xor__Ú__rxor__c                 C  r!   r   )r0   r   Úrxorr$   r   r   r   r;   X   r%   zOpsMixin.__rxor__c                 C  r   r   r   r   r   r   r   Ú_arith_method_   r   zOpsMixin._arith_methodÚ__add__c                 C  r!   )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
        )r=   r"   r   r$   r   r   r   r>   b   s   XzOpsMixin.__add__Ú__radd__c                 C  r!   r   )r=   r   Úraddr$   r   r   r   r?   ¼   r%   zOpsMixin.__radd__Ú__sub__c                 C  r!   r   )r=   r"   Úsubr$   r   r   r   rA   À   r%   zOpsMixin.__sub__Ú__rsub__c                 C  r!   r   )r=   r   Úrsubr$   r   r   r   rC   Ä   r%   zOpsMixin.__rsub__Ú__mul__c                 C  r!   r   )r=   r"   Úmulr$   r   r   r   rE   È   r%   zOpsMixin.__mul__Ú__rmul__c                 C  r!   r   )r=   r   Úrmulr$   r   r   r   rG   Ì   r%   zOpsMixin.__rmul__Ú__truediv__c                 C  r!   r   )r=   r"   Útruedivr$   r   r   r   rI   Ð   r%   zOpsMixin.__truediv__Ú__rtruediv__c                 C  r!   r   )r=   r   Úrtruedivr$   r   r   r   rK   Ô   r%   zOpsMixin.__rtruediv__Ú__floordiv__c                 C  r!   r   )r=   r"   Úfloordivr$   r   r   r   rM   Ø   r%   zOpsMixin.__floordiv__Ú__rfloordivc                 C  r!   r   )r=   r   Ú	rfloordivr$   r   r   r   Ú__rfloordiv__Ü   r%   zOpsMixin.__rfloordiv__Ú__mod__c                 C  r!   r   )r=   r"   Úmodr$   r   r   r   rR   à   r%   zOpsMixin.__mod__Ú__rmod__c                 C  r!   r   )r=   r   Úrmodr$   r   r   r   rT   ä   r%   zOpsMixin.__rmod__Ú
__divmod__c                 C  s   |   |t¡S r   )r=   Údivmodr$   r   r   r   rV   è   s   zOpsMixin.__divmod__Ú__rdivmod__c                 C  r!   r   )r=   r   Úrdivmodr$   r   r   r   rX   ì   r%   zOpsMixin.__rdivmod__Ú__pow__c                 C  r!   r   )r=   r"   Úpowr$   r   r   r   rZ   ð   r%   zOpsMixin.__pow__Ú__rpow__c                 C  r!   r   )r=   r   Úrpowr$   r   r   r   r\   ô   r%   zOpsMixin.__rpow__N)#Ú__name__Ú
__module__Ú__qualname__r   r
   r    r&   r(   r*   r,   r.   r0   r1   r3   r5   r7   r9   r;   r=   r>   r?   rA   rC   rE   rG   rI   rK   rM   rQ   rR   rT   rV   rX   rZ   r\   r   r   r   r   r      sx    












Y













r   Úufuncúnp.ufuncÚmethodÚstrÚinputsr   Úkwargsc                   sX  ddl m}m} ddlm‰ ddlm‰ m‰ tˆƒ}t	di |¤Ž}t
ˆˆ	ˆg|¢R i |¤Ž}|tur4|S tjj|jf}	|D ](}
t|
dƒoI|
jˆjk}t|
dƒo\t|
ƒj|	vo\t|
ˆjƒ }|sa|ret  S q=t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 ]}tt||jƒƒD ]\}\}}| |¡||< q­q£t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�rgt|ƒdk�sSˆ	j!dk�rgtdd„ |D ƒƒ}t"ˆ	ˆƒ|i |¤Ž}n?ˆjdk�r�tdd„ |D ƒƒ}t"ˆ	ˆƒ|i |¤Ž}n%ˆ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©rq   rr   Útri   r   r   Ú
<listcomp>-  s    zarray_ufunc.<locals>.<listcomp>é   zCannot apply ufunc z& to mixed DataFrame and Series inputs.Nc                 3  s2   � | ]\}}t |ˆ ƒr|jdi ˆ¤Žn|V  qd S )Nr   )ru   Úreindexrv   )rj   Úreconstruct_axesr   r   rs   D  s
   € ÿ
ÿc                 S  s    g | ]}t |d ƒrt|d ƒ‘qS )Úname)ÚhasattrÚgetattrrp   r   r   r   rx   L  s     r|   c                   s(   ˆj dkrt‡ fdd„| D ƒƒS ˆ | ƒS )Nry   c                 3  s   � | ]}ˆ |ƒV  qd S r   r   rp   )Ú_reconstructr   r   rs   U  rt   z3array_ufunc.<locals>.reconstruct.<locals>.<genexpr>)ÚnoutÚtuple©Úresult)r   ra   r   r   ÚreconstructR  s   
z array_ufunc.<locals>.reconstructc                   s‚   t  | ¡r| S | jˆjkrˆdkrt‚| S t| ˆˆ fƒr%ˆj| | jd�} nˆj| fi ˆ¤ˆ¤ddi¤Ž} tˆƒdkr?|  	ˆ¡} | S )NÚouter)ÚaxesÚcopyFry   )
r   Ú	is_scalarÚndimÚNotImplementedErrorÚ
isinstanceÚ_constructor_from_mgrr†   Ú_constructorÚlenÚ__finalize__r‚   )rk   rl   Ú	alignablerc   r{   Úreconstruct_kwargsr   r   r   r   Y  s(   
ÿÿÿÿ
z!array_ufunc.<locals>._reconstructÚoutÚreducec                 s  s   � | ]}t  |¡V  qd S r   ©ÚnpÚasarrayrp   r   r   r   rs   ˆ  s   € c                 s  s   � | ]	}t |d d�V  qdS )T)Úextract_numpyNr   rp   r   r   r   rs   Ž  s   € Ú__call__r   )&Úpandas.core.framerg   rh   Úpandas.core.genericrj   Úpandas.core.internalsrk   rl   ro   Ú_standardize_out_kwargr   r   r•   Úndarrayrn   r}   rm   r‹   Ú_HANDLED_TYPESr�   ÚziprŽ   ÚsetÚissubsetrŠ   r†   Ú	enumerateÚunionÚdictÚ_AXIS_ORDERSr‰   Údispatch_ufunc_with_outÚdispatch_reduction_ufuncr€   r~   Ú_mgrÚapplyÚdefault_array_ufunc)r   ra   rc   re   rf   rg   rh   Úclsrƒ   Úno_deferÚitemÚhigher_priorityÚhas_array_ufuncÚtypesÚ	set_typesr†   ÚobjÚiÚax1Úax2Únamesr|   r„   Úmgrr   )
rk   rl   rj   r   r�   rc   r{   r‘   r   ra   r   Úarray_ufuncý   s†   þ

þ
ÿýÿ
ÿÿ
þ




&	
r¸   Úreturnr¤   c                  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)rf   rº   r»   r’   r   r   r   rœ   ¢  s   

rœ   c           
      O  s¶   |  d¡}|  dd¡}t||ƒ|i |¤Ž}|tu rtS t|tƒrAt|tƒr-t|ƒt|ƒkr/t‚t||ƒD ]
\}}	t||	|ƒ q4|S t|tƒrSt|ƒdkrQ|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’   ÚwhereNry   r   )	r¼   r~   r   r‹   r�   rŽ   rŠ   rŸ   Ú_assign_where)
r   ra   rc   re   rf   r’   r½   rƒ   ÚarrÚresr   r   r   r¦   ±  s"   



r¦   ÚNonec                 C  s*   |du r|| dd…< dS t  | ||¡ dS )zV
    Set a ufunc result into 'out', masking with a 'where' argument if necessary.
    N)r•   Úputmask)r’   rƒ   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   rp   ©r   r   r   rs   ç  rt   z&default_array_ufunc.<locals>.<genexpr>c                   s"   g | ]}|ˆ ur
|nt  |¡‘qS r   r”   rp   rÃ   r   r   rx   ê  s   " z'default_array_ufunc.<locals>.<listcomp>)ÚanyrŠ   r~   )r   ra   rc   re   rf   Ú
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rtS t|j }t| |ƒs'tS | jdkr=t| tƒr5d|d< d|vr=d|d< t| |ƒd	ddi|¤ŽS )
z@
    Dispatch ufunc reductions to self's reduction methods.
    r“   ry   r   FÚnumeric_onlyÚaxisÚskipnaNr   )	rŽ   r   r^   ÚREDUCTION_ALIASESr}   r‰   r‹   r   r~   )r   ra   rc   re   rf   Úmethod_namer   r   r   r§   ï  s   




r§   )ra   rb   rc   rd   re   r   rf   r   )r¹   r¤   )ra   rb   rc   rd   )r¹   rÁ   )Ú__doc__Ú
__future__r   r"   Útypingr   Únumpyr•   Úpandas._libsr   Úpandas._libs.ops_dispatchr   Úpandas.core.dtypes.genericr   Úpandas.corer   Úpandas.core.constructionr	   Úpandas.core.ops.commonr
   rÉ   r   r¸   rœ   r¦   r¾   rª   r§   r   r   r   r   Ú<module>   s2    ü 
_ 
&

#
