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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
U
¬ý°d¶6ã@sÈddlmZddlmZmZddlmZddlZddlmZm    Z    m
Z
m Z m Z m Z mZmZmZmZmZddlZddlZddlmZmZddlmZddlmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+dd    l,m-Z-m.Z.dd
l/m0Z0dd l1m2Z2dd l3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAdd lBmCZDddlEmFZFmGZGmHZHddlImJZJmKZKmLZLddlMmNZNddlOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^ddl_m`Z`maZaddlbmcZcmdZdddlemfZfmgZgddlhmiZimjZjmkZkddllmmZmmnZnmoZoddlpmqZqddlrmsZsddltmuZumvZvddlwmxZxddlymzZzddl{m|Z|ddl}m~mZ€ddlm‚Zƒm„Z„m…Z…ddl†m‡Z‡mˆZˆddl‰mŠZŠdd l‹mŒZŒmZdd!lŽmZeràdd"lm‘Z‘m’Z’m“Z“ee6efZ”ed#d$d%Z•d&d&d'œd(d)„Z–Gd*d$„d$eseuƒZ—Gd+d,„d,e—ƒZ˜d-Z™d.Zšd/Z›d0Zœed1d2d%ZGd3d2„d2e—ƒZžd4d5d6œd7d8„ZŸed9d9d:œd;d<„ƒZ ed=d>d:œd?d<„ƒZ d@dAd:œdBd<„Z dCdDœdEdF„Z¡dGdH„Z¢dId5dJœdKdL„Z£dS)Mé)Ú annotations)ÚdatetimeÚ    timedelta)ÚwrapsN) Ú TYPE_CHECKINGÚAnyÚCallableÚIteratorÚLiteralÚSequenceÚTypeVarÚUnionÚcastÚfinalÚoverload)ÚalgosÚlib)Ú NDArrayBacked)Ú
BaseOffsetÚIncompatibleFrequencyÚNaTÚNaTTypeÚPeriodÚ
ResolutionÚTickÚ    TimedeltaÚ    TimestampÚastype_overflowsafeÚdelta_to_nanosecondsÚget_unit_from_dtypeÚiNaTÚints_to_pydatetimeÚints_to_pytimedeltaÚ    to_offset)ÚRoundToÚ round_nsint64)Úcompare_mismatched_resolutions)Úinteger_op_not_supported)Ú    ArrayLikeÚAxisIntÚDatetimeLikeScalarÚDtypeÚDtypeObjÚFÚNpDtypeÚPositionalIndexer2DÚPositionalIndexerTupleÚ ScalarIndexerÚSequenceIndexerÚ TimeAmbiguousÚTimeNonexistentÚnpt)Úfunction)ÚAbstractMethodErrorÚInvalidComparisonÚPerformanceWarning)ÚAppenderÚ SubstitutionÚcache_readonly)Úfind_stack_level)Úis_all_stringsÚis_categorical_dtypeÚis_datetime64_any_dtypeÚis_datetime64_dtypeÚis_datetime64tz_dtypeÚis_datetime_or_timedelta_dtypeÚis_dtype_equalÚis_float_dtypeÚis_integer_dtypeÚ is_list_likeÚis_object_dtypeÚis_period_dtypeÚis_string_dtypeÚis_timedelta64_dtypeÚ pandas_dtype)ÚDatetimeTZDtypeÚExtensionDtype)ÚABCCategoricalÚ ABCMultiIndex)Úis_valid_na_for_dtypeÚisna)Ú
algorithmsÚnanopsÚops)Úchecked_add_with_arrÚisinÚunique1d)Údatetimelike_accumulations)ÚOpsMixin)ÚNDArrayBackedExtensionArrayÚ ravel_compat)ÚArrowExtensionArray)ÚExtensionArray)Ú IntegerArray)ÚarrayÚensure_wrapped_if_datetimelikeÚ extract_array)Úcheck_array_indexerÚcheck_setitem_lengths)Úunpack_zerodim_and_defer)Úinvalid_comparisonÚmake_invalid_op)Ú frequencies)Ú DatetimeArrayÚ PeriodArrayÚTimedeltaArrayÚDatetimeLikeArrayTÚDatetimeLikeArrayMixin)Úboundr-)ÚmethÚreturncstˆƒ‡fdd„ƒ}tt|ƒS)zâ
    For PeriodArray methods, dispatch to DatetimeArray and re-wrap the results
    in PeriodArray.  We cannot use ._ndarray directly for the affected
    methods because the i8 data has different semantics on NaT values.
    csjt|jƒsˆ|f|ž|ŽS| d¡}ˆ|f|ž|Ž}|tkr@tSt|tƒrV| |j¡S| d¡}| |¡S)NzM8[ns]Úi8)    rIÚdtypeÚviewrÚ
isinstancerÚ    _box_funcÚ_valueÚ_from_backing_data)ÚselfÚargsÚkwargsÚarrÚresultZres_i8©ro©úVd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/arrays/datetimelike.pyÚnew_meth©s
 
 
 
z"_period_dispatch.<locals>.new_meth)rrr-)ror€r~r}rÚ_period_dispatch¢srcsâeZdZUdZded<ded<ded<ded    <d
ed <ed d œdd„ƒZdödd ddœdd„Zedd œdd„ƒZ    dddœdd„Z
dddœd d!„Z ddd"œd#d$„Z d%d&„Z dd œd'd(„Zd)d œd*d+„Zed,d œd-d.„ƒZd/dd0œd1d2d3œd4d5„Zd÷d d6œd7d8„Zdød9dd:œd;d<„Zed=dd>œd?d@„ƒZedAdBdAdCœdDd@„ƒZdAdEdFdGœ‡fdHd@„ Zd
d œdIdJ„ZdKdLddMœ‡fdNdO„ Zdd œdPdQ„Zdùd dSœ‡fdTdU„ ZedAdAdVœdWdX„ƒZedYdZd:œd[dX„ƒZed\d]d:œd^dX„ƒZedúdd`d:œdadX„ƒZdûdd`d:œ‡fdbdX„ ZedüdddedfdAdgœ‡fdhdi„ ƒZdýdAddAdkœ‡fdldm„ Zdndo„ZddRdpœd d dpœdqdr„Zdþd ddsœdtdu„Z dÿd dvœdwdx„Z!dydz„Z"e#d{d œd|d}„ƒZ$e%d~d„ƒZ&d€d œdd‚„Z'd€d œdƒd„„Z(ed€d œd…d†„ƒZ)ed d œd‡dˆ„ƒZ*e+dfddd‰œdŠd‹„Z,edŒd œddŽ„ƒZ-edŒd œdd„ƒZ.ed‘d œd’d“„ƒZ/edd œd”d•„ƒZ0ed d œd–d—„ƒZ1ed d œd˜d™„ƒZ2ed d œdšd›„ƒZ3dœd„Z4e5džƒZ6e5dŸƒZ7e5d ƒZ8e5d¡ƒZ9e5d¢ƒZ:e5d£ƒZ;e5d¤ƒZ<e5d¥ƒZ=e5d¦ƒZ>e5d§ƒZ?e5d¨ƒZ@e5d©ƒZAe#dªd œd«d¬„ƒZBe#d
d œd­d®„ƒZCe#dZd œd¯d°„ƒZDe#dZdZd"œd±d²„ƒZEe#d³d´œdµd¶„ƒZFe#dZd´œd·d¸„ƒZGe#d¹d]d"œdºd»„ƒZHe#d¼d½d"œd¾d¿„ƒZIdÀdÁ„ZJdÂdÄZKd]d´œdÄdńZLe#dÆd´œdÇdȄƒZMe#dÉdʄƒZNe#dËd̄ƒZOe#dÍd2d"œdÎdτƒZPe#d2d´œdÐdфƒZQdRdҜdd dӜdÔdՄZReSdփd×d؄ƒZTdÙdڄZUeSdۃdÜd݄ƒZVdÞd߄ZWdAdAdVœdàdá„ZXdAdAdVœdâdã„ZYeZdAdäddAd圇fdædç„ ƒZ[eZddRdèœdéd dèœdêd넃Z\eZddRdèœdéd dèœdìd턃Z]dRdcdîœd dédîœdïdð„Z^eZddRdèœdéd dèœdñdò„ƒZ_dd dóœdôdõ„Z`‡ZaS(rmzÈ
    Shared Base/Mixin class for DatetimeArray, TimedeltaArray, PeriodArray
 
    Assumes that __new__/__init__ defines:
        _ndarray
 
    and that inheriting subclass implements:
        freq
    ztuple[str, ...]Ú_infer_matcheszCallable[[DtypeObj], bool]Ú_is_recognized_dtypeztuple[type, ...]Ú_recognized_scalarsz
