zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
U
®ý°d#@ã@s|ddlmZmZddlZddlZddlZddlmZmZm    Z    m
Z
m Z m Z m Z mZddlmZGdd„dƒZGdd„dƒZdS)é©ÚdatetimeÚ    timedeltaN)Ú CategoricalÚ    DataFrameÚIndexÚSeriesÚ
date_rangeÚoption_contextÚ period_rangeÚtimedelta_rangec@sNeZdZdd„Zdd„Zdd„Zdd„Zej     d    d
d g¡d d „ƒZ
dd„Z dd„Z dd„Z dd„Zej     ddddddddddd d!g ¡d"d#„ƒZd$d%„Zej     d&d'd(g¡d)d*„ƒZd+d,„Zej     d-dd.gd/d0gg¡d1d2„ƒZd3d4„Zd5d6„Zd7d8„Zd9d:„Zd;d<„Zd=d>„Zd?d@„ZdAdB„ZdCdD„ZdEdF„ZdGdH„ZdIdJ„ZdKdL„Z dMdN„Z!d/S)OÚTestSeriesReprc CsT|}ttt|ƒƒ|dd}ddddddd    d
d d d dg }d |¡}t|ƒ|ksPt‚dS)NZsth©ÚindexÚnamez first  secondzfoo    one       0z       two       1z       three     2zbar    one       3z       two       4zbaz    two       5z       three     6zqux    one       7z       two       8z       three     9zName: sth, dtype: int64Ú
)rÚrangeÚlenÚjoinÚreprÚAssertionError)ÚselfZ%lexsorted_two_level_string_multiindexrÚserÚexpected©rúTd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/series/test_repr.pyÚtest_multilevel_name_prints"ô
z)TestSeriesRepr.test_multilevel_name_printcCs>tdddgƒ}d|_dt|ƒks$t‚d|_dt|ƒks:t‚dS)NrééÚtestú
Name: testúName:)rrrr©rÚsrrrÚtest_small_name_printing,s
z'TestSeriesRepr.test_small_name_printingcCs<ttdƒƒ}d|_dt|ƒks"t‚d|_dt|ƒks8t‚dS)Néèrr r!)rrrrrr"rrrÚtest_big_name_printing6s
 z%TestSeriesRepr.test_big_name_printingcCs(ttddƒdtd}dt|ƒks$t‚dS)NZ20010101Z20020101r)rrÚdtyper )rr    Úobjectrrr"rrrÚtest_empty_name_printing@sz'TestSeriesRepr.test_empty_name_printingÚargsr)réÿÿÿÿcCs&tttj d¡tjd|žŽdƒdS)Nr%©r)r%)ÚstrrÚnpÚrandomÚrandnÚarange)rr*rrrÚtest_float_rangeDszTestSeriesRepr.test_float_rangecCstttdƒdS)N©r')r-rr(©rrrrÚtest_empty_objectHsz TestSeriesRepr.test_empty_objectcCs0t|ƒt| t¡ƒtj|dd…<t|ƒdS)Néé)r-ÚastypeÚintr.ÚNaN)rÚ string_seriesrrrÚ test_stringLszTestSeriesRepr.test_stringcCs t|ƒdS©N)r-)rZ object_seriesrrrÚ test_objectTszTestSeriesRepr.test_objectcCs,t|ƒ| d¡}d|ddd…<t|ƒdS)NÚOr)r-r8r)rZdatetime_seriesZotsrrrÚ test_datetimeWs
