zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
U
¬ý°dÖFã@sôdZddlmZddlZddlmZddlZddlm    Z    ddl
m Z ddl m Z ddlmZdd    lmZdd
lmZd d d ddœZGdd„dƒZdddddœdd„Zddœdd„Zdddœdd„Zddœd d!„Zdddœd"d#„Zdddœd$d%„ZdS)&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)ÚmaximumZminimumÚaddÚmultiplyc@säeZdZdd„Zedƒdd„ƒZedƒdd„ƒZed    ƒd
d „ƒZed ƒd d„ƒZedƒdd„ƒZ    edƒdd„ƒZ
dd„Z edƒdd„ƒZ edƒdd„ƒZ edƒdd„ƒZed ƒd!d"„ƒZed#ƒd$d%„ƒZed&ƒd'd(„ƒZd)d*„Zed+ƒd,d-„ƒZed.ƒd/d0„ƒZed1ƒd2d3„ƒZed4ƒd5d6„ƒZed7ƒd8d9„ƒZed:ƒd;d<„ƒZed=ƒd>d?„ƒZed@ƒdAdB„ƒZedCƒdDdE„ƒZedFƒdGdH„ƒZedIƒdJdK„ƒZedLƒdMdN„ƒZedOƒdPdQ„ƒZedRƒdSdT„ƒZ edUƒdVdW„ƒZ!edXƒdYdZ„ƒZ"d[S)\ÚOpsMixincCstS©N©ÚNotImplemented©ÚselfÚotherÚop©rúLd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/arraylike.pyÚ _cmp_method#szOpsMixin._cmp_methodÚ__eq__cCs| |tj¡Sr)rÚoperatorÚeq©rrrrrr&szOpsMixin.__eq__Ú__ne__cCs| |tj¡Sr)rrÚner rrrr!*szOpsMixin.__ne__Ú__lt__cCs| |tj¡Sr)rrÚltr rrrr#.szOpsMixin.__lt__Ú__le__cCs| |tj¡Sr)rrÚler rrrr%2szOpsMixin.__le__Ú__gt__cCs| |tj¡Sr)rrÚgtr rrrr'6szOpsMixin.__gt__Ú__ge__cCs| |tj¡Sr)rrÚger rrrr):szOpsMixin.__ge__cCstSrrrrrrÚ_logical_methodAszOpsMixin._logical_methodÚ__and__cCs| |tj¡Sr)r+rÚand_r rrrr,DszOpsMixin.__and__Ú__rand__cCs| |tj¡Sr)r+rZrand_r rrrr.HszOpsMixin.__rand__Ú__or__cCs| |tj¡Sr)r+rÚor_r rrrr/LszOpsMixin.__or__Ú__ror__cCs| |tj¡Sr)r+rZror_r rrrr1PszOpsMixin.__ror__Ú__xor__cCs| |tj¡Sr)r+rÚxorr rrrr2TszOpsMixin.__xor__Ú__rxor__cCs| |tj¡Sr)r+rZrxorr rrrr4XszOpsMixin.__rxor__cCstSrrrrrrÚ _arith_method_szOpsMixin._arith_methodÚ__add__cCs| |tj¡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
        )r5rrr rrrr6bsXzOpsMixin.__add__Ú__radd__cCs| |tj¡Sr)r5rZraddr rrrr7¼szOpsMixin.__radd__Ú__sub__cCs| |tj¡Sr)r5rÚsubr rrrr8ÀszOpsMixin.__sub__Ú__rsub__cCs| |tj¡Sr)r5rZrsubr rrrr:ÄszOpsMixin.__rsub__Ú__mul__cCs| |tj¡Sr)r5rÚmulr rrrr;ÈszOpsMixin.__mul__Ú__rmul__cCs| |tj¡Sr)r5rZrmulr rrrr=ÌszOpsMixin.__rmul__Ú __truediv__cCs| |tj¡Sr)r5rÚtruedivr rrrr>ÐszOpsMixin.__truediv__Ú __rtruediv__cCs| |tj¡Sr)r5rZrtruedivr rrrr@ÔszOpsMixin.__rtruediv__Ú __floordiv__cCs| |tj¡Sr)r5rÚfloordivr rrrrAØszOpsMixin.__floordiv__Z __rfloordivcCs| |tj¡Sr)r5rZ    rfloordivr rrrÚ __rfloordiv__ÜszOpsMixin.__rfloordiv__Ú__mod__cCs| |tj¡Sr)r5rÚmodr rrrrDàszOpsMixin.__mod__Ú__rmod__cCs| |tj¡Sr)r5rZrmodr rrrrFäszOpsMixin.__rmod__Ú