np.ndarrayÚ_ndarrayzBaseOffset | NoneÚfreqÚbool©rpcCsdS)NTr~©rxr~r~rÚ _can_hold_naÍsz#DatetimeLikeArrayMixin._can_hold_naNFz Dtype | NoneÚNone)rrÚcopyrpcCs t|ƒ‚dS©N©r7)rxÚdatarrr†rŒr~r~rÚ__init__ÑszDatetimeLikeArrayMixin.__init__ztype[DatetimeLikeScalar]cCs t|ƒ‚dS)z£
        The scalar associated with this datelike
 
        * PeriodArray : Period
        * DatetimeArray : Timestamp
        * TimedeltaArray : Timedelta
        NrŽr‰r~r~rÚ _scalar_typeÖs    z#DatetimeLikeArrayMixin._scalar_typeÚstrÚ DTScalarOrNaT)ÚvaluerpcCs t|ƒ‚dS)ay
        Construct a scalar type from a string.
 
        Parameters
        ----------
        value : str
 
        Returns
        -------
        Period, Timestamp, or Timedelta, or NaT
            Whatever the type of ``self._scalar_type`` is.
 
        Notes
        -----
        This should call ``self._check_compatible_with`` before
        unboxing the result.
        NrŽ©rxr”r~r~rÚ_scalar_from_stringász*DatetimeLikeArrayMixin._scalar_from_stringz)np.int64 | np.datetime64 | np.timedelta64cCs t|ƒ‚dS)ad
        Unbox the integer value of a scalar `value`.
 
        Parameters
        ----------
        value : Period, Timestamp, Timedelta, or NaT
            Depending on subclass.
 
        Returns
        -------
        int
 
        Examples
        --------
        >>> self._unbox_scalar(Timedelta("10s"))  # doctest: +SKIP
        10000000000
        NrŽr•r~r~rÚ _unbox_scalarõsz$DatetimeLikeArrayMixin._unbox_scalar)ÚotherrpcCs t|ƒ‚dS)a|
        Verify that `self` and `other` are compatible.
 
        * DatetimeArray verifies that the timezones (if any) match
        * PeriodArray verifies that the freq matches
        * Timedelta has no verification
 
        In each case, NaT is considered compatible.
 
        Parameters
        ----------
        other
 
        Raises
        ------
        Exception
        NrŽ©rxr˜r~r~rÚ_check_compatible_with sz-DatetimeLikeArrayMixin._check_compatible_withcCs t|ƒ‚dS)zI
        box function to get object from internal representation
        NrŽ)rxÚxr~r~rru!sz DatetimeLikeArrayMixin._box_funccCstj||jddS)z1
        apply box func to passed values
        F)Úconvert)rZ    map_inferru)rxÚvaluesr~r~rÚ _box_values'sz"DatetimeLikeArrayMixin._box_valuesr    cs<ˆjdkr$‡fdd„ttˆƒƒDƒS‡fdd„ˆjDƒSdS)Néc3s|]}ˆ|VqdSrr~)Ú.0Únr‰r~rÚ    <genexpr>/sz2DatetimeLikeArrayMixin.__iter__.<locals>.<genexpr>c3s|]}ˆ |¡VqdSr)ru)r Úvr‰r~rr¢1s)ÚndimÚrangeÚlenÚasi8r‰r~r‰rÚ__iter__-s
zDatetimeLikeArrayMixin.__iter__znpt.NDArray[np.int64]cCs |j d¡S)z‘
        Integer representation of the values.
 
        Returns
        -------
        ndarray
            An ndarray with int64 dtype.
        rq)r…rsr‰r~r~rr§3s zDatetimeLikeArrayMixin.asi8r)Úna_repÚ date_formatz str | floatúnpt.NDArray[np.object_])r©rpcCs t|ƒ‚dS)z|
        Helper method for astype when converting to strings.
 
        Returns
        -------
        ndarray[str]
        NrŽ)rxr©rªr~r~rÚ_format_native_typesCs
z+DatetimeLikeArrayMixin._format_native_types)ÚboxedcCsdjS)Nz'{}')Úformat)rxr­r~r~rÚ
_formatterOsz!DatetimeLikeArrayMixin._formatterzNpDtype | None©rrrpcCs t|ƒrtjt|ƒtdS|jS)N©rr)rHÚnpr`ÚlistÚobjectr…©rxrrr~r~rÚ    __array__Vsz DatetimeLikeArrayMixin.__array__r1)ÚitemrpcCsdSrr~©rxr·r~r~rÚ __getitem__\sz"DatetimeLikeArrayMixin.__getitem__rlz(SequenceIndexer | PositionalIndexerTuple)rxr·rpcCsdSrr~r¸r~r~rr¹`sr/z"DatetimeLikeArrayT | DTScalarOrNaT)rxÚkeyrpcs:tdtƒ |¡ƒ}t |¡r |Stt|ƒ}| |¡|_|S)z’
        This getitem defers to the underlying array, which by-definition can
        only handle list-likes, slices, and integer scalars
        z(Union[DatetimeLikeArrayT, DTScalarOrNaT])rÚsuperr¹rÚ    is_scalarrlÚ_get_getitem_freqÚ_freq)rxrºr|©Ú    __class__r~rr¹gs
 
ÿ
 
 cCs¬t|jƒ}|r|j}n’|jdkr&d}n‚t||ƒ}d}t|tƒrh|jdk    r`|jdk    r`|j|j}q¨|j}n@|tkrx|j}n0t     
|¡r¨t   |  tj¡¡}t|tƒr¨| |¡S|S)z\
        Find the `freq` attribute to assign to the result of a __getitem__ lookup.
        rŸN)rIrrr†r¤rcrtÚsliceÚstepÚEllipsisÚcomZis_bool_indexerrZmaybe_booleans_to_slicersr²Zuint8r½)rxrºZ    is_periodr†Znew_keyr~r~rr½|s$
 
 
 
 
 
 
z(DatetimeLikeArrayMixin._get_getitem_freqz,int | Sequence[int] | Sequence[bool] | slicezNaTType | Any | Sequence[Any])rºr”rpcs.t|||ƒ}tƒ ||¡|r"dS| ¡dSr)rdr»Ú __setitem__Ú_maybe_clear_freq)rxrºr”Zno_opr¿r~rrŚs
z"DatetimeLikeArrayMixin.__setitem__cCsdSrr~r‰r~r~rrưsz(DatetimeLikeArrayMixin._maybe_clear_freqT©rŒcs4t|ƒ}t|ƒrv|jjdkrDtd|ƒ}|j}t||jd|jd}|S|jjdkr^t    |j
ddS|  |j  ¡¡  |j¡St|tƒrtƒj||dSt|ƒr | ¡St|ƒrà|j}|tjkrÐtd    |j›d
|›d ƒ‚|rÜ| ¡}|St|ƒrøt|j|ƒrt|ƒr"d t|ƒj›d |›}t|ƒ‚ntj||dSdS)NÚMriÚ    timestamp)ÚtzÚboxZresoÚmT)rËrÇzConverting from z to z? is not supported. Do obj.astype('int64').astype(dtype) insteadz Cannot cast z
 to dtype r±) rLrHrrÚkindrr§r!rÊÚ_cresor"r…ržÚravelÚreshapeÚshapertrNr»ÚastyperJr¬rFr²Úint64Ú    TypeErrorrŒrCrDrEÚtypeÚ__name__Úasarray)rxrrrŒZi8dataZ    convertedrÚmsgr¿r~rrÒµsJ 