zTestSeriesRepr.test_datetimerÚrg333333ó?ÚfoouαβγZ7loooooooooooooooooooooooooooooooooooooooooooooooooooong©rBÚbarZbaz)rr)rBrgffffff@)õαuβuγ)rErDcCs||_t|ƒdSr=)rr)rrr;rrrÚtest_various_names^sz!TestSeriesRepr.test_various_namescCs(ttj d¡t d¡dd}t|ƒdS)Nr%rCr)rr.r/r0r1r)rZbiggierrrÚtest_tuple_namess 
ÿzTestSeriesRepr.test_tuple_nameÚargédéécCs,ttj |¡dd}t|ƒ}d|ks(t‚dS)Nr©rzName: 0)rr.r/r0rr)rrHrZrep_strrrrÚtest_tidy_repr_name_0ysz$TestSeriesRepr.test_tidy_repr_name_0cCsFtdgddgd}dt|ƒks"t‚dt|ƒks2t‚dt|ƒksBt‚dS)Nza
    bza
    dza
    f)rrú    ú za
)rrr)rrrrrÚ test_newline€szTestSeriesRepr.test_newlinezname, expectedz#Series([], Name: foo, dtype: int64)NzSeries([], dtype: int64)cCs$tgtj|d}t|ƒ|ks t‚dS)N)r'r)rr.Úint64rr)rrrr#rrrÚtest_empty_int64†s    zTestSeriesRepr.test_empty_int64cCs tdgdƒ}d|_t|ƒdS)Nõאr%Ztitle1)rrr)rÚarrrÚtest_tidy_repr’szTestSeriesRepr.test_tidy_reprcCs8tdd„tdƒDƒƒ}t|ƒ| ¡}|jdks4t‚dS)NcSsg|]}ttj dd¡ƒ‘qS)r)rr.r/r0©Ú.0ÚirrrÚ
<listcomp>˜sz7TestSeriesRepr.test_repr_bool_fails.<locals>.<listcomp>r6rA)rrrZ
readouterrÚerrr)rZcapsysr#ZcapturedrrrÚtest_repr_bool_fails—sz#TestSeriesRepr.test_repr_bool_failscCs2tdddgt d¡d}t|ƒd|_t|ƒdS)NrrérK)rRrR)rr.rPrrr"rrrÚ!test_repr_name_iterable_indexable sz0TestSeriesRepr.test_repr_name_iterable_indexablecCs<ddddg}ddddg}t||d}t| ¡tkƒs8t‚dS)    Nér6r[uσuτuυuφr,)rÚtypeÚ__repr__r-r)rÚdataZindex1ÚdfrrrÚtest_repr_should_return_str©s   z*TestSeriesRepr.test_repr_should_return_strc    Cs*tddƒtttdƒƒƒW5QRXdS)Núdisplay.max_rowsrJ)r
r-rrr4rrrÚtest_repr_max_rows´s z!TestSeriesRepr.test_repr_max_rowscCstdgdd}t|ƒdS)NrRuבrK)rr-)rrarrrÚ test_unicode_string_with_unicode¹sz/TestSeriesRepr.test_unicode_string_with_unicodec    Cs8tdgdd}d}tjt|dt|ƒW5QRXdS)NÚabcrKz2^'str' object cannot be interpreted as an integer$)Úmatch)rÚpytestZraisesÚ    TypeErrorÚbytes)rraÚmsgrrrÚtest_str_to_bytes_raises½sz'TestSeriesRepr.test_str_to_bytes_raisescCsŽtdd„tdƒDƒtd}ttj t|ƒ¡|ƒ}t|ƒt     
d¡}t|ƒ  ¡d  d¡s\t ‚|jtj dt|ƒdd    ¡}t|ƒ  ¡ddS)
NcSs g|]}tdddƒt|ƒ‘qS)éÐrrrUrrrrXÆszDTestSeriesRepr.test_timeseries_repr_object_dtype.<locals>.<listcomp>r%r3r+zFreq:rri)rrr(rr.r/r0rrÚtmZmakeTimeSeriesÚ
splitlinesÚ
startswithrZilocÚrandint)rrÚtsZts2rrrÚ!test_timeseries_repr_object_dtypeÄsÿ
z0TestSeriesRepr.test_timeseries_repr_object_dtypec    CsZt d¡d}tddddƒ$tdddgƒ}|| ¡ks<t‚W5QRX| ¡dksVt‚dS)    NZjinja2zj\begin{tabular}{ll}
\toprule
 & 0 \\
\midrule
0 & $\alpha$ \\
1 & b \\
2 & c \\
\bottomrule
\end{tabular}
zstyler.format.escapezstyler.render.reprZlatexz$\alpha$ÚbÚc)rhZ importorskipr
rZ _repr_latex_r)rÚresultr#rrrÚtest_latex_reprÑs
 
