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
U
­ý°dõIã@snddlmZddlZddlmZddlZddlZddlm    Z    m
Z
m Z m Z m Z mZddlmZGdd„dƒZdS)é)ÚabcN)ÚParser)ÚCategoricalDtypeÚ    DataFrameÚ
MultiIndexÚSeriesÚ    TimestampÚ
date_rangec@s–eZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    dd„Z
dd„Z dd„Z dd„Z ej diejjddgdej›dfdej›dfdej›dfdgd fdd!iejjddgdej›dfdej›dfdej›dfdgd fd"ej›d#iejjd$d%gdej›dfdej›d#fdej›d#fd&ej›d#fgd fd'ej›d(iejjd)d*gdej›d(fdej›dfdej›dfdgd fd"eiejjd$d%gdej›dfdej›d+fdej›d+fd&ej›d+fgd fd"e d,¡iejjd$d%gdej›dfdej›d+fdej›d+fd&ej›d+fgd fd"ejejej›d-d.œiejjd$d%gdej›dfd/dej›d0fd&ej›d-fgd fd'd1d2iiejjddgd3dej›dfdej›dfdgd fd4ej›d-d5œejjd6d7gdej›dfdej›dfdgd fd'd2d8d9œiejjddgd3dej›dfdej›dfdgd fd"ejejd:œiejjd$d%gdej›dfd/dej›d0fdgd fd"e d;¡e d8¡d:œiejjd$d%gdej›dfd/dej›d0fdgd fejejd:œej›d-d<œejjd$d%gdej›d-fd/dej›d0fdgd fd4gd=œed>ffd4d?d@d:œd=œedAffd4d?edBdCgƒd:œd=œedDffd4d?dEd:œd=œedFffg¡dGdH„ƒZej dIedJdKdLgdMd@dNgdOdPdQggedRƒdS  dBdCg¡dTd?d;dUœd<œejjdVdWdXgdBej›dYfdZd[ej›dfgd fedJdKdLgdMd@dNgdOdPdQgge! "d\d]d^g¡dSej›d(d8d_œd8d<œejjd`dadbgdej›d0fdcej›d(fddej›dfdeej›d0fgd fedJdKdLgdMd@dNgdOdPdQgge!j"d\d]d^gedfƒdge!j"dhdidjgedkƒdgdldTej›d-d;dUœd<œejjdmdndogd[ej›d-fdpdcej›dfddej›dfdeej›dfgd fg¡dqdr„ƒZ#dsdt„Z$ej dudvdwdxg¡dydz„ƒZ%d{S)|ÚTestDataFrameToRecordscCsTtddd}ttj dd¡|dddgd}| ¡}|d    jd
ksDt‚|jd d }dS) Nz1/1/2000é
©ÚperiodséÚaÚbÚc)ÚindexÚcolumnsrúM8[ns]F©r)r    rÚnpÚrandomÚrandnÚ
to_recordsÚdtypeÚAssertionError)ÚselfrÚdfÚresult©rúad:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/frame/methods/test_to_records.pyÚtest_to_records_timeseriess
 z1TestDataFrameToRecords.test_to_records_timeseriescCsNtdddgdddggtddƒd    }|jjd
}| ¡d d
}||ksJt‚dS) NÚoneÚtwoZthreeZfourZfiveÚsixú
2012-01-01ú
2012-01-02rrr)rr    rÚvaluesrr©rrÚexpectedrrrr Útest_to_records_dt64sþ z+TestDataFrameToRecords.test_to_records_dt64cCs`tdtddddiƒ}| ¡}|jdtks0t‚|dd}t|tƒsJt‚||jdks\t‚dS)    NÚAr%r&ú
US/Eastern)Útzré)rr+)    rr    rrÚobjectrÚ
isinstancerÚloc)rrrÚvalrrr Útest_to_records_dt64tz_column's  z4TestDataFrameToRecords.test_to_records_dt64tz_columnc    Csjddddddddgddddddddgg}t d¡}t||d}|jd    dd
}d|ksZt‚d|ksft‚dS) NÚbarZbazÚfooZquxr"r#)éérTZlevel_0)rÚzerosrrr)rrÚdatarÚrrrr Útest_to_records_with_multindex2sþ
  z5TestDataFrameToRecords.test_to_records_with_multindexcsBtj tjj¡tƒ d¡}t     |g¡‰t
‡fdd„dDƒƒdS)NzbFrom: <user@example.com>
To: <someone_else@example.com>
Subject: Test message
 
Body would go here
c3s|]}|ˆkVqdS©Nr)Ú.0Úx©Úframerr Ú    <genexpr>JszKTestDataFrameToRecords.test_to_records_with_Mapping_type.<locals>.<genexpr>)ÚTypeÚSubjectÚFrom) rÚMappingÚregisterÚemailÚmessageÚMessagerÚparsestrrZ from_recordsÚall)rÚheadersrr?r Ú!test_to_records_with_Mapping_type>s ÿ z8TestDataFrameToRecords.test_to_records_with_Mapping_typecCsttj dd¡ƒ}| ¡dS)Nr )rrrZrandr)rrrrr Útest_to_records_floatsLsz-TestDataFrameToRecords.test_to_records_floatsc    sttj dd¡ƒ‰dˆj_ˆ ¡}d|jjks2t    ‚ttj dd¡ƒ‰ˆ ¡}d|jjks\t    ‚t
  dddg¡ˆ_ddgˆj_ ˆ ¡}tj jt ddd    g¡t d
d d g¡g‡fd d„tdƒDƒdddddgddtj›dtj›dtj›dgdœd}t ||¡dS)NrÚXr)rr>)rÚy)rÚzr+rrr>rPrQcs$g|]}t ˆjdd…|f¡‘qSr<)rZasarrayZiloc)r=Úi©rrr Ú
<listcomp>_szETestDataFrameToRecords.test_to_records_index_name.<locals>.<listcomp>Zlevel_1Ú0Ú1Ú2ÚOÚf8©ÚnamesÚformats©r)rrrrrÚnamerrÚfieldsrrÚ from_tuplesr[ÚrecZ
fromarraysÚarrayÚrangeÚtmÚENDIANÚassert_numpy_array_equal)rÚrsrr)rrSr Útest_to_records_index_namePs0 ÿ 
 
 
ûþýz1TestDataFrameToRecords.test_to_records_index_namecCs@tdddœgƒ d¡ ¡}tjjdgddgd}t ||¡dS)    Nr>rP)rrr)r>rP)rrX)rrXr])rÚ    set_indexrrrarbrdÚassert_almost_equal©rrr)rrr Ú"test_to_records_with_unicode_indexmsz9TestDataFrameToRecords.test_to_records_with_unicode_indexcCsÂttdddtdddtddddœƒ}tjjddgdtj›dfd    tj›dfd
tj›dfgd }|jd d }t ||¡|     d¡jdd }t ||¡|     ddg¡jdd }t ||¡dS)Nú
2022-01-01ér )r.rnr)rmrmrm)ú
2022-01-02rororVrrWÚ3r]Frr.T)
rr    rrarbrdrerrjrir(rrr Útest_to_records_index_dtypets*
 
 
ýÿþýû   z2TestDataFrameToRecords.test_to_records_index_dtypecCsDtddgid ¡}tjjdgddgddgdœd    }t ||¡dS)
Nuaccented_name_éçð?)r9)rrrrú=i8z=f8rZr])rrrrarbrdrjrkrrr Ú)test_to_records_with_unicode_column_names“s þz@TestDataFrameToRecords.test_to_records_with_unicode_column_namescCsštdtdƒidd}ttdƒddd}t |d|¡ttdƒdd}ttdƒddd}t |d|¡| ¡}tjjddd    gd
d gd}t     ||¡dS) Nr+rÚcategoryr])rr^r)rr)r.r)rnr)rrs)rUrX)
rÚlistrrdZassert_series_equalrrrarbrjr(rrr Ú test_to_records_with_categorical¡sÿz7TestDataFrameToRecords.test_to_records_with_categoricalzkwargs,expected)rr.皙™™™™É?r)r.rnçø?ÚbcrÚi8r+ÚBrY©ÚCrXr]TÚ column_dtypesZU4©rUrVz0.2r©rVrWz1.5rzr~Ú index_dtypesZU1)rUr.rxr)rVrnryrzÚUÚunicodeÚU2©r+r|r~©r+Úi1Úf4rÚint16)rÚi2F)rr‚)r.rxr)rnryrzÚfloat32)rz    not-there©r+r|Úint8©rr‚)rrz)Invalid dtype \[\] specified for column AÚint32éz&Invalid dtype 5 specified for column Brrz-Invalid dtype category specified for column Br5z$data type ["']foo["'] not understoodc    Csttddgddgddgdœƒ}t|tjƒsXtj|d|dd    |jf|ŽW5QRXn|jf|Ž}t ||¡dS)
Nr.rnrxryrrzr†r)Úmatch)    rr0rZrecarrayÚpytestZraisesrrdrj)rÚkwargsr)rrrrr Útest_to_records_dtype¶sO  z,TestDataFrameToRecords.test_to_records_dtypezdf,kwargs,expectedr.rnrr7éér6é    r)rÚfloat64)rr.)r.rnç@)r7r‘ç@)r—r6ç"@Úi4)rrˆr)rÚd)rÚe)rÚf)rrn)grVrnrš)rrÚ4r‘r›)ç@Ú7r6rœz
('a', 'd')z
('b', 'e')z
('c', 'f')Úab)r[)ržéüÿÿÿ)ržéûÿÿÿ)r éúÿÿÿZcd)rr)ržr¥rrr¢rš)ržr¦g@g@r›)r r§r—r6rœ)ržrˆcCs|jf|Ž}t ||¡dSr<)rrdrj)rrr”r)rrrr Útest_to_records_dtype_misJ z/TestDataFrameToRecords.test_to_records_dtype_micCsœGdd„dƒ}tddgddgddgd    œƒ}|ftjtjd
œŽtj›d d œ}|jf|Ž}tjjd dgdtj›d fddtj›dfdgd}t     ||¡dS)Nc@s8eZdZddœdd„Zdd„Zedœdd„Zd    d
„ZdS) zBTestDataFrameToRecords.test_to_records_dict_like.<locals>.DictLikeN)Úreturnc[s| ¡|_dSr<)Úcopyrž)rr”rrr Ú__init__ÝszKTestDataFrameToRecords.test_to_records_dict_like.<locals>.DictLike.__init__cSs |j |¡Sr<)ržÚ __getitem__©rÚkeyrrr r¬àszNTestDataFrameToRecords.test_to_records_dict_like.<locals>.DictLike.__getitem__cSs
||jkSr<)ržr­rrr Ú __contains__ãszOTestDataFrameToRecords.test_to_records_dict_like.<locals>.DictLike.__contains__cSs
|j ¡Sr<)ržÚkeys)rrrr r°æszGTestDataFrameToRecords.test_to_records_dict_like.<locals>.DictLike.keys)Ú__name__Ú
__module__Ú __qualname__r«r¬Úboolr¯r°rrrr ÚDictLikeÜsrµr.rnrxryrrzr†rr…rr€rrr‡r|r‰r}r])
rrrŽrŒrdrerrarbrj)rrµrZdtype_mappingsrr)rrr Útest_to_records_dict_likeÚs 
þ üþ    z0TestDataFrameToRecords.test_to_records_dict_liker-ÚUTCÚGMTr,cCsFtddd|d}td|i|d}| ¡}| d¡ ¡}t ||¡dS)Nz
2016-01-01r ÚS)r Úfreqr-Údatetimerr·)r    rrZ
tz_convertrdrf)rr-Zdrrr)rrrr Ú%test_to_records_datetimeindex_with_tzüs
z<TestDataFrameToRecords.test_to_records_datetimeindex_with_tzN)&r±r²r³r!r*r3r;rMrNrhrlrqrtrwr“ÚmarkZ parametrizerrarbrdreÚstrrrŽrŒÚ
ValueErrorrÚ    TypeErrorr•rrvrirr`r¨r¶r¼rrrr r
sØ    
  üþþüþþüþþüþþüþþ üþþ
ýÿüþø
üþþýþþ üþþüþþüþþ 
þüþûþþþû    þ€¼þM
ÿþýþûÿþþüþõÿÿû
þýûúòÙþH
"r
)Ú collectionsrrGÚ email.parserrÚnumpyrr“Zpandasrrrrrr    Zpandas._testingZ_testingrdr
rrrr Ú<module>s