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
U
¬ý°d;3ã@s¦UdZddlmZddlmZmZmZmZddlm    Z    ddl
m Z m Z ddl mZmZddlmZddlmZmZmZed    ed
ƒZGd d „d ƒZd d
iZeeddddZeeddddZdddœdd„Zdddœdd„Zdddœdd„ZiZded<ded <d!ed"<d
ed#<d
ed"<eed$ddd%Z iZ!d&ed'<de!d <d
e!d#<ee!d$ddd%Z"d(dd)œd*d+„Z#d d
iZ$d,ed-<ee$d.dd/dZ%ed0d1d2œd3d4„ƒZ&ed    d    d2œd5d4„ƒZ&d6d7d2œd8d4„Z&iZ'd,ed9<d
e'd:<d
e'd <ee'ddd;Z(ee'd<dddZ)dd=œd>d?„Z*iZ+d@edA<d
e+d:<d
e+d <dBe+dC<d
e+d <ee+dDdddZ,ee+dEdddZ-d
dBdFœZ.ee.dGdHZ/d
d
dBdIœZ0ee0dJdddZ1ee0dKdddZ2d#dLiZ3dMedN<ee3dOdddZ4d d
iZ5d,edP<ee5dQdddZ6d d
iZ7d,edR<ee7dSdddZ8iZ9dedT<de9d <d!e9d"<d
e9d#<ee9dUdGdVZ:iZ;dWedX<d
e;d:<d
e;d <e; <¡Z=d
e=d <dBe=dC<d
e=dY<e; <¡Z>d
e>d <dBe>dC<d
e>dY<e; <¡Z?dBe?dZ<dBe?dC<dBe;dC<ee;dGdHZ@ee=d[dddZAee>d\dddZBee;d]dddZCee?d^dddZDiZEd@ed_<d
eEd:<d
eEd <dBeEdC<eeEdGdHZFiZGd`eda<d
eGd <dbeGdc<eeGdddGdVZHdeddfœdgdh„ZIdid
iZJeeJdjdddZKdwd1d=œdkdl„ZLdmZMdnd1doœdpdq„ZNdxdrdsd1dtœdudv„ZOd
S)ya´
For compatibility with numpy libraries, pandas functions or methods have to
accept '*args' and '**kwargs' parameters to accommodate numpy arguments that
are not actually used or respected in the pandas implementation.
 
To ensure that users do not abuse these parameters, validation is performed in
'validators.py' to make sure that any extra parameters passed correspond ONLY
to those in the numpy signature. Part of that validation includes whether or
not the user attempted to pass in non-default values for these extraneous
parameters. As we want to discourage users from relying on these parameters
when calling the pandas implementation, we want them only to pass in the
default values for these parameters.
 
This module provides a set of commonly used default arguments for functions and
methods that are spread throughout the codebase. This module will make it
easier to adjust to future upstream changes in the analogous numpy signatures.
é)Ú annotations)ÚAnyÚTypeVarÚcastÚoverload)Úndarray)Úis_boolÚ
is_integer)ÚAxisÚAxisInt)ÚUnsupportedFunctionCall)Ú validate_argsÚvalidate_args_and_kwargsÚvalidate_kwargsÚ    AxisNoneTNc@s0eZdZd    dddœdd„Zd
dddœdd„ZdS) ÚCompatValidatorNz
str | NoneÚNone©ÚmethodÚreturncCs||_||_||_||_dS©N)ÚfnamerÚdefaultsÚmax_fname_arg_count)Úselfrrrr©rúSd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/compat/numpy/function.pyÚ__init__0szCompatValidator.__init__cCs |s|rœ|dkr|jn|}|dkr(|jn|}|dkr:|jn|}|dkrXt||||jƒnD|dkrpt|||jƒn,|dkrŒt|||||jƒntd|›dƒ‚dS)NÚargsÚkwargsÚbothzinvalid validation method 'ú')rrrr rrrÚ
ValueError)rrrrrrrrrÚ__call__<s(ÿýÿzCompatValidator.__call__)NNN)NNN)Ú__name__Ú
__module__Ú __qualname__rr#rrrrr/sûúrÚoutZargminr é)rrrZargmaxzbool | ndarray | Noneztuple[bool, Any])ÚskipnarcCs(t|tƒs|dkr |f|}d}||fS)NT)Ú
isinstancer)r)rrrrÚprocess_skipnabs
r+ÚboolcCst||ƒ\}}t||ƒ|S)a
    If 'Series.argmin' is called via the 'numpy' library, the third parameter
    in its signature is 'out', which takes either an ndarray or 'None', so
    check if the 'skipna' parameter is either an instance of ndarray or is
    None, since 'skipna' itself should be a boolean
    )r+Úvalidate_argmin©r)rrrrrÚvalidate_argmin_with_skipnajs
r/cCst||ƒ\}}t||ƒ|S)a
    If 'Series.argmax' is called via the 'numpy' library, the third parameter
    in its signature is 'out', which takes either an ndarray or 'None', so
    check if the 'skipna' parameter is either an instance of ndarray or is
    None, since 'skipna' itself should be a boolean
    )r+Úvalidate_argmaxr.rrrÚvalidate_argmax_with_skipnavs
r1zdict[str, int | str | None]ÚARGSORT_DEFAULTSéÿÿÿÿÚaxisZ    quicksortÚkindÚorderZargsort)rrrzdict[str, int | None]ÚARGSORT_DEFAULTS_KINDzbool | int | None)Ú    ascendingrcCs:t|ƒs|dkr|f|}d}t||ddtt|ƒ}|S)a!
    If 'Categorical.argsort' is called via the 'numpy' library, the first
    parameter in its signature is 'axis', which takes either an integer or
    'None', so check if the 'ascending' parameter has either integer type or is
    None, since 'ascending' itself should be a boolean
    NTé)r)r    Úvalidate_argsort_kindrr,)r8rrrrrÚvalidate_argsort_with_ascending—s 
 
r;zdict[str, Any]Ú CLIP_DEFAULTSZclipr9rr)r4rcCsdSrr©r4rrrrrÚvalidate_clip_with_axis­sr>cCsdSrrr=rrrr>²szndarray | AxisNoneTzAxisNoneT | NonecCs&t|tƒr|f|}d}t||ƒ|S)a
    If 'NDFrame.clip' is called via the numpy library, the third parameter in
    its signature is 'out', which can takes an ndarray, so check if the 'axis'
    parameter is an instance of ndarray, since 'axis' itself should either be
    an integer or None
    N)r*rÚ validate_clipr=rrrr>·s
    
 
 
ÚCUM_FUNC_DEFAULTSZdtype)rrZcumsum)rcCs(t|ƒs|f|}d}t|||d|S)zÛ
    If this function is called via the 'numpy' library, the third parameter in
    its signature is 'dtype', which takes either a 'numpy' dtype or 'None', so
    check if the 'skipna' parameter is a boolean or not
    T)r)rÚvalidate_cum_func)r)rrÚnamerrrÚvalidate_cum_func_with_skipna×s
 
rCzdict[str, bool | None]ÚALLANY_DEFAULTSFÚkeepdimsÚallÚany)r'rEr)r)r4r'rEÚminÚmaxÚCzdict[str, str]ÚRESHAPE_DEFAULTSZreshapeÚREPEAT_DEFAULTSÚrepeatÚROUND_DEFAULTSÚroundÚ SORT_DEFAULTSÚsort)rrzdict[str, Any | None]ÚSTAT_FUNC_DEFAULTSÚinitialZoverwrite_inputÚsumÚprodÚmeanZmedianÚSTAT_DDOF_FUNC_DEFAULTSzdict[str, str | None]Ú TAKE_DEFAULTSÚraiseÚmodeZtakezndarray | bool | None)ÚconvertrcCs4t|tƒs|dkr |f|}d}t||ddd|S)zî
    If this function is called via the 'numpy' library, the third parameter in
    its signature is 'axis', which takes either an ndarray or 'None', so check
    if the 'convert' parameter is either an instance of ndarray or is None
    NTr9r )rr)r*rÚ validate_take)r[rrrrrÚvalidate_take_with_convert?s
 
r]ZaxesZ    transposecCsD|dkr g}t|ƒt|ƒ}t|ƒt|ƒdkr@td|›dƒ‚dS)zª
    'args' and 'kwargs' should be empty, except for allowed kwargs because all
    of their necessary parameters are explicitly listed in the function
    signature
    Nrz?numpy operations are not valid with groupby. Use .groupby(...).ú
() instead)ÚsetÚlenr )rBrrÚallowedrrrÚvalidate_groupby_funcSs
ÿrb)rHrIrTrUrVZstdÚvarÚstrrcCs8t|ƒt|ƒdkr4|tkr,td|›dƒ‚tdƒ‚dS)z‹
    'args' and 'kwargs' should be empty because all of their necessary
    parameters are explicitly listed in the function signature
    rzAnumpy operations are not valid with resample. Use .resample(...).r^ztoo many arguments passed inN)r`ÚRESAMPLER_NUMPY_OPSr Ú    TypeError)rrrrrrÚvalidate_resampler_funchs 