ü 
 
ÿÿ
þý
zDatetimeLikeArrayMixin.astype)rxrpcCsdSrr~r‰r~r~rrsëszDatetimeLikeArrayMixin.viewzLiteral['M8[ns]']ricCsdSrr~rµr~r~rrsïszLiteral['m8[ns]']rkcCsdSrr~rµr~r~rrsós.r(cCsdSrr~rµr~r~rrs÷scs tƒ |¡Sr)r»rsrµr¿r~rrsüsrútype[DatetimeLikeArrayT]zSequence[DatetimeLikeArrayT]r))ÚclsÚ    to_concatÚaxisrpcs¦tƒ ||¡}|d‰ˆj}d}t|ƒr0ˆj}nl|dkrœdd„|Dƒ}ˆjdk    rœt‡fdd„|Dƒƒrœt|dd…|dd…ƒ}t‡fdd„|Dƒƒrœˆj}||_|S)    NrcSsg|]}t|ƒr|‘qSr~)r¦©r r›r~r~rÚ
<listcomp>sz<DatetimeLikeArrayMixin._concat_same_type.<locals>.<listcomp>c3s|]}|jˆjkVqdSr©r†rÝ©Úobjr~rr¢sz;DatetimeLikeArrayMixin._concat_same_type.<locals>.<genexpr>éÿÿÿÿrŸc3s,|]$}|ddˆj|ddkVqdS)rrârŸNrß)r Úpairràr~rr¢s)r»Ú_concat_same_typerrrIr†ÚallÚzipr¾)rÚrÛrÜÚnew_objrrÚnew_freqÚpairsr¿ràrräs z(DatetimeLikeArrayMixin._concat_same_typeÚC)rxÚorderrpcstƒj|d}|j|_|S)N)rë)r»rŒr†r¾)rxrërçr¿r~rrŒszDatetimeLikeArrayMixin.copyc
Cs.t|tƒr:z| |¡}Wn ttfk
r8t|ƒ‚YnXt||jƒsN|tkrš| |¡}z|     |¡Wn0t
tfk
r–}zt|ƒ|‚W5d}~XYnXnt |ƒs¬t|ƒ‚n~t |ƒt |ƒkrÆtdƒ‚ndz|j |dd}|     |¡WnFt
tfk
r(}z"tt|ddƒƒrn
t|ƒ|‚W5d}~XYnX|S)NzLengths must matchT©Ú allow_objectrr)rtr’r–Ú
ValueErrorrr8r„rr‘ršrÔrGr¦Ú_validate_listlikerHÚgetattr)rxr˜Úerrr~r~rÚ_validate_comparison_value)s.
 
 
 
z1DatetimeLikeArrayMixin._validate_comparison_value)Úallow_listlikeÚunboxc
CsÐt||jƒrn°t|tƒrbz| |¡}Wq¾tk
r^}z| ||¡}t|ƒ|‚W5d}~XYq¾Xn\t||jƒrtt    }nJt
|ƒr’| ||¡}t|ƒ‚n,t||j ƒrª| |¡}n| ||¡}t|ƒ‚|sÆ|S|  |¡S)a 
        Validate that the input value can be cast to our scalar_type.
 
        Parameters
        ----------
        value : object
        allow_listlike: bool, default False
            When raising an exception, whether the message should say
            listlike inputs are allowed.
        unbox : bool, default True
            Whether to unbox the result before returning.  Note: unbox=False
            skips the setitem compatibility check.
 
        Returns
        -------
        self._scalar_type or NaT
        N) rtr‘r’r–rîÚ_validation_error_messagerÔrQrrrrRr„r—)rxr”rórôrñrØr~r~rÚ_validate_scalarMs( 
 
   z'DatetimeLikeArrayMixin._validate_scalar)rórpcCsB|r"d|jj›dt|ƒj›d}nd|jj›dt|ƒj›d}|S)a+
        Construct an exception message on validation error.
 
        Some methods allow only scalar inputs, while others allow either scalar
        or listlike.
 
        Parameters
        ----------
        allow_listlike: bool, default False
 
        Returns
        -------
        str
        zvalue should be a 'z"', 'NaT', or array of those. Got 'z
' instead.z' or 'NaT'. Got ')r‘rÖrÕ)rxr”rórØr~r~rrõˆs ÿÿz0DatetimeLikeArrayMixin._validation_error_messagerìc    Csvt|t|ƒƒr|St|tƒr<t|ƒdkr<t|ƒjg|jdSt|dƒr¬|jtkr¬t     |¡|j
kr¬zt|ƒ |¡}Wn8t t fk
rª|r’|YS|  |d¡}t |ƒ‚YnXt|dd}t|ƒ}t|dd}t|ƒrzt|ƒj||jd}Wnt k
rYnXt|jƒr8t|jj|jƒr8| ¡}t|dd}|rLt|jƒrLn&t|ƒ |j¡sr|  |d¡}t |ƒ‚|S)Nrr±rrT©Z extract_numpy)rtrÕr³r¦Ú_from_sequencerrÚhasattrr´rÚ infer_dtyper‚rîrÔrõrbÚpd_arrayr>r?rDÚ
categoriesZ_internal_get_valuesrHrƒ)rxr”rírØr~r~rrï£s>   
   z)DatetimeLikeArrayMixin._validate_listlikecCs,t|ƒr| |¡}n|j|ddS| |¡S)NT)ró)rGrïröÚ_unboxr•r~r~rÚ_validate_setitem_valueÖs z.DatetimeLikeArrayMixin._validate_setitem_valuez6np.int64 | np.datetime64 | np.timedelta64 | np.ndarraycCs*t |¡r| |¡}n| |¡|j}|S)zZ
        Unbox either a scalar with _unbox_scalar or an instance of our own type.
        )rr¼r—ršr…r™r~r~rrýÞs
 
 