__divmod__cCs | |t¡Sr)r5Údivmodr rrrrGèszOpsMixin.__divmod__Ú __rdivmod__cCs| |tj¡Sr)r5rZrdivmodr rrrrIìszOpsMixin.__rdivmod__Ú__pow__cCs| |tj¡Sr)r5rÚpowr rrrrJðszOpsMixin.__pow__Ú__rpow__cCs| |tj¡Sr)r5rZrpowr rrrrLôszOpsMixin.__rpow__N)#Ú__name__Ú
__module__Ú __qualname__rr
rr!r#r%r'r)r+r,r.r/r1r2r4r5r6r7r8r:r;r=r>r@rArCrDrFrGrIrJrLrrrrrsv
 
 
 
 
 
 
 
 
 
 
 
 
Y
 
 
 
 
 
 
 
 
 
 
 
 
 
rznp.ufuncÚstrr)ÚufuncÚmethodÚinputsÚkwargscs<ddlm}m}ddlm‰ddlm‰tˆƒ}tf|Ž}t    ˆˆˆf|ž|Ž}|t
k    rZ|St j j |j f}    |D]P}
t|
dƒo„|
jˆjk} t|
dƒoªt|
ƒj |    koªt|
ˆjƒ } | s´| rlt
Sqltdd„|Dƒƒ} ‡fd    d
„t|| ƒDƒ‰tˆƒd kr¤t| ƒ}t|ƒd kr,||h |¡r,td ˆ›d ƒ‚ˆj}ˆd d…D]4}tt||jƒƒD]\}\}}| |¡||<qRq>ttˆj|ƒƒ‰t‡‡fdd„t|| ƒDƒƒ}nttˆjˆjƒƒ‰ˆjd krødd
„|Dƒ}tt|ƒƒd krê|dnd}d|i‰ni‰‡‡fdd„}‡‡‡‡‡‡fdd„‰d|krFtˆˆˆf|ž|Ž}||ƒSˆdkrrtˆˆˆf|ž|Ž}|t
k    rr|Sˆjd kr¼t|ƒd ks˜ˆj d kr¼tdd„|Dƒƒ}t!ˆˆƒ||Ž}ntˆjd krìtdd„|Dƒƒ}t!ˆˆƒ||Ž}nDˆdkr|s|dj"}| #t!ˆˆƒ¡}nt$|dˆˆf|ž|Ž}||ƒ}|S)z˜
    Compatibility with numpy ufuncs.
 
    See also
    --------
    numpy.org/doc/stable/reference/arrays.classes.html#numpy.class.__array_ufunc__
    r)Ú    DataFrameÚSeries©ÚNDFrame)Ú BlockManagerÚ__array_priority__Ú__array_ufunc__css|]}t|ƒVqdSr)Útype©Ú.0ÚxrrrÚ    <genexpr>)szarray_ufunc.<locals>.<genexpr>csg|]\}}t|ˆƒr|‘qSr)Ú
issubclass©r^r_ÚtrWrrÚ
<listcomp>*s
zarray_ufunc.<locals>.<listcomp>ézCannot apply ufunc z& to mixed DataFrame and Series inputs.Nc3s,|]$\}}t|ˆƒr |jfˆŽn|VqdSr)raZreindexrb)rXÚreconstruct_axesrrr`AsÿcSs g|]}t|dƒrt|dƒ‘qS)Úname)ÚhasattrÚgetattrr]rrrrdIs
rgcs(ˆjdkr t‡fdd„|DƒƒSˆ|ƒS)Nrec3s|]}ˆ|ƒVqdSrrr])Ú _reconstructrrr`Rsz3array_ufunc.<locals>.reconstruct.<locals>.<genexpr>)ÚnoutÚtuple©Úresult)rjrQrrÚ reconstructOs
z array_ufunc.<locals>.reconstructcs~t |¡r|S|jˆjkr*ˆdkr&t‚|St|ˆƒrLˆj|fˆddi—Ž}nˆj|fˆˆddi—Ž}tˆƒdkrz| ˆ¡}|S)NÚouterÚcopyFre)rZ    is_scalarÚndimÚNotImplementedErrorÚ
isinstanceZ _constructorÚlenZ __finalize__rm)rYÚ    alignablerRrfÚreconstruct_kwargsrrrrjVs&
 
