zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
U
­ý°dºQã@svddlZddlZddlZddlmZmZmZmZddl    m
Z
ej ddgddgedddd„dddd    d
d
d
d d g    e  dddd    d
d
d
d d g    ¡e eed ƒdddd    d
d
d
d d g    ƒƒed    d    d    d    d    d
d
d
d
g    ƒed    d    d    d    d    d
d
d
d
g    ƒed d d d d d d d d g    ƒgg
ddd„ƒZej ddgddd„ƒZej ddddg¡dd„ƒZej dddg¡dd„ƒZej dddg¡ej dejejg¡dd„ƒƒZej ddddg¡d d!„ƒZej dddg¡d"d#„ƒZej dddg¡ej dejejg¡d$d%„ƒƒZej ddddg¡d&d'„ƒZej dddg¡d(d)„ƒZej dddg¡ej dejejg¡d*d+„ƒƒZej ddddg¡d,d-„ƒZd.d/„Z dS)0éN)Ú CategoricalÚ    DataFrameÚGrouperÚSeries)Úget_groupby_method_argsÚaÚb)ÚkeycCs|dS)Né©©Úxr r úWd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/groupby/test_raises.pyÚ<lambda>órér
éé    é)ÚparamscCs|jS©N©Úparam©Úrequestr r rÚbysrTFcCs|jSrrrr r rÚgroupby_series%srÚhowÚmethodÚaggÚ    transformc    #CsÖtdddddddddg    dddddddddg    tdƒtdƒdœƒ}t||ƒ}|j|d}|rz|d    }|d
krzt|d
ƒrvt‚dSd d d td fd d ttfd fttfdfttfdfttfdftdfd d d tdftdfd d tdftdfd d d tdftdftdfd t    dfd d tdft    dfd tdfdœ"|\}}|dkrr|dkrDt
||ƒ|Žn,|dkr`|j |f|žŽn|j |f|žŽn`t j||dL|dkrœt
||ƒ|Žn,|dkr¸|j |f|žŽn|j |f|žŽW5QRXdS)Nrr
rrrÚ    xyzwtyuio©rrÚcÚd©rr$Úcorrwith©NÚzCould not convertzH(function|cummax) is not (implemented|supported) for (this|object) dtypezH(function|cummin) is not (implemented|supported) for (this|object) dtypezI(function|cumprod) is not (implemented|supported) for (this|object) dtypezH(function|cumsum) is not (implemented|supported) for (this|object) dtypeúunsupported operand typez#'argmax' not allowed for this dtypez#'argmin' not allowed for this dtypeú.Could not convert xy?z?w?t?y?u?i?o? to numericz!could not convert string to floatz0can't multiply sequence by non-int of type 'str'z,cannot be performed against 'object' dtypes!©"ÚallÚanyZbfillr&ÚcountZcumcountZcummaxZcumminZcumprodZcumsumZdiffZffillZfillnaÚfirstZidxmaxZidxminÚlastÚmaxÚmeanZmedianÚminZngroupZnuniqueZ
pct_changeÚprodZquantileZrankZsemÚshiftÚsizeZskewZstdÚsumÚvarrr©Úmatch)rÚrangeÚlistrÚgroupbyÚhasattrÚAssertionErrorÚ    TypeErrorÚNotImplementedErrorÚ
ValueErrorÚgetattrrr ÚpytestÚraises©    rrrÚ groupby_funcÚdfÚargsÚgbÚklassÚmsgr r rÚtest_groupby_raises_string*sŽüÿ
 þþþþÒ/Ñ1
 
 
 
 
