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
U
­ý°dF ã@sLdZddlmZddlZddlZddlmZmZm    Z    ddl
m Z ddl mZmZmZdddd    d
d d d ddg
Zd gZejdd„ƒZejdd„ƒZejdd„ƒZej de¡ej dddg¡ej dddg¡ej dddg¡dd„ƒƒƒƒZdd „Zd!d"„Zd#d$„Zej d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6g¡d7d8„ƒZd9d:„Zd;d<„ZdS)=zV
test methods relating to generic function evaluation
the so-called white/black lists
é)Úascii_lowercaseN)Ú    DataFrameÚSeriesÚ
date_range)Úgroupby_other_methodsÚreduction_kernelsÚtransformation_kernelsÚsumÚprodÚminÚmaxÚmedianÚmeanÚskewÚstdÚvarÚsemc
CsBtddddddddgddddddddgtj d¡tj d¡dœƒS)NÚfooÚbarZoneZtwoZthreeé)ÚAÚBÚCÚD)rÚnpÚrandomZrandn©rrúZd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/groupby/test_allowlist.pyÚdf&s
 
üÿrcCsRt ttƒ¡}d}| tj dd|¡¡}t|dttj |¡ƒt|ƒdœƒ}|S)Né
ré)ÚfloatsÚletters)    rÚarrayÚlistrÚtakerÚrandintrr)r"ÚNZrandom_lettersrrrrÚ
df_letters2sþÿr(cCs
tdgƒS)Nr)rrrrrÚ    raw_frame@sr)ÚopÚaxiséÚskipnaTFÚsortc    sЈdkr|}n|j}ˆtkrx|jdˆ|d}t|ˆƒˆd}|jdd ‡‡‡fdd„¡}|rj|jˆd}t ||¡nT|jdˆ|d}t|ˆƒƒ}|jdd ‡‡fdd„¡}|rÀ|jˆd}t ||¡dS)    Nr)Úlevelr+r.)r-©r/cst|ˆƒˆˆdS)N)r+r-©Úgetattr©Úh©r+r*r-rrÚ<lambda>Vóz3test_regression_allowlist_methods.<locals>.<lambda>©r+cst|ˆƒˆdS)Nr8r1r3)r+r*rrr6^r7)ÚTÚAGG_FUNCTIONS_WITH_SKIPNAÚgroupbyr2ÚapplyZ
sort_indexÚtmÚassert_frame_equal)    r)r*r+r-r.ÚframeZgroupedÚresultÚexpectedrr5rÚ!test_regression_allowlist_methodsEs$ ÿ   rBc CsÖ|}|j}ddddddddd    d
d d d g }dd„t|ƒDƒ}| |¡|D]ˆ}||fD]z}| |j¡}dt|ƒ›dt|ƒj›d}dt|ƒj›dt|ƒ›d}    |›d|    ›}
tj    t
|
dt ||ƒW5QRXqTqHdS)NÚevalÚqueryÚabsÚwhereÚmaskZalignr;ZclipZastypeÚatÚcombineZ consolidateZconvert_objectscSsg|]}| d¡r|‘qS)Úto_©Ú
startswith)Ú.0ÚmethodrrrÚ
<listcomp>ws
z*test_groupby_blocklist.<locals>.<listcomp>z (?:^Cannot.+z.+'z!'.+try using the 'apply' method$)z(?:^'z' object has no attribute z$)ú|)Úmatch) r!ÚdirÚextendr;r"ÚreprÚtypeÚ__name__ÚpytestZraisesÚAttributeErrorr2) r(rÚsZ    blocklistZ
to_methodsÚblÚobjÚgbZdefined_but_not_allowedZ not_definedÚmsgrrrÚtest_groupby_blocklistds8ó
  ÿÿr^cBCs¶|jdd}dd„t|ƒDƒ}ddddd    d