ÿzTestSeriesRepr.test_latex_reprcCs6tdtjgƒ}tddg|d}d}t|ƒ|ks2t‚dS)Nrrr,z1.0    1
NaN    2
dtype: int64)rr.Únanrrr)rrWr#ÚexprrrÚ!test_index_repr_in_frame_with_nanåsz0TestSeriesRepr.test_index_repr_in_frame_with_nancCs.tdddd}| ¡td|d}t|ƒdS)Nz1/1/1850z1/1/1950zA-DEC)Úfreqrr,)r    Úformatrr)rÚrngrrrrrÚtest_format_pre_1900_datesís z)TestSeriesRepr.test_format_pre_1900_datescCs4tdddtjjgdd}t|ƒ}d}||ks0t‚dS)Nrr%rmzM8[ns]r3z‘0   1970-01-01 00:00:00.000000
1   1970-01-01 00:00:00.000001
2   1970-01-01 00:00:00.000002
3                          NaT
dtype: datetime64[ns])rÚpdÚNaTÚ_valuerr)rZseriesrvrrrrÚtest_series_repr_natós
ÿz#TestSeriesRepr.test_series_repr_natcCs(tdgƒ t¡}d}t|ƒ|ks$t‚dS)Ngð?z0    1.0
dtype: object)rr8r(rr)rrrrrrÚtest_float_reprszTestSeriesRepr.test_float_reprcCs:tddddgddtjtjgƒ}t|ƒ}d}||ks6t‚dS)Nrrr[éTz4True    1
None    2
NaN     3
NaT     4
dtype: int64)rr.rxrr€rr)rrrvrrrrÚtest_different_null_objectssz*TestSeriesRepr.test_different_null_objects)"Ú__name__Ú
__module__Ú __qualname__rr$r&r)rhÚmarkZ parametrizer2r5r<r>r@rFrGrLrOrQrTrZr\rbrdrerlrsrwrzr~r‚rƒr…rrrrr sf
 
 
õþ
 
þþ
           r c@s\eZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd d„Z    dd„Z