rMc CsŠtdddddddddg    dddddddddg    tdƒtdƒdœƒ}|j|d}|rV|d    }d
d „}tjtd d t||ƒ|ƒW5QRXdS)Nrr
rrrr!r"r%r$cSs tdƒ‚dS©NúTest error message©r@r r r rÚfuncsz,test_groupby_raises_string_udf.<locals>.funcrOr9)rr;r<r=rDrEr@rC©rrrrHrJrQr r rÚtest_groupby_raises_string_udf€süÿ rSÚgroupby_func_npc Cs¶tdddddddddg    dddddddddg    tdƒtdƒdœƒ}|j|d}|rV|d    }tjd
tjtd fi|\}}|dkrŠt||ƒ|ƒn(t    j
||d t||ƒ|ƒW5QRXdS) Nrr
rrrr!r"r%r$r'r*r9) rr;r<r=Únpr7r2r@rCrDrE©rrrrTrHrJrKrLr r rÚtest_groupby_raises_string_np–s*üÿ þýrWc    #Cs¬tdddddddddg    dddddddddg    tdƒt dddddd    d
¡d œƒ}t||ƒ}|j|d }|rˆ|d }|dkrˆt|dƒr„t‚dSdddtdfddddtdftdfdddddddddddddtdftdfdddddtdfdtdfddœ"|\}}|dkrH|dkrt||ƒ|Žn,|dkr6|j    |f|žŽn|j
|f|žŽn`t j ||dL|dkrrt||ƒ|Žn,|dkrŽ|j    |f|žŽn|j
|f|žŽW5QRXdS)Nrr
rrréÕé
ééé`=r"r%r$r&r'z+cannot perform __mul__ with this index typez3datetime64 type does not support cumprod operationsz2datetime64 type does not support cumsum operationsz/cannot perform __truediv__ with this index typez%datetime64 type does not support prodz1dtype datetime64\[ns\] does not support reductionú/datetime64 type does not support sum operationsr+rrr9) rr;Údatetimerr=r>r?r@rCrr rDrErFr r rÚtest_groupby_raises_datetime³s~üÿ
 Þ#Ý%
 
 
 
 
r_c Cs˜tdddddddddg    dddddddddg    tdƒt dddddd    d
¡d œƒ}|j|d }|rd|d }dd„}tjtddt||ƒ|ƒW5QRXdS)Nrr
rrrrXrYrZr[r\r"r%r$cSs tdƒ‚dSrNrPr r r rrQ sz.test_groupby_raises_datetime_udf.<locals>.funcrOr9)rr;r^r=rDrEr@rCrRr r rÚ test_groupby_raises_datetime_udfýsüÿ     r`c CsÄtdddddddddg    dddddddddg    tdƒt dddddd    d
¡d œƒ}|j|d }|rd|d }tjtdftjdi|\}}|dkr˜t||ƒ|ƒn(t    j
||dt||ƒ|ƒW5QRXdS)Nrr
rrrrXrYrZr[r\r"r%r$r]r'r9) rr;r^r=rUr7r@r2rCrDrErVr r rÚtest_groupby_raises_datetime_nps*üÿ þýrac
#Csþtdddddddddg    dddddddddg    tdƒtdddddddddg    dddd    gd
d d œƒ}t||ƒ}|j|d }|rš|d    }|dkršt|dƒr–t‚dSdddtdfddttfdfttfdfttfdfttfdftdfd|sætdfnddddddtdftdfdddtdftdftdfdt    dfddtdft    dftdftdfd œ"|\}}    |dkrš|d!krlt
||ƒ|Žn,|d"krˆ|j |f|žŽn|j |f|žŽn`t j||    d#L|d!krÄt
||ƒ|Žn,|d"krà|j |f|žŽn|j |f|žŽW5QRXdS)$Nrr
rrrrrr#r$T©Ú
categoriesZorderedr"r%r&r'ú=unsupported operand type\(s\) for \*: 'Categorical' and 'int'zz(category type does not support cummax operations|category dtype not supported|cummax is not supported for category dtype)zz(category type does not support cummin operations|category dtype not supported|cummin is not supported for category dtype)z|(category type does not support cumprod operations|category dtype not supported|cumprod is not supported for category dtype)zz(category type does not support cumsum operations|category dtype not supported|cumsum is not supported for category dtype)zDunsupported operand type\(s\) for -: 'Categorical' and 'Categorical'úSCannot setitem on a Categorical with a new category \(0\), set the categories firstúC'Categorical' with dtype category does not support reduction 'mean'úE'Categorical' with dtype category does not support reduction 'median'zDunsupported operand type\(s\) for /: 'Categorical' and 'Categorical'ú.category type does not support prod operationszNo matching signature foundú#Cannot cast object dtype to float64úC'Categorical' with dtype category does not support reduction 'skew'ú-category type does not support sum operationsúB'Categorical' with dtype category does not support reduction 'var'r+rrr9)rr;rrr=r>r?r@rArBrCrr rDrE)
rrrrGÚusing_copy_on_writerHrIrJrKrLr r rÚtest_groupby_raises_category1s¼
ýüÿ
 þþþþþþûþþþþþþ²R®T
 
 
 
 