zDatetimeLikeArrayMixin._unboxcCsddlm}||ƒ |¡jS)Nr)ÚIndex)ZpandasrÿÚmapr`)rxZmapperrÿr~r~rrðs zDatetimeLikeArrayMixin.mapznpt.NDArray[np.bool_]c    CsDt|dƒst |¡}|jjdkr0tj|jtdSt|t    |ƒƒsØdddddd    g}|jt
kr t j |d
d }||kr |d krxn(d |krt | t
¡|ƒStj|jtdSzt    |ƒ |¡}Wn$tk
rÖt | t
¡|ƒYSX|jjdkrütd|ƒ}| |j¡}z| |¡Wn*ttfk
r4tj|jtdYSXt |j|jƒS)zô
        Compute boolean array of whether each value is found in the
        passed set of values.
 
        Parameters
        ----------
        values : set or sequence of values
 
        Returns
        -------
        ndarray[bool]
        rr)ÚfÚiÚuÚcr±rÚ timedelta64rÚ
datetime64ÚdateZperiodF©ÚskipnaÚstringÚmixed©rÌrÈúDatetimeArray | TimedeltaArray)rùr²r×rrrÍÚzerosrÑr‡rtrÕr´rrúrWrÒrørîrÚas_unitÚunitršrÔr§)rxrZ    inferableÚinferredr~r~rrWûs@
 
 ú
 
 zDatetimeLikeArrayMixin.isincCs|jSr)Ú_isnanr‰r~r~rrR7szDatetimeLikeArrayMixin.isnacCs
|jtkS)z-
        return if each value is nan
        )r§r r‰r~r~rr:szDatetimeLikeArrayMixin._isnancCst|j ¡ƒS)zJ
        return if I have any nans; enables various perf speedups
        )r‡rÚanyr‰r~r~rÚ_hasnaAszDatetimeLikeArrayMixin._hasna)r|rpcCs6|jr2|r| |¡}|dkr"tj}t ||j|¡|S)az
        Parameters
        ----------
        result : np.ndarray
        fill_value : object, default iNaT
        convert : str, dtype or None
 
        Returns
        -------
        result : ndarray with values replace by the fill_value
 
        mask the result if needed, convert to the provided dtype if its not
        None
 
        This is an internal routine.
        N)rrÒr²ÚnanÚputmaskr)rxr|Ú
fill_valuerœr~r~rÚ_maybe_mask_resultsHs
z*DatetimeLikeArrayMixin._maybe_mask_resultsz
str | NonecCs|jdkrdS|jjS)zU
        Return the frequency object as a string if its set, otherwise None.
        N)r†Úfreqstrr‰r~r~rrfs
zDatetimeLikeArrayMixin.freqstrcCs6|jdkrdSz t |¡WStk
r0YdSXdS)z˜
        Tries to return a string representing a frequency generated by infer_freq.
 
        Returns None if it can't autodetect the frequency.
        rŸN)r¤rhZ
infer_freqrîr‰r~r~rÚ inferred_freqos 
 z$DatetimeLikeArrayMixin.inferred_freqzResolution | NonecCs:|j}|dkrdSz t |¡WStk
r4YdSXdSr)rrZget_reso_from_freqstrÚKeyError)rxrr~r~rÚ_resolution_obj}s z&DatetimeLikeArrayMixin._resolution_objcCs|jjS)zO
        Returns day, hour, minute, second, millisecond or microsecond
        )rÚattrnamer‰r~r~rÚ
resolution‡sz!DatetimeLikeArrayMixin.resolutioncCstj|jdddS)NT©Ztimeliker©rZ is_monotonicr§r‰r~r~rÚ_is_monotonic_increasing’sz/DatetimeLikeArrayMixin._is_monotonic_increasingcCstj|jdddS)NTrrŸr r‰r~r~rÚ_is_monotonic_decreasing–sz/DatetimeLikeArrayMixin._is_monotonic_decreasingcCstt|j d¡ƒƒ|jkS)NÚK)r¦rXr§rÏÚsizer‰r~r~rÚ
_is_uniquešsz!DatetimeLikeArrayMixin._is_uniquec
    CsÒ|jdkr6t|ddƒ|jkr6|| ¡| ¡ƒ |j¡Sz| |¡}Wn tk
rdt|||ƒYSXt|ddƒ}t|ƒr°t    j
dd t   |t      | t¡¡|¡}W5QRX|S|tkrè|tjkrÔt    j|jtd}nt    j|jtd}|St|jƒsxtt|ƒ}|j|jkrxt|t|ƒƒsdz|j|jdd}Wn0tk
r`t      |j!¡}t"|j#||ƒYSXn|j#}t"|j#||ƒS| $|¡}||j# %d    ¡| %d    ¡ƒ}t&|ƒ}|j'|B}| (¡rÎ|tjk}    t     )|||    ¡|S)
NrŸrÑrrÚignore)rår±F©Zround_okrq)*r¤rðrÑrÏrÐròr8rfrHr²ZerrstaterUZcomp_method_OBJECT_ARRAYr×rÒr´rÚoperatorÚneZonesr‡rrIrrrÚ TimelikeOpsrÎrtrÕrrrîr`Zasm8r&r…rýrsrRrrr)
rxr˜Úoprrr|Z    other_arrZ
other_valsÚo_maskÚmaskZ
nat_resultr~r~rÚ _cmp_method¡sV ÿ
 
 ÿ 
 
 
 
z"DatetimeLikeArrayMixin._cmp_methodÚ__pow__Ú__rpow__Ú__mul__Ú__rmul__Ú __truediv__Ú __rtruediv__Ú __floordiv__Ú __rfloordiv__Ú__mod__Ú__rmod__Ú
__divmod__Ú __rdivmod__z@tuple[int | npt.NDArray[np.int64], None | npt.NDArray[np.bool_]]cCsDt|tƒr|j}d}n&t|ttfƒr0|j}d}n |j}|j}||fS)zR
        Get the int64 values and b_mask to pass to checked_add_with_arr.
        N)rtrÚordinalrrrvrr§)rxr˜Zi8valuesr-r~r~rÚ_get_i8_values_and_maskês
z.DatetimeLikeArrayMixin._get_i8_values_and_maskcCs4t|jƒr|jSt |¡sdSt|jtƒr0|jSdS)zP
        Check if we can preserve self.freq in addition or subtraction.
        N)rIrrr†rr¼rtrr™r~r~rÚ_get_arithmetic_result_freqýs
 
 z2DatetimeLikeArrayMixin._get_arithmetic_result_freqc
Cs"t|jƒs*tdt|ƒj›dt|ƒj›ƒ‚td|ƒ}ddlm}ddlm    }|t
k    sXt ‚t |ƒrŽ|j t
 ¡ d|j›d¡}|j||jd    St|ƒ}| |¡\}}td|ƒ}| |¡\}}t|j||j|d
}| d|j›d¡}||j|jd }| d|j›d¡}| |¡}    |j|||    d S) Nú cannot add ú and rkr©ri)Ú tz_to_dtypezM8[ú]r±©Zarr_maskZb_mask©rÊr©rrr†)rKrrrÔrÕrÖrÚpandas.core.arraysriZpandas.core.arrays.datetimesrArÚAssertionErrorrRr…Z to_datetime64rÒrÚ _simple_newrÚ_ensure_matching_resosr<rVr§rrsrÊr=)
rxr˜rirAr|Úother_i8r,Ú
res_valuesrrrèr~r~rÚ_add_datetimelike_scalar s4
ÿ
 
ÿ
z/DatetimeLikeArrayMixin._add_datetimelike_scalarcCs2t|jƒs*tdt|ƒj›dt|ƒj›ƒ‚||S)Nr>r?)rKrrrÔrÕrÖr™r~r~rÚ_add_datetime_arraylike1s
 
ÿz.DatetimeLikeArrayMixin._add_datetime_arraylikezdatetime | np.datetime64)r˜cCsZ|jjdkr tdt|ƒj›ƒ‚td|ƒ}t|ƒr:|tSt|ƒ}|     |¡\}}| 
|¡S)NrÈú"cannot subtract a datelike from a ri) rrrÍrÔrÕrÖrrRrrrIÚ_sub_datetimelike)rxr˜Útsr~r~rÚ_sub_datetimelike_scalar;s 
z/DatetimeLikeArrayMixin._sub_datetimelike_scalarcCsZ|jjdkr tdt|ƒj›ƒ‚t|ƒt|ƒkr8tdƒ‚td|ƒ}| |¡\}}|     |¡S)NrÈrNú$cannot add indices of unequal lengthri)
rrrÍrÔrÕrÖr¦rîrrIrOr™r~r~rÚ_sub_datetime_arraylikeLs 
z.DatetimeLikeArrayMixin._sub_datetime_arraylikezTimestamp | DatetimeArrayc
 
Csºtd|ƒ}ddlm}z| |¡Wn@tk
rd}z"t|ƒ dd¡}t|ƒ|ƒ|‚W5d}~XYnX| |¡\}}t    |j
| |j |d}|  d|j ›d¡}| |¡}    |j||j|    d    S)
Nrir©rkÚcompareÚsubtractrCú timedelta64[rBrE)rrFrkZ_assert_tzawareness_compatrÔr’ÚreplacerÕr<rVr§rrsrr=rHrr)
rxr˜rkrñZ new_messagerJr,rKZres_m8rèr~r~rrOYs"
  ÿ
z(DatetimeLikeArrayMixin._sub_datetimelikerrjcCsPt|jƒstdt|ƒj›ƒ‚ddlm}t |j    |j
¡}|||j d}||S)Nzcannot add Period to a r)rjrß) rKrrrÔrÕrÖZpandas.core.arrays.periodrjr²Z broadcast_tor;rÑr†)rxr˜rjZi8valsZparrr~r~rÚ _add_periodns 
 z"DatetimeLikeArrayMixin._add_periodcCs t|ƒ‚dSrrŽ)rxÚoffsetr~r~rÚ _add_offsetzsz"DatetimeLikeArrayMixin._add_offsetcCsjt|ƒr@tj|jdd |jj¡}| t¡t    |ƒj
||jdSt d|ƒ}t |ƒ}|  |¡\}}| |¡S)zk
        Add a delta of a timedeltalike
 
        Returns
        -------
        Same type as self
        rqr±r )rRr²ÚemptyrÑrsr…rrÚfillr rÕrHrrrIÚ_add_timedeltalike)rxr˜Ú
new_valuesr~r~rÚ_add_timedeltalike_scalar}s
 
z0DatetimeLikeArrayMixin._add_timedeltalike_scalarcCs:t|ƒt|ƒkrtdƒ‚td|ƒ}| |¡\}}| |¡S)zl
        Add a delta of a TimedeltaIndex
 
        Returns
        -------
        Same type as self
        rRr )r¦rîrrIr^r™r~r~rÚ_add_timedelta_arraylike‘s
 
 
z/DatetimeLikeArrayMixin._add_timedelta_arraylikezTimedelta | TimedeltaArraycCsZtd|ƒ}| |¡\}}t|j||j|d}| |jj¡}| |¡}t    |ƒj
||j|dS)Nr rCrE) rr<rVr§rrsr…rrr=rÕrH)rxr˜rJr,r_rKrèr~r~rr^£s
ÿ
z)DatetimeLikeArrayMixin._add_timedeltalikecCstt|jƒr*tdt|ƒj›dttƒj›ƒ‚td|ƒ}tj|j    tj
d}|  t ¡|  |jj¡}t|ƒj||jddS)z$
        Add pd.NaT to self
        z Cannot add r?zTimedeltaArray | DatetimeArrayr±NrE)rIrrrÔrÕrÖrrr²r\rÑrÓr]r rsr…rH©rxr|r~r~rÚ_add_nat±s
ÿ
 
zDatetimeLikeArrayMixin._add_natcCsTtj|jtjd}| t¡|jjdkrFtd|ƒ}|     d|j
›d¡S|     d¡SdS)z+
        Subtract pd.NaT from self
        r±r zDatetimeArray| TimedeltaArrayrWrBztimedelta64[ns]N) r²r\rÑrÓr]r rrrÍrrsrrbr~r~rÚ_sub_natÃs 
 
zDatetimeLikeArrayMixin._sub_natzPeriod | PeriodArraycs tˆjƒs*tdt|ƒj›dtˆƒj›ƒ‚tdˆƒ‰ˆ |¡ˆ |¡\}}tˆj    | ˆj
|d}t   ‡fdd„|Dƒ¡}|dkrŠˆj
}n
ˆj
|B}t ||<|S)Núcannot subtract ú from rjrCcsg|]}ˆjj|‘qSr~)r†ÚbaserÝr‰r~rrÞçsz:DatetimeLikeArrayMixin._sub_periodlike.<locals>.<listcomp>)rIrrrÔrÕrÖrršr<rVr§rr²r`r)rxr˜rJr,Z new_i8_dataZnew_datar-r~r‰rÚ_sub_periodlike×s&
ÿ
 