dd„Z dd„Z dS)ÚTestCategoricalReprcsLGdd„dƒ‰t‡fdd„tdƒDƒƒ}t|ƒ}| ¡}t|ƒt|ƒdS)Nc@s"eZdZdZdZedœdd„ZdS)zATestCategoricalRepr.test_categorical_repr_unicode.<locals>.CountyuSan SebastiánZPR)ÚreturncSs|jd|jS)Nz, )rÚstater4rrrr_szJTestCategoricalRepr.test_categorical_repr_unicode.<locals>.County.__repr__N)r†r‡rˆrrŒr-r_rrrrÚCountysrcsg|]
}ˆƒ‘qSrr)rVÚ_©rrrrXszETestCategoricalRepr.test_categorical_repr_unicode.<locals>.<listcomp>é=)rrrZ    to_seriesrr-)rÚcatÚidxrrrrÚtest_categorical_repr_unicodes z1TestCategoricalRepr.test_categorical_repr_unicodec    Csœttddddgƒƒ}d}|| ¡ks(t‚ttddgdƒƒ}d    }td
d ƒ|t|ƒks\t‚W5QRXtd ƒ}ttddg|d dƒ}d}|| ¡ks˜t‚dS)Nrrr[r„zO0    1
1    2
2    3
3    4
dtype: category
Categories (4, int64): [1, 2, 3, 4]rSrtézf0     a
1     b
     ..
48    a
49    b
Length: 50, dtype: category
Categories (2, object): ['a', 'b']rcr6ÚabcdefghijklmnopqrstuvwxyzT)Ú
categoriesÚorderedzh0    a
1    b
dtype: category
Categories (26, object): ['a' < 'b' < 'c' < 'd' ... 'w' < 'x' < 'y' < 'z'])rrÚ__str__rr
rÚlist)rrSryZlevsrrrÚtest_categorical_repr!sÿÿ ÿz)TestCategoricalRepr.test_categorical_reprcCs^ttdddgƒƒ}d}t|ƒ|ks&t‚ttt d¡ƒƒ}dt ¡j›d}t|ƒ|ksZt‚dS)Nrrr[zE0    1
1    2
2    3
dtype: category
Categories (3, int64): [1, 2, 3]é
úf0    0
1    1
2    2
3    3
4    4
5    5
6    6
7    7
8    8
9    9
dtype: category
Categories (10, z ): [0, 1, 2, 3, ..., 6, 7, 8, 9]©rrrrr.r1Úint_r'©rr#ryrrrÚtest_categorical_series_repr<s õ z0TestCategoricalRepr.test_categorical_series_reprcCsfttdddgddƒ}d}t|ƒ|ks*t‚ttt d¡ddƒ}dt ¡j›d    }t|ƒ|ksbt‚dS)
Nrrr[T©r—zG0    1
1    2
2    3
dtype: category
Categories (3, int64): [1 < 2 < 3]r›rœz$): [0 < 1 < 2 < 3 ... 6 < 7 < 8 < 9]rrŸrrrÚ$test_categorical_series_repr_orderedVs õ z8TestCategoricalRepr.test_categorical_series_repr_orderedcCsbtdddd}tt|ƒƒ}d}t|ƒ|ks.t‚tddddd}tt|ƒƒ}d}t|ƒ|ks^t‚dS)    Nú2011-01-01 09:00ÚHr6©r{Úperiodsa20   2011-01-01 09:00:00
1   2011-01-01 10:00:00
2   2011-01-01 11:00:00
3   2011-01-01 12:00:00
4   2011-01-01 13:00:00
dtype: category
Categories (5, datetime64[ns]): [2011-01-01 09:00:00, 2011-01-01 10:00:00, 2011-01-01 11:00:00,
                                 2011-01-01 12:00:00, 2011-01-01 13:00:00]ú
US/Eastern©r{r¦Útza³0   2011-01-01 09:00:00-05:00
1   2011-01-01 10:00:00-05:00
2   2011-01-01 11:00:00-05:00
3   2011-01-01 12:00:00-05:00
4   2011-01-01 13:00:00-05:00
dtype: category
Categories (5, datetime64[ns, US/Eastern]): [2011-01-01 09:00:00-05:00, 2011-01-01 10:00:00-05:00,
                                             2011-01-01 11:00:00-05:00, 2011-01-01 12:00:00-05:00,
                                             2011-01-01 13:00:00-05:00]©r    rrrr©rr’r#ryrrrÚ%test_categorical_series_repr_datetimeps      
z9TestCategoricalRepr.test_categorical_series_repr_datetimecCsjtdddd}tt|ddƒ}d}t|ƒ|ks2t‚tddddd    }tt|ddƒ}d
}t|ƒ|ksft‚dS) Nr£r¤r6r¥Tr¡a60   2011-01-01 09:00:00
1   2011-01-01 10:00:00
2   2011-01-01 11:00:00
3   2011-01-01 12:00:00
4   2011-01-01 13:00:00
dtype: category
Categories (5, datetime64[ns]): [2011-01-01 09:00:00 < 2011-01-01 10:00:00 < 2011-01-01 11:00:00 <
                                 2011-01-01 12:00:00 < 2011-01-01 13:00:00]r§r¨a·0   2011-01-01 09:00:00-05:00
1   2011-01-01 10:00:00-05:00
2   2011-01-01 11:00:00-05:00
3   2011-01-01 12:00:00-05:00
4   2011-01-01 13:00:00-05:00
dtype: category
Categories (5, datetime64[ns, US/Eastern]): [2011-01-01 09:00:00-05:00 < 2011-01-01 10:00:00-05:00 <
                                             2011-01-01 11:00:00-05:00 < 2011-01-01 12:00:00-05:00 <
                                             2011-01-01 13:00:00-05:00]rªr«rrrÚ-test_categorical_series_repr_datetime_orderedŒs    