ÿrgzAxisInt | NoneÚint)r4ÚndimrcCs<|dkr dS||ks(|dkr8||dkr8td|›dƒ‚dS)a
    Ensure that the axis argument passed to min, max, argmin, or argmax is zero
    or None, as otherwise it will be incorrectly ignored.
 
    Parameters
    ----------
    axis : int or None
    ndim : int, default 1
 
    Raises
    ------
    ValueError
    Nrz4`axis` must be fewer than the number of dimensions (ú))r")r4rirrrÚvalidate_minmax_axisvsrk)N)r()PÚ__doc__Ú
__future__rÚtypingrrrrÚnumpyrZpandas._libs.librr    Zpandas._typingr
r Z pandas.errorsr Zpandas.util._validatorsr rrrrZARGMINMAX_DEFAULTSr-r0r+r/r1r2Ú__annotations__Zvalidate_argsortr7r:r;r<r?r>r@rAZvalidate_cumsumrCrDZ validate_allZ validate_anyZLOGICAL_FUNC_DEFAULTSZvalidate_logical_funcZMINMAX_DEFAULTSZ validate_minZ validate_maxrKZvalidate_reshaperLZvalidate_repeatrNZvalidate_roundrPZ validate_sortrRÚcopyZ SUM_DEFAULTSZ PROD_DEFAULTSZMEDIAN_DEFAULTSZvalidate_stat_funcZ validate_sumZ validate_prodZ validate_meanZvalidate_medianrWZvalidate_stat_ddof_funcrXr\r]ZTRANSPOSE_DEFAULTSZvalidate_transposerbrergrkrrrrÚ<module>s€    *ÿÿ  ÿ ÿÿ ÿÿ ÿÿ
  ÿÿÿÿÿ   ÿÿÿÿ   ÿ