ÿ
z&DatetimeLikeArrayMixin._sub_periodlikecCsŽ|tjtjfkst‚t|ƒdkr8|jdkr8|||dƒStjdt|ƒj    ›dt
t ƒd|j |j kstt|j |j fƒ‚||  d¡t |¡ƒ}|S)aZ
        Add or subtract array-like of DateOffset objects
 
        Parameters
        ----------
        other : np.ndarray[object]
        op : {operator.add, operator.sub}
 
        Returns
        -------
        np.ndarray[object]
            Except in fastpath case with length 1 where we operate on the
            contained scalar.
        rŸrz)Adding/subtracting object-dtype array to z not vectorized.)Ú
stacklevelÚO)r(ÚaddÚsubrGr¦r¤ÚwarningsÚwarnrÕrÖr9r=rÑrÒr²r×)rxr˜r+rKr~r~rÚ_addsub_object_arrayòsüz+DatetimeLikeArrayMixin._addsub_object_arrayr)Únamer    cKsX|dkr td|›dt|ƒ›ƒ‚tt|ƒ}|| ¡fd|i|—Ž}t|ƒj|d|jdS)N>ÚcummaxÚcumminz Accumulation z not supported for r    )r†rr)rÔrÕrðrYrŒrHrr)rxrpr    rzr+r|r~r~rÚ _accumulates
ÿz"DatetimeLikeArrayMixin._accumulateÚ__add__cCsœt|ddƒ}t|ƒ}|tkr(| ¡}nBt|tttjfƒrH|     |¡}n"t|t
ƒr`|  |¡}n
t|t tj fƒr|| |¡}nît|tƒrœt|jƒrœ| |¡}nÎt |¡rÚt|jƒs¸t|ƒ‚td|ƒ}| ||jjtj¡}nt|ƒrî| |¡}n|t|ƒr| |tj¡}nbt |ƒst!|ƒr&| "|¡St#|ƒrft|jƒsDt|ƒ‚td|ƒ}| ||jjtj¡}nt$St|tj%ƒr˜t|jƒr˜ddl&m'}||ƒS|S©NrrrjrrT)(rðrarrcrtrrr²rr`rr[rrrLrrKrrrYrÚ
is_integerrIr'rÚ_addsub_int_array_or_scalarr†r¡r(rkrarHrorArBrMrFÚNotImplementedÚndarrayrFrk©rxr˜Ú other_dtyper|rárkr~r~rrt!sB  
 
 
 
 
 
 
 
 zDatetimeLikeArrayMixin.__add__cCs
| |¡Sr)rtr™r~r~rÚ__radd__WszDatetimeLikeArrayMixin.__radd__Ú__sub__cCs°t|ddƒ}t|ƒ}|tkr(| ¡}nVt|tttjfƒrJ|     | ¡}n4t|t
ƒrd|  | ¡}nt|t tj fƒr€| |¡}nþt |¡r¾t|jƒsœt|ƒ‚td|ƒ}| ||jjtj¡}nÀt|tƒrÔ| |¡}nªt|ƒrê| | ¡}n”t|ƒr| |tj¡}nzt |ƒst!|ƒr$| "|¡}nZt|ƒr:| |¡}nDt#|ƒrzt|jƒsXt|ƒ‚td|ƒ}| ||jjtj¡}nt$St|tj%ƒr¬t|jƒr¬ddl&m'}||ƒS|Sru)(rðrarrdrtrrr²rr`rr[rrrQrrvrIrrr'rrwr†r¡r(rlrrhrKrarHrorArBrSrFrxryrFrkrzr~r~rr}[sF  
 
 
 
 
 
 
 
 
 zDatetimeLikeArrayMixin.__sub__cCsòt|ddƒ}t|ƒrZt|jƒrZt |¡r4t|ƒ|St|tƒsRddl    m
}||ƒ}||St|jƒršt |dƒršt|jƒsšt dt |ƒj›dt |ƒj›ƒ‚nNt|jƒrÊt|ƒrÊt dt |ƒj›d|j›ƒ‚nt|jƒrètd|ƒ}| |S|| S)Nrrrr@rerfrk)rðr@rKrrrr¼rrtrmrFrirùrÔrÕrÖrIr)rxr˜r{rir~r~rÚ__rsub__‘s. 
 
 ÿþýÿ
 
 
zDatetimeLikeArrayMixin.__rsub__cCs2||}|dd…|dd…<t|jƒs.|j|_|Sr©rIrrr†r¾©rxr˜r|r~r~rÚ__iadd__´s
 
zDatetimeLikeArrayMixin.__iadd__cCs2||}|dd…|dd…<t|jƒs.|j|_|Srrr€r~r~rÚ__isub__½s
 
