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
U
­ý°dôã@sJddlZddlZddlmZmZmZmZmZddl    m
Z Gdd„dƒZ dS)éN)Ú    DataFrameÚ PeriodIndexÚSeriesÚ
date_rangeÚ period_rangec@s”eZdZdd„Zdd„Zdd„Zej de    e
g¡dd    „ƒZ ej de    e
g¡d
d „ƒZ ej de    e
g¡d d „ƒZ ej de    e
g¡dd„ƒZdd„ZdS)ÚTestPeriodIndexcCsÞtdddddgdd}ttj t|ƒ¡|d}| ¡}|d}|dd    …}t ||¡d|dd…<|rtt ||¡n|dd    …dk     ¡sŒt
‚tdddddgdd}ttj t|ƒ¡|d}|d}||dk}t ||¡dS)
NiÐi×iÙzA-JUN©Úfreq©ÚindexZ2007éé) rrÚnpÚrandomZrandnÚlenÚcopyÚtmÚassert_series_equalÚallÚAssertionError)ÚselfZusing_copy_on_writeÚidxÚtsÚoriginalÚresultÚexpected©rúgd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/indexes/period/test_partial_slicing.pyÚ0test_getitem_periodindex_duplicates_string_slices    z@TestPeriodIndex.test_getitem_periodindex_duplicates_string_slicecCsJtdddddgdd}ttj t|ƒ¡|d ¡}|d    |d
ksFt‚dS) NZ2Q05Z3Q05Z4Q05Z1Q06Z2Q06ÚQrr
Z05Q4é)rrrrÚrandrZcumsumr)rÚpiÚserrrrÚ'test_getitem_periodindex_quarter_string&sz7TestPeriodIndex.test_getitem_periodindex_quarter_stringcCsjtdddd}ttj t|ƒ¡|d}|d}|dd…}t ||¡|d    }|dd
…}t ||¡dS) Nz1/1/10z12/31/12ÚM)ÚstartÚendr    r
Z2010ré Z2011é)rrrrr!rrr)rr"ÚsÚresÚexprrrÚtest_pindex_slice_index,s   z'TestPeriodIndex.test_pindex_slice_indexÚ
make_rangec
Cs|dddd}d}dddd    d
g}|D]*}tjt|d ||d…W5QRXq$ttj t|ƒ¡|d }t     |dd…|d d…¡t     |dd…|d d…¡t     |dd…|dd…¡t     |dd…|dd…¡d    d
g}|D]*}tjt|d ||d…W5QRXqädS)Nú
2013/01/01ÚDi©r&r    ÚperiodsúBslice indices must be integers or None or have an __index__ methodÚ2014ú2013/02ú
2013/01/02ú 2013/02/01 9Hú2013/02/01 09:00©Úmatchr
r z
2013/01/05ééim©
ÚpytestÚraisesÚ    TypeErrorrrrr!rrr)rr.rÚmsgÚvaluesÚvr*ÚinvalidrrrÚtest_range_slice_day6s(ûz$TestPeriodIndex.test_range_slice_dayc
Csú|dddd}d}dddd    d
g}|D]*}tjt|d ||d…W5QRXq$ttj t|ƒ¡|d }t     |d d…|dd…¡t     |dd…|dd…¡t     |dd…|dd…¡t     |dd…|dd…¡dD]}t     ||d…|¡qÜdS)Nz2013/01/01 09:00:00ÚSi r1r3r4r5r6r7r8r9r
z2013/01/01 09:05z2013/01/01 09:10i,i”z2013/01/01 10:00z2013/01/01 10:05iixz2013/01/01 10Hz2013/01/01 09:30iD)r/z2013/01Z2013r=)rr.rrArBrCr*ÚdrrrÚtest_range_slice_secondsTs$ûz(TestPeriodIndex.test_range_slice_secondscCsü|dddd}tddd„tdƒDƒi|d}tt|ƒgdd    dgd
}|d d ¡|d<t |d d …|¡t |d d…|jdd…¡t |dd…|jdd…¡t |dd …|¡t |dd…|¡t |dd…|¡t |dd…|¡dS)Nú
2013/10/01r0é
r1ÚunitscSsg|] }d|‘qS©édr©Ú.0ÚirrrÚ
<listcomp>tsz@TestPeriodIndex.test_range_slice_outofbounds.<locals>.<listcomp>r
r)r ÚcolumnsÚint64z
2013/09/01ú
2013/09/30z
2013/10/02r z
2013/10/15z
2013/10/17z2013-06z2013-09z2013-11z2013-12)rÚrangeÚtypeZastyperZassert_frame_equalZiloc)rr.rZdfÚemptyrrrÚtest_range_slice_outofboundsosz,TestPeriodIndex.test_range_slice_outofboundsc    Cs6|dddd}tddd„tdƒDƒi|d}t ||¡}d    t|ƒj›d
}tjt|d |     d d ¡W5QRXtjt|d | 
d d ¡W5QRXtjt|d |dd …W5QRXtjt|d |d d…W5QRXtjt|d |j dd …W5QRXtjt|d |j d d…W5QRXdS)NrIr0rJr1rKcSsg|] }d|‘qSrLrrNrrrrQ„sz?TestPeriodIndex.test_maybe_cast_slice_bound.<locals>.<listcomp>r
zcannot do slice indexing on z( with these indexers \[foo\] of type strr9ZfooÚleftrT) rrUrÚget_objrVÚ__name__r>r?r@Z_maybe_cast_slice_boundZget_slice_boundÚloc)rr.Zframe_or_seriesrÚobjrArrrÚtest_maybe_cast_slice_bound€s" ÿz+TestPeriodIndex.test_maybe_cast_slice_boundc Csztdddd}| d¡}tt d¡|d}ttdddƒƒttd    d
dƒƒ}||}|j}tjdd    dd d d dddddddg tj    d}||j
dk  ¡s˜t ‚||j
dk  ¡r°t ‚| d¡}t ||¡||}    |jd}t ||    ¡|d}t ||    ¡tjdgtj    d}
|dj
dkr*|djd ks.t ‚| d¡}t ||
¡||
}    |jd}t ||    ¡|d}t ||    ¡dS)Nz
2014-01-01éZ30D)r2r    r0r
rr r r<r ér;ééééééé)ZdtypeiÞr4éißzMay 2015)rZ    to_periodrrZarangeÚlistrUr ÚarrayZintpÚyearrrÚanyZget_locrZassert_numpy_array_equalr\rÚmonth) rZdtir"Z ser_montonicZshufflerr#ZnidxZ indexer_2014rrZindexer_may2015rrrÚ.test_partial_slice_doesnt_require_monotonicity›s8
 ÿ
 
  $
 
 z>TestPeriodIndex.test_partial_slice_doesnt_require_monotonicityN)r[Ú
__module__Ú __qualname__rr$r-r>ÚmarkZ parametrizerrrErHrXr^rnrrrrrs
 
 
 
 
r) Únumpyrr>ZpandasrrrrrZpandas._testingZ_testingrrrrrrÚ<module>s