zATestCategoricalRepr.test_categorical_series_repr_datetime_orderedcCs`tdddd}tt|ƒƒ}d}t|ƒ|ks.t‚tdddd}tt|ƒƒ}d}t|ƒ|ks\t‚dS)    Nr£r¤r6r¥a0    2011-01-01 09:00
1    2011-01-01 10:00
2    2011-01-01 11:00
3    2011-01-01 12:00
4    2011-01-01 13:00
dtype: category
Categories (5, period[H]): [2011-01-01 09:00, 2011-01-01 10:00, 2011-01-01 11:00, 2011-01-01 12:00,
                            2011-01-01 13:00]ú2011-01ÚMz™0    2011-01
1    2011-02
2    2011-03
3    2011-04
4    2011-05
dtype: category
Categories (5, period[M]): [2011-01, 2011-02, 2011-03, 2011-04, 2011-05]©r rrrrr«rrrÚ#test_categorical_series_repr_period¨s      z7TestCategoricalRepr.test_categorical_series_repr_periodcCshtdddd}tt|ddƒ}d}t|ƒ|ks2t‚tdd    dd}tt|ddƒ}d
}t|ƒ|ksdt‚dS) Nr£r¤r6r¥Tr¡a0    2011-01-01 09:00
1    2011-01-01 10:00
2    2011-01-01 11:00
3    2011-01-01 12:00
4    2011-01-01 13:00
dtype: category
Categories (5, period[H]): [2011-01-01 09:00 < 2011-01-01 10:00 < 2011-01-01 11:00 < 2011-01-01 12:00 <
                            2011-01-01 13:00]r®r¯z0    2011-01
1    2011-02
2    2011-03
3    2011-04
4    2011-05
dtype: category
Categories (5, period[M]): [2011-01 < 2011-02 < 2011-03 < 2011-04 < 2011-05]r°r«rrrÚ+test_categorical_series_repr_period_orderedÂs    z?TestCategoricalRepr.test_categorical_series_repr_period_orderedcCs\tddd}tt|ƒƒ}d}t|ƒ|ks,t‚tddd}tt|ƒƒ}d}t|ƒ|ksXt‚dS)Nú1 daysr6©r¦z0   1 days
1   2 days
2   3 days
3   4 days
4   5 days
dtype: category
Categories (5, timedelta64[ns]): [1 days, 2 days, 3 days, 4 days, 5 days]ú1 hoursr›aÍ0   0 days 01:00:00
1   1 days 01:00:00
2   2 days 01:00:00
3   3 days 01:00:00
4   4 days 01:00:00
5   5 days 01:00:00
6   6 days 01:00:00
7   7 days 01:00:00
8   8 days 01:00:00
9   9 days 01:00:00
dtype: category
Categories (10, timedelta64[ns]): [0 days 01:00:00, 1 days 01:00:00, 2 days 01:00:00,
                                   3 days 01:00:00, ..., 6 days 01:00:00, 7 days 01:00:00,
                                   8 days 01:00:00, 9 days 01:00:00]©r rrrrr«rrrÚ&test_categorical_series_repr_timedeltaÜs    z:TestCategoricalRepr.test_categorical_series_repr_timedeltacCsdtddd}tt|ddƒ}d}t|ƒ|ks0t‚tddd}tt|ddƒ}d    }t|ƒ|ks`t‚dS)
Nr³r6r´Tr¡z”0   1 days
1   2 days
2   3 days
3   4 days
4   5 days
dtype: category
Categories (5, timedelta64[ns]): [1 days < 2 days < 3 days < 4 days < 5 days]rµr›aÑ0   0 days 01:00:00
1   1 days 01:00:00
2   2 days 01:00:00
3   3 days 01:00:00
4   4 days 01:00:00
5   5 days 01:00:00
6   6 days 01:00:00
7   7 days 01:00:00
8   8 days 01:00:00
9   9 days 01:00:00
dtype: category
Categories (10, timedelta64[ns]): [0 days 01:00:00 < 1 days 01:00:00 < 2 days 01:00:00 <
                                   3 days 01:00:00 ... 6 days 01:00:00 < 7 days 01:00:00 <
                                   8 days 01:00:00 < 9 days 01:00:00]r¶r«rrrÚ.test_categorical_series_repr_timedelta_orderedüs  zBTestCategoricalRepr.test_categorical_series_repr_timedelta_orderedN) r†r‡rˆr“ršr r¢r¬r­r±r²r·r¸rrrrrŠs rŠ)rrÚnumpyr.rhZpandasrrrrrr    r
r r Zpandas._testingZ_testingrnr rŠrrrrÚ<module>s(
y