zDatetimeLikeArrayMixin.__isub__znpt.NDArray[np.float64])rxÚqsÚ interpolationrpcstƒj||dS)N)rƒr„)r»Ú    _quantile)rxrƒr„r¿r~rr…Ész DatetimeLikeArrayMixin._quantile©rÜr    úAxisInt | NonecKs8t d|¡t ||j¡tj|j||d}| ||¡S)a 
        Return the minimum value of the Array or minimum along
        an axis.
 
        See Also
        --------
        numpy.ndarray.min
        Index.min : Return the minimum value in an Index.
        Series.min : Return the minimum value in a Series.
        r~r†)ÚnvZ validate_minÚvalidate_minmax_axisr¤rTZnanminr…Ú_wrap_reduction_result©rxrÜr    rzr|r~r~rÚminÑs zDatetimeLikeArrayMixin.mincKs8t d|¡t ||j¡tj|j||d}| ||¡S)a 
        Return the maximum value of the Array or maximum along
        an axis.
 
        See Also
        --------
        numpy.ndarray.max
        Index.max : Return the maximum value in an Index.
        Series.max : Return the maximum value in a Series.
        r~r†)rˆZ validate_maxr‰r¤rTZnanmaxr…rŠr‹r~r~rÚmaxãs zDatetimeLikeArrayMixin.max)r    rÜcCsDt|jƒr tdt|ƒj›dƒ‚tj|j||| ¡d}|     ||¡S)aL
        Return the mean value of the Array.
 
        Parameters
        ----------
        skipna : bool, default True
            Whether to ignore any NaT elements.
        axis : int, optional, default 0
 
        Returns
        -------
        scalar
            Timestamp or Timedelta.
 
        See Also
        --------
        numpy.ndarray.mean : Returns the average of array elements along a given axis.
        Series.mean : Return the mean value in a Series.
 
        Notes
        -----
        mean is only defined for Datetime and Timedelta dtypes, not for Period.
        zmean is not implemented for zX since the meaning is ambiguous.  An alternative is obj.to_timestamp(how='start').mean()©rÜr    r-)
rIrrrÔrÕrÖrTZnanmeanr…rRrŠ)rxr    rÜr|r~r~rÚmeanõs
ÿÿzDatetimeLikeArrayMixin.meancKsHt d|¡|dk    r*t|ƒ|jkr*tdƒ‚tj|j||d}| ||¡S)Nr~z abs(axis) must be less than ndimr†)    rˆZvalidate_medianÚabsr¤rîrTZ    nanmedianr…rŠr‹r~r~rÚmedians
 zDatetimeLikeArrayMixin.median)ÚdropnacCsHd}|r| ¡}tj| d¡|d}| |jj¡}ttj|ƒ}|     |¡S)Nrq)r-)
rRrSÚmodersr…rrrr²ryrw)rxr’r-Zi8modesZnpmodesr~r~rÚ_mode$s zDatetimeLikeArrayMixin._mode)NNF)F)N)T).)N)r)rê)F)F)T)brÖÚ
__module__Ú __qualname__Ú__doc__Ú__annotations__r<rŠrÚpropertyr‘r–r—ršruržr¨r§r¬r¯r¶rr¹r½rÅrÆrÒrsÚ classmethodrärŒròrörõrïrþrrýr\rrWrRrrr rrrrrr!r"r%r.rgr/r0r1r2r3r4r5r6r7r8r9r:r<r=rLrMrQrSrOrYr[r`rar^rcrdrhrorsrertr|r}r~rr‚rr…rŒrrr‘r”Ú __classcell__r~r~r¿rrm»s 
 ÿ
ÿ 6ý
(û;3
 
<ÿ     
<#       
 
# 
5
5#     %    c@s*eZdZdZedddddœdd„ƒZd    S)
Ú DatelikeOpszK
    Common ops for DatetimeIndex/PeriodIndex, but not TimedeltaIndex.
    zNhttps://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior)ÚURLr’r«)rªrpcCs|j|tjd}|jtddS)a°
        Convert to Index using specified date_format.
 
        Return an Index of formatted strings specified by date_format, which
        supports the same string format as the python standard library. Details
        of the string format can be found in `python string format
        doc <%(URL)s>`__.
 
        Formats supported by the C `strftime` API but not by the python string format
        doc (such as `"%%R"`, `"%%r"`) are not officially supported and should be
        preferably replaced with their supported equivalents (such as `"%%H:%%M"`,
        `"%%I:%%M:%%S %%p"`).
 
        Note that `PeriodIndex` support additional directives, detailed in
        `Period.strftime`.
 
        Parameters
        ----------
        date_format : str
            Date format string (e.g. "%%Y-%%m-%%d").
 
        Returns
        -------
        ndarray[object]
            NumPy ndarray of formatted strings.
 
        See Also
        --------
        to_datetime : Convert the given argument to datetime.
        DatetimeIndex.normalize : Return DatetimeIndex with times to midnight.
        DatetimeIndex.round : Round the DatetimeIndex to the specified freq.
        DatetimeIndex.floor : Floor the DatetimeIndex to the specified freq.
        Timestamp.strftime : Format a single Timestamp.
        Period.strftime : Format a single Period.
 
        Examples
        --------
        >>> rng = pd.date_range(pd.Timestamp("2018-03-10 09:00"),
        ...                     periods=3, freq='s')
        >>> rng.strftime('%%B %%d, %%Y, %%r')
        Index(['March 10, 2018, 09:00:00 AM', 'March 10, 2018, 09:00:01 AM',
               'March 10, 2018, 09:00:02 AM'],
              dtype='object')
        )rªr©FrÇ)r¬r²rrÒr´)rxrªr|r~r~rÚstrftime4s1zDatelikeOps.strftimeN)rÖr•r–r—r;ržr~r~r~rrœ/s
