gL ivddlZddlZddlZddlmZddlmZejjdddgdZ ejjddd gd Z d Z d Zd Zejjddd gdZdZdZejjdej&ej(gejjdddideigdZdZdZdZdZdZdZy)N)Serieszoperation, expected)mina)maxbcRtddgd}t||}||k(sJy)Nrrstringdtype)rgetattr) operationexpectedserres_operation_series i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pandas/tests/series/test_reductions.pytest_reductions_series_stringsr s4 #s8 ,C1'#y13 ( ** * as_periodTFc rttddDcgc]}tjdd|c}}|r|jj d}n|jj d}|j}|j|jk(sJtj||ycc}w)NiDz US/Central) rrangepd Timestampdt to_period tz_localizemoder tmassert_series_equal)rnrress rtest_mode_extension_dtyper%s E!QK@q",,tQ*@ ACffs#ff  . ((*C 99 !! !3$AsB4c ztdddtjddtjg|}|jd}tddtjg|}t j |||jd}tddg|}t j ||tj|d<|jd}tddg|}t j |||jd}ttjg|}t j ||y) Nrr F)dropnaT)rrNAr r!r")any_numeric_ea_dtyperresultrs rtest_mode_nullable_dtyper. s !Q255!Q.6J KC XXUX #Fq!RUUm+?@H68, XXTX "Fq!f$89H68,eeCG XXTX "Fq!f$89H68, XXUX #Fruug%9:H68,rctjdtddgt}t j dd5|j }dddtddgt}tj|y#1swY3xYw)Npyarrowrrr zfuture.infer_stringT) pytest importorskiprobjectroption_contextr r!r")rr-rs rtest_mode_infer_stringr56sq  " #s6 *C  0$ 7sCj/H68,s BB ctdtjgd}|d}|j|k(sJ|j |k(sJ|j |k(sJy)Nrzm8[ns]r )rrNaTmedianrr)rexps rtest_reductions_td64_with_natr:@s[ !RVVH -C a&C ::<3   779   779  rskipnactgd}|j|}t|tjsJ|tjdk(sJy)Nztimedelta64[ns]r )r;r)rsum isinstancer Timedelta)r;rr-s rtest_td64_sum_emptyr@IsK , -C WWFW #F fbll ++ + R\\!_ $$ $rcttjddd}|dxxtjdz cc<||j z j }tjtj ||j z jt|z j}tj|jdz |jdz sJd}tjt| 5||j z jddd|dd }tjt| 5||j z jddd|dd}||j z jy#1swYzxYw#1swY)rr-s rtest_prod_numpy16_bugrZls0 a 1C XXZF&&)) ))rfunckwargskeepdimsoutctddg}tt|}|j}d|d|d}t j t |5||fi|dddy#1swYyxYw)Nrr(zthe 'z=' parameter is not supported in the pandas implementation of z\(\)rF)rnextiter__name__r1rPrQ)r\r[rparamnamerRs r)test_validate_any_all_out_keepdims_raisesressy !Q.C f E ==D w"V4 ) z - SFs  A%%A.ctddg}d}tjt|5t j |ddddy#1swYyxYw)Nrr(zPthe 'initial' parameter is not supported in the pandas implementation of sum\(\)rF )initialrr1rPrQrMr=rrRs rtest_validate_sum_initialrksL !Q.C % z -  sB   A  Actddg}d}tjt|5|j ddddy#1swYyxYw)Nrr(z[the 'overwrite_input' parameter is not supported in the pandas implementation of median\(\)rFT)overwrite_input)rr1rPrQr8rjs rtest_validate_median_initialrosN !Q.C ( z -) 4 ()))s AActddg}d}tjt|5t j |ddddy#1swYyxYw)Nrr(zQthe 'keepdims' parameter is not supported in the pandas implementation of sum\(\)rFT)r]rirjs rtest_validate_stat_keepdimsrqsL !Q.C % z -# sT"###rlcttddg}|jdk(sJd}tjt|5|j ddd|j }|sd}tjt|5|j dddy#1swYRxYw#1swYyxYw)N1212zHCould not convert string '12' to numeric|does not support|Cannot performrFzECould not convert \['12'\] to numeric|does not support|Cannot perform)rr=r1rP TypeErrorrIto_frame)using_array_managerusing_infer_stringrrRdfs r(test_mean_with_convertible_string_raisesr{s #s C 779   TC y ,   B V y ,    sB"B."B+.B7ctjdddg}|rd}nd}tjt|5|j dddtjt|5|j ddddd}tjt|5|d j dddd }tjt|5tj |d jd jdddy#1swYxYw#1swYxYw#1swYyxYw#1swYyxYw) NJ{)dbnumericz'Could not convert string 'J' to numericzDCould not convert \['J'\] to numeric|does not support|Cannot performrFrIzGCould not convert string 'J' to numeric|does not support|Cannot performrzECould not convert string 'J' to numeric|ufunc 'divide'|Cannot performr ) r DataFramer1rPrvrIaggrMastypearray)rxrzrRs r#test_mean_dont_convert_j_to_complexrs cc23 4B7U y ,   y , v TC y , 4  QC y ,1 4)//01111s/D0D''D3 2D?D$'D03D<?EcJd}tgd}tjt|5|j ddd|sd}|j }tjt|5|j dddy#1swYRxYw#1swYyxYw)NzICannot convert \['1' '2' '3'\] to numeric|does not support|Cannot perform)rsrt3rFzMCannot convert \[\['1' '2' '3'\]\] to numeric|does not support|Cannot perform)rr1rPrvr8rw)rxrRrrzs r*test_median_with_convertible_string_raisesrs VC  !C y ,     B y , sB 3B BB")numpyrMr1pandasrrpandas._testing_testingr!mark parametrizerr%r.r5r:r@rUrZanyallr3rerkrorqr{rrrrrs& .|0LM+N+tUm4 %5 %-,-D%=1%2%2*"&&"&&!12Z$68I#JK L3   )#  1*r