rncCsªtdddddddddg    dddddddddg    tdƒtdddddddddg    dddd    gd
d d œƒ}|j|d }|rv|d    }dd„}tjtddt||ƒ|ƒW5QRXdS)Nrr
rrrrrr#r$Trbr"r%cSs tdƒ‚dSrNrPr r r rrQÅsz.test_groupby_raises_category_udf.<locals>.funcrOr9)rr;rr=rDrEr@rCrRr r rÚ test_groupby_raises_category_udf±s"
ýüÿ rocCsÚtdddddddddg    dddddddddg    tdƒtdddddddddg    dddd    gd
d d œƒ}|j|d }|rv|d    }tjtdftjtdfi|\}}|dkr®t||ƒ|ƒn(t    j
||dt||ƒ|ƒW5QRXdS)Nrr
rrrrrr#r$Trbr"r%rkrfr9) rr;rr=rUr7r@r2rCrDrErVr r rÚtest_groupby_raises_category_npÌs6
ýüÿ þþúrpc #CsHttdddddddddg    ddddgdddddddddddg    td    ƒtdddddddddg    ddddgddd
œƒ}t||ƒ}|j||d }|r®|d}|d kr®t|d ƒrªt‚dStd d„|j     ¡Dƒƒ}    dddt
dfddt t
fdft t
fdft t
fdft t
fdft
dfd|st
dfndd|    r&t dfnd|    r6t dfndddt
dft
dfdddt
dft
dft
dfdt dfddt
dft dft
dft
d fd!œ"|\}
} |
dkrä|d"kr¶t ||ƒ|Žn,|d#krÒ|j|f|žŽn|j|f|žŽn`tj|
| d$L|d"krt ||ƒ|Žn,|d#kr*|j|f|žŽn|j|f|žŽW5QRXdS)%Nrrr#r$Trbrrrr")rÚobservedr&css|] }|jVqdSr)Úempty)Ú.0Úgroupr r rÚ    <genexpr>sz;test_groupby_raises_category_on_category.<locals>.<genexpr>r'rdzz(cummax is not supported for category dtype|category dtype not supported|category type does not support cummax operations)zz(cummin is not supported for category dtype|category dtype not supported|category type does not support cummin operations)z|(cumprod is not supported for category dtype|category dtype not supported|category type does not support cumprod operations)zz(cumsum is not supported for category dtype|category dtype not supported|category type does not support cumsum operations)r)rez*attempt to get argmax of an empty sequencez*attempt to get argmin of an empty sequencerfrgrhr(rirjrkrlr+rrr9)rrr;rr=r>r?r-ÚgroupsÚvaluesr@rArBrCrr rDrE) rrrrGrqrmrHrIrJZ empty_groupsrKrLr r rÚ(test_groupby_raises_category_on_categoryðsÆ
ý
ýøÿ
þþþþþûþÿ ÿ þþþþ´P°R
 
 
 
 
rxc    CsJtdgdgdgdœƒ}|jddd}tjtdd|d    W5QRXdS)
Nrr
r)rrr#r)Zaxisz'Cannot subset columns when using axis=1r9r)rr=rDrErB)rHrJr r rÚ%test_subsetting_columns_axis_1_raisestsry)!r^ÚnumpyrUrDZpandasrrrrZpandas.tests.groupbyrZfixtureÚarrayÚdictÚzipr;rrÚmarkZ parametrizerMrSr7r2rWr_r`rarnrorprxryr r r rÚ<module>sZ "2öÿ
 
 
U
 
I
 

 "