ÿrœaM    
    Perform {op} operation on the data to the specified `freq`.
 
    Parameters
    ----------
    freq : str or Offset
        The frequency level to {op} the index to. Must be a fixed
        frequency like 'S' (second) not 'ME' (month end). See
        :ref:`frequency aliases <timeseries.offset_aliases>` for
        a list of possible `freq` values.
    ambiguous : 'infer', bool-ndarray, 'NaT', default 'raise'
        Only relevant for DatetimeIndex:
 
        - 'infer' will attempt to infer fall dst-transition hours based on
          order
        - bool-ndarray where True signifies a DST time, False designates
          a non-DST time (note that this flag is only applicable for
          ambiguous times)
        - 'NaT' will return NaT where there are ambiguous times
        - 'raise' will raise an AmbiguousTimeError if there are ambiguous
          times.
 
    nonexistent : 'shift_forward', 'shift_backward', 'NaT', timedelta, default 'raise'
        A nonexistent time does not exist in a particular timezone
        where clocks moved forward due to DST.
 
        - 'shift_forward' will shift the nonexistent time forward to the
          closest existing time
        - 'shift_backward' will shift the nonexistent time backward to the
          closest existing time
        - 'NaT' will return NaT where there are nonexistent times
        - timedelta objects will shift nonexistent times by the timedelta
        - 'raise' will raise an NonExistentTimeError if there are
          nonexistent times.
 
    Returns
    -------
    DatetimeIndex, TimedeltaIndex, or Series
        Index of the same type for a DatetimeIndex or TimedeltaIndex,
        or a Series with the same index for a Series.
 
    Raises
    ------
    ValueError if the `freq` cannot be converted.
 
    Notes
    -----
    If the timestamps have a timezone, {op}ing will take place relative to the
    local ("wall") time and re-localized to the same timezone. When {op}ing
    near daylight savings time, use ``nonexistent`` and ``ambiguous`` to
    control the re-localization behavior.
 
    Examples
    --------
    **DatetimeIndex**
 
    >>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min')
    >>> rng
    DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00',
                   '2018-01-01 12:01:00'],
                  dtype='datetime64[ns]', freq='T')
    a’>>> rng.round('H')
    DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
                   '2018-01-01 12:00:00'],
                  dtype='datetime64[ns]', freq=None)
 
    **Series**
 
    >>> pd.Series(rng).dt.round("H")
    0   2018-01-01 12:00:00
    1   2018-01-01 12:00:00
    2   2018-01-01 12:00:00
    dtype: datetime64[ns]
 
    When rounding near a daylight savings time transition, use ``ambiguous`` or
    ``nonexistent`` to control how the timestamp should be re-localized.
 
    >>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam")
 
    >>> rng_tz.floor("2H", ambiguous=False)
    DatetimeIndex(['2021-10-31 02:00:00+01:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
 
    >>> rng_tz.floor("2H", ambiguous=True)
    DatetimeIndex(['2021-10-31 02:00:00+02:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
    a‘>>> rng.floor('H')
    DatetimeIndex(['2018-01-01 11:00:00', '2018-01-01 12:00:00',
                   '2018-01-01 12:00:00'],
                  dtype='datetime64[ns]', freq=None)
 
    **Series**
 
    >>> pd.Series(rng).dt.floor("H")
    0   2018-01-01 11:00:00
    1   2018-01-01 12:00:00
    2   2018-01-01 12:00:00
    dtype: datetime64[ns]
 
    When rounding near a daylight savings time transition, use ``ambiguous`` or
    ``nonexistent`` to control how the timestamp should be re-localized.
 
    >>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam")
 
    >>> rng_tz.floor("2H", ambiguous=False)
    DatetimeIndex(['2021-10-31 02:00:00+01:00'],
                 dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
 
    >>> rng_tz.floor("2H", ambiguous=True)
    DatetimeIndex(['2021-10-31 02:00:00+02:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
    aŒ>>> rng.ceil('H')
    DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
                   '2018-01-01 13:00:00'],
                  dtype='datetime64[ns]', freq=None)
 
    **Series**
 
    >>> pd.Series(rng).dt.ceil("H")
    0   2018-01-01 12:00:00
    1   2018-01-01 12:00:00
    2   2018-01-01 13:00:00
    dtype: datetime64[ns]
 
    When rounding near a daylight savings time transition, use ``ambiguous`` or
    ``nonexistent`` to control how the timestamp should be re-localized.
 
    >>> rng_tz = pd.DatetimeIndex(["2021-10-31 01:30:00"], tz="Europe/Amsterdam")
 
    >>> rng_tz.ceil("H", ambiguous=False)
    DatetimeIndex(['2021-10-31 02:00:00+01:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
 
    >>> rng_tz.ceil("H", ambiguous=True)
    DatetimeIndex(['2021-10-31 02:00:00+02:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
    Ú TimelikeOpsTr*cs°eZdZUdZded<dejdfdddœd    d
„Zed d „ƒZ    e
d d„ƒZ e j ddœdd„ƒZ edd„ƒZ edddœdd„ƒZeddœdd„ƒZeddœdd„ƒZddddœd d!„Zd"d#„Zd$dd%œ‡fd&d'„ Zd(d)„Zeeejd*d+ƒdGd-d.d/œd0d1„ƒZeeejd2d+ƒdHd-d.d/œd3d4„ƒZeeejd5d+ƒdId-d.d/œd6d7„ƒZdd8d9œd:ddd;œd<d=„Zdd8d9œd:ddd;œd>d?„Z ddœd@dA„Z!dBdC„Z"dJdddDœ‡fdEdF„ Z#‡Z$S)Kr*zK
    Common ops for TimedeltaIndex/DatetimeIndex, but not PeriodIndex.
    znp.dtypeÚ_default_dtypeNFr‡r‹)rŒrpcCsät|dd}t|tƒr$|jdtd}t|ddƒ}|dk}|tjk    rF|nd}t|t|ƒƒrÒ|r^n4|dkrn|j    }n$|r’|j    r’t
|ƒ}t ||j    dƒ\}}|dk    rÄt |ƒ}t ||jƒsÄtd|›d|j›ƒ‚|j}|j}n0|dkrt|tjƒrü|jjd    krü|j}n|j}t|tjƒs2td
t|ƒj›d t|ƒj›d ƒ‚|jd krFtdƒ‚|jdkr^| |j¡}| ||¡}|dkrŠtdt|ƒj›dƒ‚|r˜| ¡}|r¦t
|ƒ}tj|||d||_|dkrà|dk    ràt|ƒ ||¡dS)NTr÷rÓ©Zna_valuer¾Fzdtype=z does not match data dtype ZMmzUnexpected type 'z'. 'values' must be a z6, ndarray, or Series or Index containing one of those.)rŸéz.Only 1-dimensional input arrays are supported.rqÚinferz#Frequency inference not allowed in z$.__init__. Use 'pd.array()' instead.)rrr)rbrtr_Úto_numpyr rðrÚ
no_defaultrÕr†r#Úvalidate_inferred_freqrLrDrrrÔr…r²ryrÍr rîrÖr¤rsÚ_validate_dtyperŒrrr¾Ú_validate_frequency)rxrrrr†rŒrZ explicit_noneÚ_r~r~rrs^ 
 
 ÿ
ÿ    
ÿzTimelikeOps.__init__cCs t|ƒ‚dSrrŽ)rÚrrrr~r~rr§LszTimelikeOps._validate_dtypecCs|jS)zK
        Return the frequency object if it is set, otherwise None.
        ©r¾r‰r~r~rr†PszTimelikeOps.freqrˆcCs8|dk    r.t|ƒ}| ||¡|jdkr.tdƒ‚||_dS)NrŸzCannot set freq with ndim > 1)r#r¨r¤rîr¾r•r~r~rr†Ws  
c
Ks¬|j}|jdks||jkrdSz>|jf|ddt|ƒ||jdœ|—Ž}t |j|j¡sZt    ‚WnJt    k
r¦}z,dt
|ƒkr~|‚t    d|›d|j›ƒ|‚W5d}~XYnXdS)am
        Validate that a frequency is compatible with the values of a given
        Datetime Array/Index or Timedelta Array/Index
 
        Parameters
        ----------
        index : DatetimeIndex or TimedeltaIndex
            The index on which to determine if the given frequency is valid
        freq : DateOffset
            The frequency to validate
        rN)ÚstartÚendÚperiodsr†rz    non-fixedúInferred frequency ú9 from passed values does not conform to passed frequency ) rr$rÚ_generate_ranger¦rr²Z array_equalr§rîr’)rÚÚindexr†rzrZon_freqrñr~r~rr¨bs. ûú ÿýzTimelikeOps._validate_frequencyrÙrl)rÚrpcOs t|ƒ‚dSrrŽ)rÚr«r¬r­r†ryrzr~r~rr°szTimelikeOps._generate_rangeÚintcCs t|jjƒSr)rr…rrr‰r~r~rrΕszTimelikeOps._cresor’cCs