ÿÿÿ 
z!array_ufunc.<locals>._reconstructÚoutÚreducecss|]}t |¡VqdSr©ÚnpZasarrayr]rrrr`…scss|]}t|ddVqdS)T)Z extract_numpyNrr]rrrr`‹sÚ__call__)%Zpandas.core.framerUrVZpandas.core.genericrXZpandas.core.internalsrYr\Ú_standardize_out_kwargrrr{Zndarrayr[rhrZrtZ_HANDLED_TYPESrlÚzipruÚsetÚissubsetrsÚaxesÚ    enumerateÚunionÚdictZ _AXIS_ORDERSrrÚdispatch_ufunc_with_outÚdispatch_reduction_ufuncrkriZ_mgrÚapplyÚdefault_array_ufunc)rrQrRrSrTrUrVÚclsrnZno_deferÚitemZhigher_priorityZhas_array_ufuncÚtypesZ    set_typesrÚobjÚiZax1Zax2ÚnamesrgroZmgrr)    rYrXrjrvrRrfrwrrQrÚ array_ufuncýs‚  
þ
 
þ
 ÿ ý
 
ÿþ
 
 
 
 
&     
rr„)ÚreturncKs@d|kr<d|kr<d|kr<| 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)`
    rxÚout1Úout2)Úpop)rTr‘r’rxrrrr}Ÿs 
 
r})rQrRc
Os²| d¡}| dd¡}t||ƒ||Ž}|tkr2tSt|tƒr~t|tƒrVt|ƒt|ƒkrZt‚t||ƒD]\}}    t||    |ƒqd|St|tƒr¢t|ƒdkrž|d}nt‚t|||ƒ|S)zz
    If we have an `out` keyword, then call the ufunc without `out` and then
    set the result into the given `out`.
    rxÚwhereNrer)    r“rirrtrlrursr~Ú _assign_where)
rrQrRrSrTrxr”rnZarrÚresrrrr…®s"
 
 
 
 r…ÚNonecCs(|dkr||dd…<nt |||¡dS)zV
    Set a ufunc result into 'out', masking with a 'where' argument if necessary.
    N)r{Zputmask)rxrnr”rrrr•Ñsr•cs<t‡fdd„|Dƒƒst‚‡fdd„|Dƒ}t||ƒ||Ž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`.
    c3s|]}|ˆkVqdSrrr]©rrrr`äsz&default_array_ufunc.<locals>.<genexpr>cs"g|]}|ˆk    r|nt |¡‘qSrrzr]r˜rrrdçsz'default_array_ufunc.<locals>.<listcomp>)Úanyrsri)rrQrRrSrTZ
new_inputsrr˜rrˆÜsrˆcOs’|dks t‚t|ƒdks$|d|k    r(tS|jtkr6tSt|j}t||ƒsNtS|jdkrzt|tƒrjd|d<d|krzd|d<t    ||ƒfddi|—ŽS)z@
    Dispatch ufunc reductions to self's reduction methods.
    ryrerFZ numeric_onlyZaxisZskipna)
ÚAssertionErrorrurrMÚREDUCTION_ALIASESrhrrrtrri)rrQrRrSrTÚ method_namerrrr†ìs 
 
 
 
 
r†)Ú__doc__Ú
__future__rrÚtypingrÚnumpyr{Z pandas._libsrZpandas._libs.ops_dispatchrZpandas.core.dtypes.genericrZ pandas.corerZpandas.core.constructionr    Zpandas.core.ops.commonr
r›rrr}r…r•rˆr†rrrrÚ<module>s0        ü_##