d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFhB}||ks²t‚dS)GNÚsecondr0cSsh|]}| d¡s|’qS©Ú_rK)rMÚvrrrÚ    <setcomp>’s
z&test_tab_completion.<locals>.<setcomp>rrrZaggZ    aggregater<ZboxplotÚfilterÚfirstZ    get_groupÚgroupsÚhistÚindicesÚlastr rr r ZngroupsZnthÚohlcZplotr
Úsizerr    Z    transformrrÚcountZnuniqueÚheadÚdescribeÚcummaxÚquantileÚrankÚcumprodÚtailÚresampleÚcumminÚfillnaZcumsumZcumcountZngroupÚallÚshiftrr%Ú
pct_changeÚanyÚcorrZcorrwithZcovÚdtypesÚndimÚdiffÚidxmaxÚidxminÚffillÚbfillZrollingZ    expandingÚpipeÚsampleZewmZ value_counts)r;rRÚAssertionError)ÚmframeÚgrpÚresultsrArrrÚtest_tab_completionsŒ ¾Dr‰cCs2|jdd}dD]}t||ƒ}|j|kst‚qdS)Nr_r0)r    r
r r reri)r;r2rVr…)r†r‡ÚnameÚfrrrÚtest_groupby_function_renameÚs 
rŒrNrlr{rorurrrnrqrpr~rxrwrzr€rrr‚rycCsdtdt|ƒd}||_| dg¡dg}|dg |d¡}t||ƒƒ}t||ƒƒ}t ||¡dS)NÚ2014©Zperiodsrr)rÚlenÚindexr;r2r=r>)rrNÚrngÚgÚg_expÚresÚexprrrÚ#test_groupby_selection_with_methodsás  r–cCsðtdt|ƒd}d|j_||_| dg¡dg}|dg |d¡}t | d¡| d¡¡t |j    |j    ¡t | 
dd„¡| 
dd„¡¡t |  d    ¡  ¡|  d    ¡  ¡¡t |  d    ¡  ¡|  d    ¡  ¡¡t | d
d„¡| d
d„¡¡dS) NrrŽrrrrcSs| ¡S)N)r    ©Úxrrrr6r7z6test_groupby_selection_other_methods.<locals>.<lambda>rcSs t|ƒdkS)Né)rr—rrrr6r7)rrÚcolumnsrŠrr;r=r>rvr|r<rtrrjrd)rr‘r’r“rrrÚ$test_groupby_selection_other_methodss    ÿr›cCsÀ| |jdd…df¡}dd„t|ƒDƒt|jƒ}t|ƒ}|t8}|t8}|t8}tt@r`t‚tt@rlt‚tt@rxt‚|rd|›d}t|ƒ‚ttBtB}||kr¼d||›d}t|ƒ‚dS)NrcSsh|]}| d¡s|’qSr`rK)rMrarrrrcs
z/test_all_methods_categorized.<locals>.<setcomp>z?
There are uncategorized methods defined on the Grouper class:
aG.
 
Was a new method recently added?
 
Every public method On Grouper must appear in exactly one the
following three lists defined in pandas.core.groupby.base:
- `reduction_kernels`
- `transformation_kernels`
- `groupby_other_methods`
see the comments in pandas/core/groupby/base.py for guidance on
how to fix this test.
        zI
Some methods which are supposed to be on the Grouper class
are missing:
z‡.
 
They're still defined in one of the lists that live in pandas/core/groupby/base.py.
If you removed a method, you should update them
)    r;ZilocrRÚsetršrrrr…)r†r‡ÚnamesZ    new_namesr]Zall_categorizedrrrÚtest_all_methods_categorizeds(   þ ýrž) Ú__doc__ÚstringrÚnumpyrrWZpandasrrrZpandas._testingZ_testingr=Zpandas.core.groupby.baserrrZ AGG_FUNCTIONSr:Zfixturerr(r)ÚmarkZ parametrizerBr^r‰rŒr–r›ržrrrrÚ<module>sp  ö 
 
 
 ,Jïþ