t|jƒSr)Ú dtype_to_unitrrr‰r~r~rr™szTimelikeOps.unitrŸ)rxrrpcCs~|dkrtdƒ‚t |jj›d|›d¡}t|j|dd}t|jtjƒrP|j}ntd|ƒj}t    ||d}t
|ƒj |||j d    S)
N)ÚsÚmsÚusÚnsz)Supported units are 's', 'ms', 'us', 'ns'z8[rBTr'rirDrE) rîr²rrrÍrr…rtrrÊrMrÕrHr†)rxrrrr_Z    new_dtyperÊr~r~rr s  ÿzTimelikeOps.as_unitcCs:|j|jkr2|j|jkr&| |j¡}n | |j¡}||fSr)rÎrrr™r~r~rrIµs
   z"TimelikeOps._ensure_matching_resosznp.ufunc)ÚufuncÚmethodcsV|tjtjtjfkr@t|ƒdkr@|d|kr@t||ƒ|jf|ŽStƒj||f|ž|ŽS)NrŸr)    r²ÚisnanÚisinfÚisfiniter¦rðr…r»Ú__array_ufunc__)rxr¸r¹Úinputsrzr¿r~rr½Àsÿ
þ
ýzTimelikeOps.__array_ufunc__c Cs´t|jƒr@td|ƒ}| d¡}| ||||¡}|j|j||dS| d¡}ttj|ƒ}t    |ƒ}|j
t ||j ƒ}    |    dkr||St |||    ƒ}
|j|
td}| |jj¡}|j||jdS)Nri©Ú    ambiguousÚ nonexistentrqr©rr±)rBrrrZ tz_localizeÚ_roundrÊrsr²ryr#ÚnanosrrÎr%rr r…rH) rxr†r“rÀrÁZnaiver|rrZrÄZ    result_i8r~r~rrÃËs(
 
 
ÿ
   zTimelikeOps._roundÚround)r+Úraiser3r4r¿cCs| |tj||¡Sr)rÃr$ZNEAREST_HALF_EVEN©rxr†rÀrÁr~r~rrÅãszTimelikeOps.roundÚfloorcCs| |tj||¡Sr)rÃr$Z MINUS_INFTYrÇr~r~rrÈìszTimelikeOps.floorÚceilcCs| |tj||¡Sr)rÃr$Z
PLUS_INFTYrÇr~r~rrÉõszTimelikeOps.ceilTr†r‡)rÜr    rpcCstj|j||| ¡dS©NrŽ)rTZnananyr…rR©rxrÜr    r~r~rrszTimelikeOps.anycCstj|j||| ¡dSrÊ)rTZnanallr…rRrËr~r~rråszTimelikeOps.allcCs
d|_dSrrªr‰r~r~rrÆ szTimelikeOps._maybe_clear_freqcCsJ|dkr
n.t|ƒdkr"t|tƒr"n|dks.t‚t|jƒ}| ¡}||_|S)z×
        Helper to get a view on the same data, with a new freq.
 
        Parameters
        ----------
        freq : DateOffset, None, or "infer"
 
        Returns
        -------
        Same type as self
        Nrr£)r¦rtrrGr#rrsr¾)rxr†r{r~r~rÚ
_with_freqs  
zTimelikeOps._with_freq)Úuse_na_sentinelÚsortcsh|jdk    rZtjt|ƒtjd}| ¡}|rR|jjdkrR|ddd…}|ddd…}||fStƒj|dS)Nr±rrâ)rÍ)    r†r²Zaranger¦ZintprŒr¡r»Ú    factorize)rxrÍrÎÚcodesZuniquesr¿r~rrÏ/s
zTimelikeOps.factorize)rÆrÆ)rÆrÆ)rÆrÆ)TF)%rÖr•r–r—r˜rr¥rršr§r™r†Úsetterr¨r°r<rÎrrrIr½rÃr:Ú
_round_docÚ_round_exampler®rÅÚ_floor_examplerÈÚ _ceil_examplerÉrrårÆrÌrÏr›r~r~r¿rr*ýsV
ÿH
 
 
 
*  üüü !ýr‡r’)rŒÚcls_namecCsêt|dƒs>t|ttfƒs.t |¡dkr.t|ƒ}t |¡}d}n(t|tƒrZtd|›dƒ‚n t    |dd}t|t
ƒs†t|t ƒrš|j j dkrš|jd    td
}d}nHt|tjtfƒr´t|t ƒrÀt |¡}n"t|tƒrâ|jj|jtd j}d}||fS) NrrrFzCannot create a z from a MultiIndex.Tr÷ÚiurÓr¡rÂ)rùrtr³Útupler²r¤r×rPrÔrbr_r]rrrÍr¤r ryr^rOrüZtakerÐrZ_values)rrŒrÖr~r~rÚ!ensure_arraylike_for_datetimelikeDs0
 
 
 
ÿ
ÿÿ 
rÙr‹)r­rpcCsdSrr~©r­r~r~rÚvalidate_periodsfsrÛz int | floatr²cCsdSrr~rÚr~r~rrÛkszint | float | Nonez
int | NonecCsB|dk    r>t |¡rt|ƒ}nt |¡s4td|›ƒ‚tt|ƒ}|S)a9
    If a `periods` argument is passed to the Datetime/Timedelta Array/Index
    constructor, cast it to an integer.
 
    Parameters
    ----------
    periods : None, float, int
 
    Returns
    -------
    periods : None or int
 
    Raises
    ------
    TypeError
        if periods is None, float, or int
    Nzperiods must be a number, got )rZis_floatr²rvrÔrrÚr~r~rrÛps
 
 
 
ztuple[BaseOffset | None, bool]rˆcCsF|dk    r>|dk    r.||kr.td|›d|j›ƒ‚|dkr:|}d}||fS)aÅ
    If the user passes a freq and another freq is inferred from passed data,
    require that they match.
 
    Parameters
    ----------
    freq : DateOffset or None
    inferred_freq : DateOffset or None
    freq_infer : bool
 
    Returns
    -------
    freq : DateOffset or None
    freq_infer : bool
 
    Notes
    -----
    We assume at this point that `maybe_infer_freq` has been called, so
    `freq` is either a DateOffset object or None.
    Nr®r¯F)rîr)r†rÚ
freq_inferr~r~rr¦‹sÿr¦cCs0d}t|tƒs(|dkr t|ƒ}nd}d}||fS)aÓ
    Comparing a DateOffset to the string "infer" raises, so we need to
    be careful about comparisons.  Make a dummy variable `freq_infer` to
    signify the case where the given freq is "infer" and set freq to None
    to avoid comparison trouble later on.
 
    Parameters
    ----------
    freq : {DateOffset, None, str}
 
    Returns
    -------
    freq : {DateOffset, None}
    freq_infer : bool
        Whether we should inherit the freq of passed data.
    Fr£TN)rtrr#)r†rÜr~r~rÚmaybe_infer_freq°s
 
rÝzDatetimeTZDtype | np.dtyper°cCst|tƒr|jSt |¡dS)zç
    Return the unit str corresponding to the dtype's resolution.
 
    Parameters
    ----------
    dtype : DatetimeTZDtype or np.dtype
        If np.dtype, we assume it is a datetime64 dtype.
 
    Returns
    -------
    str
    r)rtrMrr²Z datetime_datar±r~r~rr³Ìs
r³)¤Ú
__future__rrrÚ    functoolsrr(Útypingrrrr    r
r r r rrrrmÚnumpyr²Z pandas._libsrrZpandas._libs.arraysrZpandas._libs.tslibsrrrrrrrrrrrrr r!r"r#Zpandas._libs.tslibs.fieldsr$r%Zpandas._libs.tslibs.np_datetimer&Zpandas._libs.tslibs.timestampsr'Zpandas._typingr(r)r*r+r,r-r.r/r0r1r2r3r4r5Zpandas.compat.numpyr6rˆZ pandas.errorsr7r8r9Zpandas.util._decoratorsr:r;r<Zpandas.util._exceptionsr=Zpandas.core.dtypes.commonr>r?r@rArBrCrDrErFrGrHrIrJrKrLZpandas.core.dtypes.dtypesrMrNZpandas.core.dtypes.genericrOrPZpandas.core.dtypes.missingrQrRZ pandas.corerSrTrUZpandas.core.algorithmsrVrWrXZpandas.core.array_algosrYZpandas.core.arraylikerZZpandas.core.arrays._mixinsr[r\Zpandas.core.arrays.arrow.arrayr]Zpandas.core.arrays.baser^Zpandas.core.arrays.integerr_Zpandas.core.commonÚcoreÚcommonrÄZpandas.core.constructionr`rûrarbZpandas.core.indexersrcrdZpandas.core.ops.commonreZpandas.core.ops.invalidrfrgZpandas.tseriesrhrFrirjrkr“rlrrmrœrÒrÓrÔrÕrŸr*rÙrÛr¦rÝr³r~r~r~rÚ<module>sŠ  4  H  @  D         ~:? I"%