
    MhD                        S r SSKJr  SSKrSSKJr  SSK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SSS.r " S S5      rSS jrSS jrSS jrSS jrSS jrSS jrg)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                  6   \ rS rSrS r\" S5      S 5       r\" S5      S 5       r\" S5      S 5       r\" S	5      S
 5       r	\" S5      S 5       r
\" S5      S 5       rS r\" S5      S 5       r\" S5      S 5       r\" S5      S 5       r\" S5      S 5       r\" S5      S 5       r\" S5      S 5       rS r\" S5      S 5       r\" S5      S  5       r\" S!5      S" 5       r\" S#5      S$ 5       r\" S%5      S& 5       r\" S'5      S( 5       r\" S)5      S* 5       r\" S+5      S, 5       r\" S-5      S. 5       r\" S/5      S0 5       r\" S15      S2 5       r\" S35      S4 5       r\" S55      S6 5       r \" S75      S8 5       r!\" S95      S: 5       r"\" S;5      S< 5       r#S=r$g>)?OpsMixin   c                    [         $ NNotImplementedselfotherops      G/var/www/html/env/lib/python3.13/site-packages/pandas/core/arraylike.py_cmp_methodOpsMixin._cmp_method#           __eq__c                B    U R                  U[        R                  5      $ r   )r    operatoreqr   r   s     r   r$   OpsMixin.__eq__&       x{{33r#   __ne__c                B    U R                  U[        R                  5      $ r   )r    r&   ner(   s     r   r+   OpsMixin.__ne__*   r*   r#   __lt__c                B    U R                  U[        R                  5      $ r   )r    r&   ltr(   s     r   r/   OpsMixin.__lt__.   r*   r#   __le__c                B    U R                  U[        R                  5      $ r   )r    r&   ler(   s     r   r3   OpsMixin.__le__2   r*   r#   __gt__c                B    U R                  U[        R                  5      $ r   )r    r&   gtr(   s     r   r7   OpsMixin.__gt__6   r*   r#   __ge__c                B    U R                  U[        R                  5      $ r   )r    r&   ger(   s     r   r;   OpsMixin.__ge__:   r*   r#   c                    [         $ r   r   r   s      r   _logical_methodOpsMixin._logical_methodA   r"   r#   __and__c                B    U R                  U[        R                  5      $ r   )r@   r&   and_r(   s     r   rB   OpsMixin.__and__D   s    ##E8==99r#   __rand__c                B    U R                  U[        R                  5      $ r   )r@   r   rand_r(   s     r   rF   OpsMixin.__rand__H   s    ##E9??;;r#   __or__c                B    U R                  U[        R                  5      $ r   )r@   r&   or_r(   s     r   rJ   OpsMixin.__or__L       ##E8<<88r#   __ror__c                B    U R                  U[        R                  5      $ r   )r@   r   ror_r(   s     r   rO   OpsMixin.__ror__P       ##E9>>::r#   __xor__c                B    U R                  U[        R                  5      $ r   )r@   r&   xorr(   s     r   rT   OpsMixin.__xor__T   rN   r#   __rxor__c                B    U R                  U[        R                  5      $ r   )r@   r   rxorr(   s     r   rX   OpsMixin.__rxor__X   rS   r#   c                    [         $ r   r   r   s      r   _arith_methodOpsMixin._arith_method_   r"   r#   __add__c                B    U R                  U[        R                  5      $ )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(   s     r   r_   OpsMixin.__add__b   s    p !!%66r#   __radd__c                B    U R                  U[        R                  5      $ r   )r]   r   raddr(   s     r   rb   OpsMixin.__radd__       !!%88r#   __sub__c                B    U R                  U[        R                  5      $ r   )r]   r&   subr(   s     r   rg   OpsMixin.__sub__       !!%66r#   __rsub__c                B    U R                  U[        R                  5      $ r   )r]   r   rsubr(   s     r   rl   OpsMixin.__rsub__   rf   r#   __mul__c                B    U R                  U[        R                  5      $ r   )r]   r&   mulr(   s     r   rp   OpsMixin.__mul__   rk   r#   __rmul__c                B    U R                  U[        R                  5      $ r   )r]   r   rmulr(   s     r   rt   OpsMixin.__rmul__   rf   r#   __truediv__c                B    U R                  U[        R                  5      $ r   )r]   r&   truedivr(   s     r   rx   OpsMixin.__truediv__   s    !!%)9)9::r#   __rtruediv__c                B    U R                  U[        R                  5      $ r   )r]   r   rtruedivr(   s     r   r|   OpsMixin.__rtruediv__   s    !!%););<<r#   __floordiv__c                B    U R                  U[        R                  5      $ r   )r]   r&   floordivr(   s     r   r   OpsMixin.__floordiv__   s    !!%):):;;r#   __rfloordivc                B    U R                  U[        R                  5      $ r   )r]   r   	rfloordivr(   s     r   __rfloordiv__OpsMixin.__rfloordiv__   s    !!%)<)<==r#   __mod__c                B    U R                  U[        R                  5      $ r   )r]   r&   modr(   s     r   r   OpsMixin.__mod__   rk   r#   __rmod__c                B    U R                  U[        R                  5      $ r   )r]   r   rmodr(   s     r   r   OpsMixin.__rmod__   rf   r#   
__divmod__c                .    U R                  U[        5      $ r   )r]   divmodr(   s     r   r   OpsMixin.__divmod__   s    !!%00r#   __rdivmod__c                B    U R                  U[        R                  5      $ r   )r]   r   rdivmodr(   s     r   r   OpsMixin.__rdivmod__   s    !!%):):;;r#   __pow__c                B    U R                  U[        R                  5      $ r   )r]   r&   powr(   s     r   r   OpsMixin.__pow__   rk   r#   __rpow__c                B    U R                  U[        R                  5      $ r   )r]   r   rpowr(   s     r   r   OpsMixin.__rpow__   rf   r#    N)%__name__
__module____qualname____firstlineno__r    r   r$   r+   r/   r3   r7   r;   r@   rB   rF   rJ   rO   rT   rX   r]   r_   rb   rg   rl   rp   rt   rx   r|   r   r   r   r   r   r   r   r   __static_attributes__r   r#   r   r   r      s    h'4 (4 h'4 (4 h'4 (4 h'4 (4 h'4 (4 h'4 (4 i(: ): j)< *< h'9 (9 i(; ); i(9 )9 j); *; i(W7 )W7r j)9 *9 i(7 )7 j)9 *9 i(7 )7 j)9 *9 m,; -; n-= .= n-< .< m,> -> i(7 )7 j)9 *9 l+1 ,1 m,< -< i(7 )7 j)9 *9r#   r   c                  ^ ^^^^^^^^^  SSK JnJn  SSKJm  SSKJmJm  [        T 5      n[        S0 UD6n[        T TT/UQ70 UD6nU[        La  U$ [        R                  R                  UR                  4n	U H  n
[        U
S5      =(       a    U
R                   T R                   :  n[        U
S5      =(       a:    [        U
5      R                  U	;  =(       a    [#        U
T R$                  5      (       + nU(       d	  U(       d  M  [        s  $    ['        S U 5       5      n[)        X=5       VVs/ s H  u  p[+        UT5      (       d  M  UPM     snnm[-        T5      S:  a  [/        U5      n[-        U5      S:  a&  XV1R1                  U5      (       a  [3        S	T S
35      eT R4                  nTSS  HC  n[7        [)        UUR4                  5      5       H  u  nu  nnUR9                  U5      UU'   M     ME     [;        [)        T R<                  U5      5      m['        UU4S j[)        X=5       5       5      nO)[;        [)        T R<                  T R4                  5      5      mT R>                  S:X  aS  U Vs/ s H"  n[        US5      (       d  M  [A        US5      PM$     nn[-        [/        U5      5      S:X  a  US   OSnSU0m O0 m UU4S jnUUUUUU U 4S jmSU;   a  [C        T TT/UQ70 UD6nU" U5      $ TS:X  a  [E        T TT/UQ70 UD6nU[        La  U$ T R>                  S:  aD  [-        U5      S:  d  TRF                  S:  a%  ['        S U 5       5      n[A        TT5      " U0 UD6nOT R>                  S:X  a%  ['        S U 5       5      n[A        TT5      " U0 UD6nOLTS:X  a2  U(       d+  US   RH                  nURK                  [A        TT5      5      nO[M        US   TT/UQ70 UD6nU" U5      nU$ s  snnf s  snf )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              3  8   #    U  H  n[        U5      v   M     g 7fr   )type.0xs     r   	<genexpr>array_ufunc.<locals>.<genexpr>,  s     *6a$q''6s      zCannot apply ufunc z& to mixed DataFrame and Series inputs.Nc              3  r   >#    U  H,  u  p[        UT5      (       a  UR                  " S0 TD6OUv   M.     g 7f)Nr   )
issubclassreindex)r   r   tr   reconstruct_axess      r   r   r   D  s8      
* .87-C-CAII)()J*s   47namec                ^   > TR                   S:  a  [        U4S jU  5       5      $ T" U 5      $ )Nr   c              3  4   >#    U  H  nT" U5      v   M     g 7fr   r   )r   r   _reconstructs     r   r   3array_ufunc.<locals>.reconstruct.<locals>.<genexpr>U  s     9&Qa&s   )nouttuple)resultr   ufuncs    r   reconstruct array_ufunc.<locals>.reconstructR  s*    ::>9&999F##r#   c                ^  > [         R                  " U 5      (       a  U $ U R                  TR                  :w  a  TS:X  a  [        eU $ [	        U TT45      (       a  TR                  X R                  S9n OTR                  " U 40 TDTDSS0D6n [        T5      S:X  a  U R                  T5      n U $ )Nouter)axescopyFr   )
r   	is_scalarndimNotImplementedError
isinstance_constructor_from_mgrr   _constructorlen__finalize__)r   r   r   	alignablemethodr   reconstruct_kwargsr   s    r   r   !array_ufunc.<locals>._reconstructY  s    ==  M;;$))# ))Mf|\:;;//[[/IF &&*.@GLF y>Q((.Fr#   outreducec              3  N   #    U  H  n[         R                  " U5      v   M     g 7fr   )npasarrayr   s     r   r   r     s     5frzz!}}fs   #%c              3  6   #    U  H  n[        US S9v   M     g7f)T)extract_numpyNr	   r   s     r   r   r     s     LV}Qd;Vs   __call__r   )'pandas.core.framer   r   pandas.core.genericr   pandas.core.internalsr   r   r   _standardize_out_kwargr   r   r   ndarrayr   hasattrr   r   _HANDLED_TYPESr   zipr   r   setissubsetr   r   	enumerateuniondict_AXIS_ORDERSr   getattrdispatch_ufunc_with_outdispatch_reduction_ufuncr   _mgrapplydefault_array_ufunc)!r   r   r   inputskwargsr   r   clsr   no_deferitemhigher_priorityhas_array_ufunctypesr   r   	set_typesr   objiax1ax2namesr   r   mgrr   r   r   r   r   r   r   s!   ```                       @@@@@@@r   array_ufuncr     s    ,
 t*C#-f-F /tUFVVVvVF^# 	

""H
 D./ B''$*A*AA 	
 D+, :T
**(::tT%8%899 	
 oo!!  *6**E"61L1tqZ75K1LI
9~
 J	y>A9"5">">y"I"I &%eW,RS  yyQR=C "+3tSXX+>!?:C))C.Q "@ !  D$5$5t <= 
F*
 

  D$5$5tyy AByyA~-3JVwq&7I#F#VJs5z?a/uQxT$d^$ 0 (ufPvPP6"")$vQQ&Q'M
 yy1}#f+/UZZ!^ 5f55 ':6:	aLVLL':6: Z )..CYYwuf56F )E6UFUfUF  FMe M> Ks   1O=O=9PPc                 |    SU ;  a5  SU ;   a/  SU ;   a)  U R                  S5      nU R                  S5      nX4nX0S'   U $ )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)r   r  r  r   s       r   r   r     sI     Fv/Ff4Dzz&!zz&!luMr#   c                   UR                  S5      nUR                  SS5      n[        X5      " U0 UD6nU[        L a  [        $ [        U[        5      (       aU  [        U[        5      (       a  [        U5      [        U5      :w  a  [        e[        XW5       H  u  p[        XU5        M     U$ [        U[        5      (       a  [        U5      S:X  a  US   nO[        e[        XWU5        U$ )zn
If we have an `out` keyword, then call the ufunc without `out` and then
set the result into the given `out`.
r   whereNr   r   )	r  r   r   r   r   r   r   r   _assign_where)
r   r   r   r   r   r   r  r   arrress
             r   r   r     s     **U
CJJw%EU#V6v6F&%  #u%%SS[)@%%C(HC#E* ) 
#us8q=a&C%%#u%Jr#   c                B    Uc  XSS& g[         R                  " XU5        g)zN
Set a ufunc result into 'out', masking with a 'where' argument if necessary.
N)r   putmask)r   r   r  s      r   r	  r	    s     }A


3v&r#   c                   ^  [        U 4S jU 5       5      (       d  [        eU Vs/ s H  oUT La  UO[        R                  " U5      PM!     nn[	        X5      " U0 UD6$ s  snf )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  *   >#    U  H  oTL v   M
     g 7fr   r   )r   r   r   s     r   r   &default_array_ufunc.<locals>.<genexpr>  s     )&QDy&s   )anyr   r   r   r   )r   r   r   r   r   r   
new_inputss   `      r   r   r     s\     )&)))!!AGHA}!"**Q-7JH5!:888 Is   &Ac                b   US:X  d   e[        U5      S:w  d  US   U La  [        $ UR                  [        ;  a  [        $ [        UR                     n[	        X5      (       d  [        $ U R
                  S:  a%  [        U [        5      (       a  SUS'   SU;  a  SUS'   [        X5      " SSS0UD6$ )	z8
Dispatch ufunc reductions to self's reduction methods.
r   r   r   Fnumeric_onlyaxisskipnar   )	r   r   r   REDUCTION_ALIASESr   r   r   r   r   )r   r   r   r   r   method_names         r   r   r     s     X
6{a6!9D0~~..#ENN3K 4%%yy1}dJ''%*F>" F6N 4%=U=f==r#   )r   np.ufuncr   strr   r   r   r   )returnr   )r   r  r   r  )r  None)__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   <module>r'     sn    #     G 1 ! 2 ; 	 W9 W9|bJ F'9 #>r#   