
    I j|                      % S SK Jr  S SKJrJr  S SKJr  S SKrS SKJrJ	r	J
r
JrJrJrJrJrJr  S SKrS SKrS SKJr  S SKJr  S SKJrJr  S S	KJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.  S S
K/J0r0J1r1  S SK2J3r3  S SK4J5r5  S SK6J7r7  S SK8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrBJCrCJDrDJErEJFrFJGrGJHrH  S SKIJJrK  S SKLJMrMJNrNJOrO  S SKPJQrQ  S SKRJSrS  S SKTJUrU  S SKVJWrWJXrXJYrYJZrZJ[r[J\r\  S SK]J^r^J_r_J`r`JaraJbrb  S SKcJdrdJere  S SKfJgrgJhrh  S SKiJjrjJkrkJlrlJmrm  S SKnJoroJprpJqrq  S SKrJsrs  S SKtJuru  S SKvJwrwJxrx  S SKyJzrz  S SK{J|r|  S SK}J~r~  S SKJs  Jr  S S KJrJrJr  S S!KJrJr  S S"KJr  S S#KJrJr  S S$KJr  \(       a   S S%KJrJrJr  S S&K8Jr  S S'KJr  S S(KJrJrJr  \;\ -  rS)\S*'   S9S+ jrS:S, jr " S- S.\u\w5      r " S/ S0\5      r " S1 S2\5      r      S;S3 jr\S<S4 j5       r\S=S5 j5       rS>S6 jr      S?S7 jrS@S8 jrg)A    )annotations)datetime	timedelta)wrapsN)	TYPE_CHECKINGAnyLiteralSelf	TypeAliasUnioncastfinaloverload)using_string_dtype)
get_option)algoslib)
BaseOffsetDayIncompatibleFrequencyNaTNaTTypePeriod
ResolutionTick	Timedelta	Timestampadd_overflowsafeastype_overflowsafeget_unit_from_dtypeiNaTints_to_pydatetimeints_to_pytimedeltaperiods_per_day	timezones	to_offset)RoundToround_nsint64)compare_mismatched_resolutions)get_unit_for_round)integer_op_not_supported)	ArrayLikeAxisIntDatetimeLikeScalarDtypeDtypeObjFInterpolateOptionsNpDtypePositionalIndexer2DPositionalIndexerTupleScalarIndexerSequenceIndexerTakeIndexerTimeAmbiguousTimeNonexistentnpt)function)AbstractMethodErrorInvalidComparisonPerformanceWarning)cache_readonly)find_stack_level)'construct_1d_object_array_from_listlike)is_all_stringsis_integer_dtypeis_list_likeis_object_dtypeis_string_dtypepandas_dtype)
ArrowDtypeCategoricalDtypeDatetimeTZDtypeExtensionDtypePeriodDtype)ABCCategoricalABCMultiIndex)is_valid_na_for_dtypeisna)
algorithmsmissingnanopsops)isin	map_array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)CallableIteratorSequence)TimeUnitIndex)DatetimeArrayPeriodArrayTimedeltaArrayr   DTScalarOrNaTc                :    [        U 5      n[        U 5      " U5      $ N)rg   re   )op_nameops     p/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/pandas/core/arrays/datetimelike.py_make_unpacked_invalid_oprx      s    		!B#G,R00    c                L   ^  [        T 5      U 4S j5       n[        [        U5      $ )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.
c                V  > [        U R                  [        5      (       d  T" U /UQ70 UD6$ U R                  S5      nT" U/UQ70 UD6nU[        L a  [        $ [        U[
        5      (       a  U R                  UR                  5      $ UR                  S5      nU R                  U5      $ )NM8[ns]i8)	
isinstancedtyperM   viewr   r   	_box_func_value_from_backing_data)selfargskwargsarrresultres_i8meths         rw   new_meth"_period_dispatch.<locals>.new_meth   s    $**k22.t.v..ii!c+D+F+S=J	**>>&--00T"&&v..ry   )r   r   r1   )r   r   s   ` rw   _period_dispatchr      s*     4[/ / 8ry   c                    ^  \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   S\S'   \SrS j5       r Ss     StS jjr\	SuS j5       r
SvS jr    SwS jrSxS jrS rSyS jrSzS jr\	S{S j5       rSSS.   S|S jjrS}S~S jjr S     SS jjr\SS j5       r\    SS j5       rSU 4S  jjrSS! jr      SU 4S" jjrSS# jrSSU 4S% jjjr\SS& j5       r\SS' j5       r\SS( j5       r\SSS) jj5       rSSU 4S* jjjrSU 4S+ jjrS, rSS$S-.   SS. jjrS}SS/ jjrS}SS0 jjr S1 r!\"SS2 j5       r#\$SSS3 jj5       r%SS4 jr&SS5 jr'\	SS6 j5       r(\	SrS7 j5       r)\*S4   SS8 jjr+\	SS9 j5       r,\	SS: j5       r-\	SS; j5       r.\	SS< j5       r/\	SrS= j5       r0\	SrS> j5       r1\	SrS? j5       r2S@ r3\4" SA5      r5\4" SB5      r6\4" SC5      r7\4" SD5      r8\4" SE5      r9\4" SF5      r:\4" SG5      r;\4" SH5      r<\4" SI5      r=\4" SJ5      r>\4" SK5      r?\4" SL5      r@\"  SSM j5       rA\"SSN j5       rB\"SSO j5       rC\"SSP j5       rD\"    SSQ j5       rE\"SSR j5       rF\"SSS j5       rG\"SST j5       rHSU rISV rJSSW jrK\"SSX j5       rL\"SSY j5       rM\"SySZ j5       rN\"SS[ j5       rO\"SS\ j5       rPS$S].SS^ jjrQ\R" S_5      S` 5       rSSa rT\R" Sb5      Sc 5       rUSd rVSSe jrWSSf jrX\Y      SU 4Sg jj5       rZ\YSS$Sh.SSi jj5       r[\YSS$Sh.SSj jj5       r\S$SkSl.SSm jjr]\YSS$Sh.SSn jj5       r^SSSo jjr_          SSp jr`SqraU =rb$ )DatetimeLikeArrayMixin   z
Shared Base/Mixin class for DatetimeArray, TimedeltaArray, PeriodArray

Assumes that __new__/__init__ defines:
    _ndarray

and that inheriting subclass implements:
    freq
ztuple[str, ...]_infer_matcheszCallable[[DtypeObj], bool]_is_recognized_dtypeztuple[type, ...]_recognized_scalars
np.ndarray_ndarrayBaseOffset | Nonefreqc                    g)NT r   s    rw   _can_hold_na#DatetimeLikeArrayMixin._can_hold_na   s    ry   NFc                    [        U 5      ert   r=   )r   datar   r   copys        rw   __init__DatetimeLikeArrayMixin.__init__   s     "$''ry   c                    [        U 5      e)z{
The scalar associated with this datelike

* PeriodArray : Period
* DatetimeArray : Timestamp
* TimedeltaArray : Timedelta
r   r   s    rw   _scalar_type#DatetimeLikeArrayMixin._scalar_type   s     "$''ry   c                    [        U 5      e)a  
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.
r   r   values     rw   _scalar_from_string*DatetimeLikeArrayMixin._scalar_from_string       $ "$''ry   c                    [        U 5      e)aA  
Unbox the integer value of a scalar `value`.

Parameters
----------
value : Period, Timestamp, Timedelta, or NaT
    Depending on subclass.

Returns
-------
int

Examples
--------
>>> arr = pd.array(np.array(["1970-01-01"], "datetime64[ns]"))
>>> arr._unbox_scalar(arr[0])
np.datetime64('1970-01-01T00:00:00.000000000')
r   r   s     rw   _unbox_scalar$DatetimeLikeArrayMixin._unbox_scalar  s    * "$''ry   c                    [        U 5      e)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
r   r   others     rw   _check_compatible_with-DatetimeLikeArrayMixin._check_compatible_with  r   ry   c                    [        U 5      e)z9
box function to get object from internal representation
r   )r   xs     rw   r    DatetimeLikeArrayMixin._box_func/  s     "$''ry   c                @    [         R                  " XR                  SS9$ )z!
apply box func to passed values
F)convert)r   	map_inferr   r   valuess     rw   _box_values"DatetimeLikeArrayMixin._box_values5  s     }}V^^UCCry   c                   ^  T R                   S:  a  U 4S j[        [        T 5      5       5       $ U 4S jT R                   5       $ )N   c              3  .   >#    U  H
  nTU   v   M     g 7frt   r   ).0nr   s     rw   	<genexpr>2DatetimeLikeArrayMixin.__iter__.<locals>.<genexpr>=  s     6%5DG%5s   c              3  F   >#    U  H  nTR                  U5      v   M     g 7frt   )r   )r   vr   s     rw   r   r   ?  s     9y!DNN1%%ys   !)ndimrangelenasi8r   s   `rw   __iter__DatetimeLikeArrayMixin.__iter__;  s1    99q=6U3t9%5669tyy99ry   c                8    U R                   R                  S5      $ )za
Integer representation of the values.

Returns
-------
ndarray
    An ndarray with int64 dtype.
r}   )r   r   r   s    rw   r   DatetimeLikeArrayMixin.asi8A  s     }}!!$''ry   r   )na_repdate_formatc                   [        U 5      e)zT
Helper method for astype when converting to strings.

Returns
-------
ndarray[str]
r   )r   r   r   s      rw   _format_native_types+DatetimeLikeArrayMixin._format_native_typesQ  s     "$''ry   c                    SR                   $ )Nz'{}')format)r   boxeds     rw   
_formatter!DatetimeLikeArrayMixin._formatter]  s    }}ry   c                N   [        U5      (       a2  USL a  [        S5      e[        R                  " [	        U 5      [
        S9$ USL a  [        R                  " U R                  US9$ U R                  nU R                  (       a!  UR                  5       nSUR                  l
        U$ )NFz:Unable to avoid copy while creating an array as requested.r   T)rF   
ValueErrornpr`   listobjectr   	_readonlyr   flags	writeable)r   r   r   r   s       rw   	__array__ DatetimeLikeArrayMixin.__array__d  s     5!!u} P  88DJf554<88DMM77>>[[]F%*FLL"ry   c                    g rt   r   r   keys     rw   __getitem__"DatetimeLikeArrayMixin.__getitem__x      @Cry   c                    g rt   r   r   s     rw   r   r   {  s     ry   c                   > [        [        [        [        4   [        TU ]  U5      5      n[        R                  " U5      (       a  U$ [        [        U5      nU R                  U5      Ul	        U$ )zz
This getitem defers to the underlying array, which by-definition can
only handle list-likes, slices, and integer scalars
)
r   r   r
   rr   superr   r   	is_scalar_get_getitem_freq_freq)r   r   r   	__class__s      rw   r   r     s`     eD-/0%'2Ec2JK==  M $'F --c2ry   c                n   [        U R                  [        5      nU(       a  U R                  nU$ U R                  S:w  a  SnU$ [        X5      nSn[        U[        5      (       aD  U R                  b(  UR                  b  UR                  U R                  -  nU$ U R                  n U$ U[        L a  U R                  nU$ [        R                  " U5      (       aY  [        R                  " UR                  [        R                  5      5      n[        U[        5      (       a  U R!                  U5      $ U$ )zL
Find the `freq` attribute to assign to the result of a __getitem__ lookup.
r   N)r~   r   rM   r   r   rc   slicestepEllipsiscomis_bool_indexerr   maybe_booleans_to_slicer   r   uint8r   )r   r   	is_periodr   new_keys        rw   r   (DatetimeLikeArrayMixin._get_getitem_freq  s
    tzz;7	99D& % YY!^D"  &d0CD#u%%99(SXX-A88dii/D   99D   yy
 	 $$S))55chhrxx6HIgu--11'::ry   c                l   > [        XU 5      n[        TU ]	  X5        U(       a  g U R                  5         g rt   )rd   r   __setitem___maybe_clear_freq)r   r   r   no_opr   s       rw   r   "DatetimeLikeArrayMixin.__setitem__  s2     &c$7 	C' ry   c                    g rt   r   r   s    rw   r   (DatetimeLikeArrayMixin._maybe_clear_freq  s     	ry   Tc                t  > [        U5      nU[        :X  a  U R                  R                  S:X  a:  [	        SU 5      n U R
                  n[        UU R                  SU R                  S9nU$ U R                  R                  S:X  a  [        U R                  SS9$ U R                  U R
                  R                  5       5      R                  U R                  5      $ [        U5      (       a^  [!        U["        5      (       a9  U R%                  UR&                  S9nUR)                  5       nUR+                  XQS	S
9$ U R%                  5       $ [!        U["        5      (       a  [,        T	U ]]  XS9$ UR                  S;   aU  U R
                  nU[0        R2                  :w  a  [5        SU R                   SU S35      eU(       a  UR7                  5       nU$ UR                  S;   a  U R                  U:w  d  UR                  S:X  a&  S[9        U 5      R:                   SU 3n[5        U5      e[0        R<                  " XS9$ )NMro   	timestamp)tzboxresomT)r  )r   F)r   r   r   iuzConverting from z to z? is not supported. Do obj.astype('int64').astype(dtype) insteadmMfzCannot cast z
 to dtype r   )rH   r   r   kindr   r   r"   r  _cresor#   r   r   ravelreshapeshaperG   r~   rL   r   na_valueconstruct_array_type_from_sequencer   astyper   int64	TypeErrorr   type__name__asarray)
r   r   r   i8data	converted
arr_objectclsr   msgr   s
            rw   r  DatetimeLikeArrayMixin.astype  s   
 U#F?zz#%OT2 .ww#		 ! C'*4==dCC##DIIOO$56>>tzzJJU##%00!66enn6M
002))*)NN0022~..7>%>33ZZ4 YYF &tzzl$ug >C C 
 MjjD TZZ5%8UZZ3=N !d!4!4 5ZwGCC. ::d00ry   c                    g rt   r   r   s    rw   r   DatetimeLikeArrayMixin.view  s    ry   c                    g rt   r   r   r   s     rw   r   r#  	  s    ?Bry   c                    g rt   r   r%  s     rw   r   r#    r   ry   c                    g rt   r   r%  s     rw   r   r#    s    <?ry   c                "   > [         TU ]  U5      $ rt   )r   r   )r   r   r   s     rw   r   r#    s     w|E""ry   c                2   > [         TU ]  X5        S U l        g rt   )r   _putmaskr   )r   maskr   r   s      rw   r*  DatetimeLikeArrayMixin._putmask  s    %
ry   c                   [        U[        5      (       a   U R                  U5      n[        XR                  5      (       d	  U[        L a%  U R                  U5      n U R                  U5        U$ [        U5      (       d  [        U5      e[        U5      [        U 5      :w  a  [        S5      e U R                  USS9nU R                  U5        U$ ! [        [        4 a  n[        U5      UeS nAff = f! [         a  n[        U5      UeS nAff = f! [         a2  n[        [        USS 5      5      (       a   S nAU$ [        U5      UeS nAff = f)NzLengths must matchT)allow_objectr   )r~   strr   r   r   r>   r   r   r   r   r  rE   r   _validate_listlikerF   getattr)r   r   errs      rw   _validate_comparison_value1DatetimeLikeArrayMixin._validate_comparison_value  sK   eS!!8007
 e5566%3,%%e,E8++E2, # e$$#E**Z3t9$122<//D/I++E2 ;  56 8'.C78  8'.C78  <"75'4#@AA  ,E2;<sM   C C6 /!D C3"C..C36
D DD
EE?EE)allow_listlikeunboxc               D   [        XR                  5      (       a  O[        U[        5      (       a   U R                  U5      nO[        XR                  5      (       a  [        nOt[        U5      (       a  U R                  X5      n[        U5      e[        XR                  5      (       a  U R                  U5      nOU R                  X5      n[        U5      eU(       d  U$ U R                  U5      $ ! [         a"  nU R                  X5      n[        U5      UeSnAff = f)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)r~   r   r/  r   r   _validation_error_messager  rP   r   r   rQ   r   r   )r   r   r5  r6  r2  r   s         rw   _validate_scalar'DatetimeLikeArrayMixin._validate_scalarC  s    0 e..//s##.007
 #5**55E%[[ 00GCC. 7788 %%e,E 00GCC.  L!!%((9  .44UKn#-.s   C3 3
D=DDc                "   [        US5      (       a!  [        USS5      S:  a  UR                   S3nOS[        U5      R                   S3nU(       a  SU R
                  R                   SU S3nU$ SU R
                  R                   S	U S3nU$ )
z
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
r   r   r   z array'zvalue should be a 'z!', 'NaT', or array of those. Got z	 instead.z' or 'NaT'. Got )hasattrr1  r   r  r  r   )r   r   r5  msg_gotr   s        rw   r8  0DatetimeLikeArrayMixin._validation_error_message  s     5'""wufa'@1'DV,G$u+../q1G%d&7&7&@&@%A B**1)=  
 &d&7&7&@&@%A Biy*  
ry   c                r   [        U[        U 5      5      (       aW  U R                  R                  S;   a;  U(       d4  U R                  UR                  :w  a  UR                  U R                  SS9nU$ [        U[        5      (       a2  [        U5      S:X  a#  [        U 5      R                  / U R                  S9$ [        US5      (       aS  UR                  [        :X  a?  [        R                  " U5      U R                  ;   a   [        U 5      R                  U5      n[        U[        5      (       a  [#        U5      n[        U[$        R&                  5      (       a4  UR                  [        :X  a   [        R(                  " USU R                  S9n[+        USS	9n[-        U5      n[+        USS	9n[/        U5      (       a#   [        U 5      R                  XR                  S9n[        UR                  [0        5      (       a>  UR2                  R                  U R                  :X  a  UR5                  5       n[+        USS	9nU(       a  [7        UR                  5      (       a  OF[        U 5      R9                  UR                  5      (       d  U R!                  US5      n[        U5      eU R                  R                  S;   a!  U(       d  UR                  U R                  SS9nU$ ! [        [        4 a1  nU(       a  Us S nA$ U R!                  US5      n[        U5      UeS nAff = f! [         a     GNSf = f)
Nr  Fround_okr   r   r   Tconvert_non_numericdtype_if_all_natextract_numpy)r~   r  r   r  unitas_unitr   r   r  r=  r   r   infer_dtyper   r   r  r8  rB   r   ndarraymaybe_convert_objectsrb   pd_arrayrC   rJ   
categories_internal_get_valuesrF   r   )r   r   r.  r2  r   s        rw   r0  )DatetimeLikeArrayMixin._validate_listlike  s}   eT$Z((zz$&|		UZZ@Wdii%@LeT""s5zQ:,,Rtzz,BB5'""u{{f'< u%)<)<<2 J55e<E eT"";EBEeRZZ((U[[F-B --4$**E e48e48%   T
11%zz1J ekk#344%%3224%e4@OEKK88d00==00=CC. ::??d"<MM$))eM<E_ #I. 2#$88EC#C.c1	26  s6   K$  "L( $L%4L <L%L  L%(
L65L6c                    [        U5      (       a  U R                  U5      nOU R                  USS9$ U R                  U5      $ )NT)r5  )rE   r0  r9  _unboxr   s     rw   _validate_setitem_value.DatetimeLikeArrayMixin._validate_setitem_value  sB    ++E2E((t(DD{{5!!ry   c                    [         R                  " U5      (       a  U R                  U5      nU$ U R                  U5        UR                  nU$ )zJ
Unbox either a scalar with _unbox_scalar or an instance of our own type.
)r   r   r   r   r   r   s     rw   rR  DatetimeLikeArrayMixin._unbox  sH    
 ==&&u-E
  ''.NNEry   c                    SSK Jn  [        XUS9nU" U5      n[        U[        5      (       a  UR                  5       $ UR                  $ )Nr   rm   )	na_action)pandasrn   rW   r~   rO   to_numpyr`   )r   mapperrX  rn   r   s        rw   mapDatetimeLikeArrayMixin.map  s>     49=vfm,,??$$<<ry   c                T   UR                   R                  S;   a#  [        R                  " U R                  [
        S9$ [        U5      n[        U[        U 5      5      (       d  UR                   [        :X  ad  [        R                  " USU R                   S9nUR                   [        :w  a  U R                  U5      $ [        U R                  [        5      U5      $ [        R                  " U R                  [
        S9$ U R                   R                  S;   a'  [        SU 5      n UR                  U R                   5      n U R#                  U5        [        U R(                  UR(                  5      $ ! [$        [&        4 a&    [        R                  " U R                  [
        S9s $ f = f)z
Compute boolean array of whether each value is found in the
passed set of values.

Parameters
----------
values : np.ndarray or ExtensionArray

Returns
-------
ndarray[bool]
fiucr   TrC  r  DatetimeArray | TimedeltaArray)r   r  r   zerosr  boolra   r~   r  r   r   rL  rV   r  r   rI  rH  r   r  r   r   r   s     rw   rV   DatetimeLikeArrayMixin.isin  s?    <<&88DJJd33/7&$t*--||v%22(,%)ZZ
 <<6)99V,,  F 3V<<88DJJd33::??d"8$?D^^DII.F	4 ''/ DIIv{{++ :& 	488DJJd33	4s    E1 13F'&F'c                    U R                   $ rt   )_isnanr   s    rw   rQ   DatetimeLikeArrayMixin.isna>  s    {{ry   c                (    U R                   [        :H  $ )z
return if each value is nan
)r   r!   r   s    rw   re  DatetimeLikeArrayMixin._isnanA  s    
 yyD  ry   c                H    [        U R                  R                  5       5      $ )z:
return if I have any nans; enables various perf speedups
)rb  re  anyr   s    rw   _hasnaDatetimeLikeArrayMixin._hasnaH  s    
 DKKOO%&&ry   c                    U R                   (       aL  U(       a  UR                  U5      nUc  [        R                  n[        R                  " XR
                  U5        U$ )a  
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.
)rk  r  r   nanputmaskre  )r   r   
fill_valuer   s       rw   _maybe_mask_results*DatetimeLikeArrayMixin._maybe_mask_resultsO  sB    & ;;w/!VV
JJv{{J7ry   c                J    U R                   c  gU R                   R                  $ )a^  
Return the frequency object as a string if it's set, otherwise None.

See Also
--------
DatetimeIndex.inferred_freq : Returns a string representing a frequency
    generated by infer_freq.

Examples
--------
For DatetimeIndex:

>>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00"], freq="D")
>>> idx.freqstr
'D'

The frequency can be inferred if there are more than 2 points:

>>> idx = pd.DatetimeIndex(
...     ["2018-01-01", "2018-01-03", "2018-01-05"], freq="infer"
... )
>>> idx.freqstr
'2D'

For PeriodIndex:

>>> idx = pd.PeriodIndex(["2023-1", "2023-2", "2023-3"], freq="M")
>>> idx.freqstr
'M'
N)r   freqstrr   s    rw   rt  DatetimeLikeArrayMixin.freqstrm  s"    @ 99yy   ry   c                r    U R                   S:w  a  g [        R                  " U 5      $ ! [         a     gf = f)al  
Tries to return a string representing a frequency generated by infer_freq.

Returns None if it can't autodetect the frequency.

See Also
--------
DatetimeIndex.freqstr : Return the frequency object as a string if it's set,
    otherwise None.

Examples
--------
For DatetimeIndex:

>>> idx = pd.DatetimeIndex(["2018-01-01", "2018-01-03", "2018-01-05"])
>>> idx.inferred_freq
'2D'

For TimedeltaIndex:

>>> tdelta_idx = pd.to_timedelta(["0 days", "10 days", "20 days"])
>>> tdelta_idx
TimedeltaIndex(['0 days', '10 days', '20 days'],
               dtype='timedelta64[us]', freq=None)
>>> tdelta_idx.inferred_freq
'10D'
r   N)r   rh   
infer_freqr   r   s    rw   inferred_freq$DatetimeLikeArrayMixin.inferred_freq  s:    : 99>	))$// 		s   ) 
66c                p    U R                   nUc  g  [        R                  " U5      $ ! [         a     g f = frt   )rt  r   get_reso_from_freqstrKeyError)r   rt  s     rw   _resolution_obj&DatetimeLikeArrayMixin._resolution_obj  s;    ,,?	33G<< 		s   ( 
55c                .    U R                   R                  $ )z?
Returns day, hour, minute, second, millisecond or microsecond
)r}  attrnamer   s    rw   
resolution!DatetimeLikeArrayMixin.resolution  s     ##,,,ry   c                F    [         R                  " U R                  SS9S   $ )NTtimeliker   r   is_monotonicr   r   s    rw   _is_monotonic_increasing/DatetimeLikeArrayMixin._is_monotonic_increasing      !!$))d;A>>ry   c                F    [         R                  " U R                  SS9S   $ )NTr  r   r  r   s    rw   _is_monotonic_decreasing/DatetimeLikeArrayMixin._is_monotonic_decreasing  r  ry   c                v    [        [        U R                  R                  S5      5      5      U R                  :H  $ )NK)r   rX   r   r  sizer   s    rw   
_is_unique!DatetimeLikeArrayMixin._is_unique  s(    8DIIOOC012dii??ry   c                .   U R                   S:  aY  [        USS 5      U R                  :X  a>  U" U R                  5       UR                  5       5      R	                  U R                  5      $  U R                  U5      n[        USS 5      n[        U5      (       aA  [        R                  " U[         R"                  " U R%                  [&        5      5      U5      nU$ U[(        L a]  U[*        R,                  L a%  [         R.                  " U R                  [0        S9nU$ [         R2                  " U R                  [0        S9nU$ [        U R                  [4        5      (       d  [7        [8        U 5      n U R:                  UR:                  :w  aX  [        U[=        U 5      5      (       d   UR?                  U R@                  SS9nO"URJ                  n[I        U RJ                  XR5      $ U RM                  U5      nU" U RJ                  RO                  S5      URO                  S5      5      n[Q        U5      nU RR                  U-  nURU                  5       (       a)  U[*        R,                  L n	[         RV                  " XHU	5        U$ ! [         aG    [        US5      (       a'  [        UR                  [        5      (       a  [        s $ [        XU5      s $ f = f! [B         a9    [         RD                  " URF                  5      n[I        U RJ                  XR5      s $ f = f)Nr   r  r   r   FrA  r}   ),r   r1  r  r  r  r3  r>   r=  r~   r   rI   NotImplementedrf   rF   rU   comp_method_OBJECT_ARRAYr   r  r  r   r   operatorneonesrb  ra  rM   r   TimelikeOpsr  r  rI  rH  r   r`   asm8r)   r   rR  r   rQ   re  rj  ro  )
r   r   rv   r   r   	other_arr
other_valso_maskr+  
nat_results
             rw   _cmp_method"DatetimeLikeArrayMixin._cmp_method  sX   99q=WUGT:djjHdjjlEKKM2::4::FF	733E:E w-5!! 11BJJt{{623UF MC<X[[ 48 M $**D9M$**k22T*D{{ell*!%d44 %dii% H !&I9$--WW[['
DMM&&t,jood.CDe{{V#88::x{{*JJJvZ0a ! 	7ug&&:ekk:+N+N%%%d266	7: & $&HHUZZ$8	= MM9  s,   +I= $K =A K?KKA LL__pow____rpow____mul____rmul____truediv____rtruediv____floordiv____rfloordiv____mod____rmod__
__divmod____rdivmod__c                    [        U[        5      (       a  UR                  nSnX#4$ [        U[        [        45      (       a  UR
                  nSnX#4$ UR                  nUR                  nX#4$ )z>
Get the int64 values and b_mask to pass to add_overflowsafe.
N)r~   r   ordinalr   r   r   re  r   )r   r   i8valuesr+  s       rw   _get_i8_values_and_mask.DatetimeLikeArrayMixin._get_i8_values_and_mask!  sq     eV$$}}HD ~ 	9566||HD
 ~ <<DzzH~ry   c                   [        U R                  [        5      (       a  U R                  $ [        R
                  " U5      (       d  g[        U R                  [        5      (       a  U R                  $ U R                  R                  S:X  a!  [        U[        5      (       a  U R                  $ U R                  R                  S:X  aS  [        U[        5      (       a>  UR                  b%  [        R                  " UR                  5      (       a  U R                  $ [        R                  " U R                  S5      (       a@  [        U R                  [        5      (       a!  [        U[        5      (       a  U R                  $ [        R                  " U R                  S5      (       a@  [        U[        5      (       a+  [        U R                  [        5      (       a  U R                  $ g)z@
Check if we can preserve self.freq in addition or subtraction.
Nr	  r  )r~   r   rM   r   r   r   r   r  r   r   r  r%   is_utcis_np_dtyper   r   s     rw   _get_arithmetic_result_freq2DatetimeLikeArrayMixin._get_arithmetic_result_freq4  s8    djj+..99u%%		4((99ZZ__#
5)(D(D99JJOOs"5),,!Y%5%5ehh%?%?
 99OODJJ,,499c**5),, 99OODJJ,,5),,499c**99ry   c                   [         R                  " U R                  S5      (       d7  [        S[	        U 5      R
                   S[	        U5      R
                   35      e[        SU 5      n SSKJn  SSK	J
n  U[        Ld   e[        U5      (       aY  U R                  [        R                  " 5       R                  SU R                    S	35      -   nUR"                  " XDR                  S
9$ [%        U5      nU R'                  U5      u  p[        SU 5      n U R)                  U5      u  pV[+        U R,                  [.        R0                  " USS
95      nUR3                  SU R                    S	35      nU" UR4                  U R                   S9nUR3                  SU R                    S	35      nU R7                  U5      n	UR"                  " XxU	S9$ )Nr	  cannot add  and rq   r   ro   )tz_to_dtypezM8[]r   r}   r  rH  r   r   )r   r  r   r  r  r  r   pandas.core.arraysro   pandas.core.arrays.datetimesr  r   rQ   r   to_datetime64r  rH  _simple_newr   _ensure_matching_resosr  r   r   r   r  r   r  r  )
r   r   ro   r  r   other_i8r  
res_valuesr   new_freqs
             rw   _add_datetimelike_scalar/DatetimeLikeArrayMixin._add_datetimelike_scalar^  s   tzz3//d4j112%U8L8L7MN  $d+4<C;; ]]S%6%6%8%?%?#dii[PQ@R%SSF ,,V<<HH% 11%8$d+77>!$))RZZ-MN[[3tyyk!34
uxxdii8[[3tyyk!34
33E:((xPPry   c                    [         R                  " U R                  S5      (       d7  [        S[	        U 5      R
                   S[	        U5      R
                   35      eX-   $ )Nr	  r  r  )r   r  r   r  r  r  r   s     rw   _add_datetime_arraylike.DatetimeLikeArrayMixin._add_datetime_arraylike  sT    tzz3//d4j112%U8L8L7MN 
 |ry   c                    U R                   R                  S:w  a!  [        S[        U 5      R                   35      e[        SU 5      n [        U5      (       a	  U [        -
  $ [        U5      nU R                  U5      u  pU R                  U5      $ )Nr  "cannot subtract a datelike from a ro   )r   r  r  r  r  r   rQ   r   r   r  _sub_datetimelike)r   r   tss      rw   _sub_datetimelike_scalar/DatetimeLikeArrayMixin._sub_datetimelike_scalar  s     ::??c!@dATAT@UVWWOT* ;;#:u..r2%%b))ry   c                   U R                   R                  S:w  a!  [        S[        U 5      R                   35      e[        U 5      [        U5      :w  a  [        S5      e[        SU 5      n U R                  U5      u  pU R                  U5      $ )Nr  r  $cannot add indices of unequal lengthro   )
r   r  r  r  r  r   r   r   r  r  r   s     rw   _sub_datetime_arraylike.DatetimeLikeArrayMixin._sub_datetime_arraylike  s{    ::??c!@dATAT@UVWWt9E
"CDDOT*11%8%%e,,ry   c                   [        SU 5      n SSKJn   U R                  U5        U R                  U5      u  pV[        U R                  [        R                  " U* SS95      nUR                  SU R                   S	35      nU R                  U5      n	[        S
U	5      n	UR                   " XR"                  U	S9$ ! [         a2  n[        U5      R                  SS5      n[        U5      " U5      UeS nAff = f)Nro   r   rq   comparesubtractr}   r   timedelta64[r  zTick | Noner  )r   r  rq   _assert_tzawareness_compatr  r/  replacer  r  r   r   r   r  r   rH  r  r  r   )
r   r   rq   r2  new_messager  r  r  res_m8r  s
             rw   r  (DatetimeLikeArrayMixin._sub_datetimelike  s    OT*5	2++E2
  77>%diiXIT1RS
<		{!!<=33E:x0))&8TT  	2c(**9jAKs)K(c1	2s   B9 9
C5-C00C5c                0   [         R                  " U R                  S5      (       d!  [        S[	        U 5      R
                   35      eSSKJn  [        R                  " UR                  U R                  5      n[        UR                  5      nU" X4S9nXP-   $ )Nr	  zcannot add Period to a r   )rp   r   )r   r  r   r  r  r  pandas.core.arrays.periodrp   r   broadcast_tor  r  rM   r   )r   r   rp   i8valsr   parrs         rw   _add_period"DatetimeLikeArrayMixin._add_period  sr    tzz3//5d4j6I6I5JKLL 	:

;EJJ'6/{ry   c                    [        U 5      ert   r   )r   offsets     rw   _add_offset"DatetimeLikeArrayMixin._add_offset  s    !$''ry   c                   [        U5      (       ay  [        R                  " U R                  SS9R	                  U R
                  R                  5      nUR                  [        5        [        U 5      R                  X R                  S9$ [        SU 5      n [        U5      nU R                  U5      u  pU R                  U5      $ )zC
Add a delta of a timedeltalike

Returns
-------
Same type as self
r}   r   r`  )rQ   r   emptyr  r   r   r   fillr!   r  r  r   r   r  _add_timedeltalike)r   r   
new_valuess      rw   _add_timedeltalike_scalar0DatetimeLikeArrayMixin._add_timedeltalike_scalar  s     ;;$**D9>>t}}?R?RSJOOD!:))*JJ)GG 4d;% 11%8&&u--ry   c                    [        U 5      [        U5      :w  a  [        S5      e[        SU 5      R                  U5      u  pU R	                  U5      $ )zD
Add a delta of a TimedeltaIndex

Returns
-------
Same type as self
r  r`  )r   r   r   r  r  r   s     rw   _add_timedelta_arraylike/DatetimeLikeArrayMixin._add_timedelta_arraylike  sR     t9E
"CDD,d

 
 
' 	 &&u--ry   c                .   U R                  U5      u  p#[        U R                  [        R                  " USS95      nUR                  U R                  R                  5      nU R                  U5      n[        U 5      R                  UU R                  US9$ )Nr}   r   r  )r  r   r   r   r  r   r   r   r  r  r  )r   r   r  r  r  r  r  s          rw   r  )DatetimeLikeArrayMixin._add_timedeltalike  s    77>%diiHD1QR
__T]]%8%89
33E: Dz%%** & 
 	
ry   c                   [        U R                  [        5      (       a;  [        S[	        U 5      R
                   S[	        [        5      R
                   35      e[        R                  " U R                  [        R                  S9nUR                  [        5        UR                  U R                  R                  5      n[	        U 5      R                  UU R                  SS9$ )z
Add pd.NaT to self
zCannot add r  r   Nr  )r~   r   rM   r  r  r  r   r   r  r  r  r  r!   r   r   r  r   r   s     rw   _add_natDatetimeLikeArrayMixin._add_nat  s    
 djj+..d4j112%S	8J8J7KL  $**BHH5DT]]001Dz%%** & 
 	
ry   c                2   [         R                  " U R                  [         R                  S9nUR	                  [
        5        U R                  R                  S;   a+  [        SU 5      n UR                  SU R                   S35      $ UR                  S5      $ )z
Subtract pd.NaT from self
r   r  zDatetimeArray| TimedeltaArrayr  r  ztimedelta64[ns])r   r  r  r  r  r!   r   r  r   r   rH  r  s     rw   _sub_natDatetimeLikeArrayMixin._sub_nat  sq     $**BHH5D::??d"7>D;;dii[:;;;;011ry   c                8   [        U R                  [        5      (       d7  [        S[	        U5      R
                   S[	        U 5      R
                   35      e[        SU 5      n U R                  U5        U R                  U5      u  p#[        U R                  [        R                  " U* SS95      n[        R                  " U Vs/ s H  oPR                  R                  U-  PM     sn5      nUc  U R                   nOU R                   U-  n["        Xg'   U$ s  snf )Ncannot subtract  from rp   r}   r   )r~   r   rM   r  r  r  r   r   r  r   r   r   r  r`   r   basere  r   )r   r   r  r  new_i8_datar   new_datar+  s           rw   _sub_periodlike&DatetimeLikeArrayMixin._sub_periodlike-  s     $**k22"4;#7#7"8tDz?R?R>ST  M4(##E*77>&tyy"**hYd2ST88EAYY^^a/EF>;;D ;;'D Fs   "Dc                   U[         R                  [         R                  4;   d   e[        U5      S:X  a  U R                  S:X  a  U" XS   5      $ [        S5      (       a9  [        R                  " S[        U 5      R                   S3[        [        5       S9  U R                  UR                  :X  d   U R                  UR                  45       eU" U R                  S5      [        R                  " U5      5      nU$ )a  
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   r   performance_warningsz)Adding/subtracting object-dtype array to z not vectorized.)
stacklevelO)r  addsubr   r   r   warningswarnr  r  r?   rA   r  r  r   r  )r   r   rv   r  s       rw   _addsub_object_array+DatetimeLikeArrayMixin._addsub_object_arrayF  s      hllHLL1111u:?tyyA~ d!H%%,--MM;:&&''79"+-	 zzU[[(C4::u{{*CC(C("**U*;<
ry   )skipnac                   US;  a  [        SU S[        U 5       35      e[        [        U5      nU" U R	                  5       4SU0UD6n[        U 5      R                  XPR                  S9$ )N>   cummaxcumminzAccumulation z not supported for r  r   )r  r  r1  rY   r   r  r   )r   namer  r   rv   r   s         rw   _accumulate"DatetimeLikeArrayMixin._accumulatek  sk    ++mD61DT$ZLQRR/6DIIK99&9Dz%%fJJ%??ry   __add__c                F   [        USS 5      n[        U5      nU[        L a  U R                  5       nGO[	        U[
        [        [        R                  45      (       a  U R                  U5      nGO[	        U[        5      (       a[  [        R                  " U R                  S5      (       a5  [        UR                  S9R!                  S5      nU R                  U5      nGO[[	        U["        5      (       a  U R%                  U5      nGO3[	        U[&        [        R(                  45      (       a  U R+                  U5      nGO[	        U[,        5      (       a9  [        R                  " U R                  S5      (       a  U R/                  U5      nGO[        R0                  " U5      (       an  [	        U R                  [2        5      (       d  [5        U 5      e[7        SU 5      nUR9                  XR                  R:                  -  [<        R>                  5      nGO$[        R                  " US5      (       a  U RA                  U5      nO[C        U5      (       a!  U RE                  U[<        R>                  5      nO[        R                  " US5      (       d  [	        U[F        5      (       a  U RI                  U5      $ [K        U5      (       am  [	        U R                  [2        5      (       d  [5        U 5      e[7        SU 5      nUR9                  XR                  R:                  -  [<        R>                  5      nO[L        $ [	        U[        RN                  5      (       aF  [        R                  " UR                  S5      (       a   SS	K(J)n  URT                  " X3R                  S
9$ U$ )Nr   Mmdayssr	  rp   r  r   r  r   )+r1  ra   r   r  r~   r   r   r   timedelta64r  r   r   r  r   r   r   rI  r   r  r   
datetime64r  r   r  
is_integerrM   r+   r   _addsub_int_array_or_scalar_nr  r
  r  rF   r  rK   r  rD   r  rK  r  rq   r  r   r   other_dtyper   tdobjrq   s          rw   r  DatetimeLikeArrayMixin.__add__t  s   eWd3.u5 C<:>--/Fi@AA33E:Fs##

D(I(I(005B33B7Fz**%%e,F"--8992259Fv&&3??4::s+K+K%%e,F^^E"" djj+66.t44}d+C44UYY\\5I8<<XF __[#..2259F[))..uhllCF__[#..*3
 3
 //66k**djj+66.t44}d+C44UYY\\5I8<<XF "!fbjj))coofllC.P.P9!00||LLry   c                $    U R                  U5      $ rt   )r  r   s     rw   __radd__DatetimeLikeArrayMixin.__radd__  s    ||E""ry   __sub__c                T   [        USS 5      n[        U5      nU[        L a  U R                  5       nGO[	        U[
        [        [        R                  45      (       a  U R                  U* 5      nGO[	        U[        5      (       a\  [        R                  " U R                  S5      (       a6  [        UR                  S9R!                  S5      nU R                  U* 5      nGO`[	        U["        5      (       a  U R%                  U* 5      nGO7[	        U[&        [        R(                  45      (       a  U R+                  U5      nGO[        R,                  " U5      (       an  [	        U R                  [.        5      (       d  [1        U 5      e[3        SU 5      nUR5                  XR                  R6                  -  [8        R:                  5      nGOv[	        U[<        5      (       a  U R?                  U5      nGON[        R                  " US5      (       a  U RA                  U* 5      nGO[C        U5      (       a!  U RE                  U[8        R:                  5      nO[        R                  " US5      (       d  [	        U[F        5      (       a  U RI                  U5      nO[	        U[.        5      (       a  U R?                  U5      nO[K        U5      (       am  [	        U R                  [.        5      (       d  [1        U 5      e[3        SU 5      nUR5                  XR                  R6                  -  [8        R:                  5      nO[L        $ [	        U[        RN                  5      (       aF  [        R                  " UR                  S5      (       a   SS	K(J)n  URT                  " X3R                  S
9$ U$ )Nr   r  r  r  rp   r	  r  r   r  r   )+r1  ra   r   r  r~   r   r   r   r  r  r   r   r  r   r   r   rI  r   r  r   r  r  r  rM   r+   r   r   r!  r  r  r   r  r  rF   r  rK   r  rD   r  rK  r  rq   r  r"  s          rw   r*  DatetimeLikeArrayMixin.__sub__  s   eWd3.u5 C<:>--/Fi@AA33UF;Fs##

D(I(I(005B33RC8Fz**%%uf-F"--8992259F^^E"" djj+66.t44}d+C44UYY\\5I8<<XFv&&))%0F __[#..22E6:F[))..uhllCF__[#..*3
 3
 11%8F[11))%0Fk**djj+66.t44}d+C44UYY\\5I8<<XF "!fbjj))coofllC.P.P9!00||LLry   c           	     v   [        USS 5      n[        R                  " US5      =(       d    [        U[        5      nU(       a  [        R                  " U R
                  S5      (       ab  [        R                  " U5      (       a  [        U5      U -
  $ [        U[        5      (       d   SSK	J
n  UR                  " XR
                  S9nX-
  $ U R
                  R                  S:X  a]  [        US5      (       aL  U(       dE  [        S[        U 5      R                    S[        U5      R                    S	UR
                   S
35      e[        U R
                  ["        5      (       aJ  [        R                  " US5      (       a.  [        S[        U 5      R                    SUR
                   35      e[        R                  " U R
                  S5      (       a  [%        SU 5      n U * U-   $ X-
  nUR
                  R                  S:X  a7  [        S[        U 5      R                    S[        U5      R                    35      eU* $ )Nr   r  r	  r   r  r   r  r   [r  rq   )r1  r   r  r~   rK   r   r   r   r   r  ro   r  r  r=  r  r  r  rM   r   )r   r   r#  other_is_dt64ro   flippeds         rw   __rsub__DatetimeLikeArrayMixin.__rsub__  s   eWd3S9 
Z>
 S__TZZ== }}U## '$..e%;<<<%44U++N<ZZ__#w(?(? "4:#6#6"7v;''(%++a9  

K00S__[RU5V5V.tDz/B/B.C6%++WXX__TZZ--($/DEU?",==$"4:#6#6"7vd5k>R>R=ST  xry   c                ~    X-   nUS S  U S S & [        U R                  [        5      (       d  UR                  U l        U $ rt   r~   r   rM   r   r   r   r   r   s      rw   __iadd__DatetimeLikeArrayMixin.__iadd__  7    )Q$**k22DJry   c                ~    X-
  nUS S  U S S & [        U R                  [        5      (       d  UR                  U l        U $ rt   r4  r5  s      rw   __isub__DatetimeLikeArrayMixin.__isub__"  r8  ry   c                   > [         TU ]  XS9$ )N)qsinterpolation)r   	_quantile)r   r=  r>  r   s      rw   r?   DatetimeLikeArrayMixin._quantile.  s     w B DDry   axisr  c                   [         R                  " SU5        [         R                  " XR                  5        [        R
                  " U R                  XS9nU R                  X5      $ )z
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   rA  )nvvalidate_minvalidate_minmax_axisr   rT   nanminr   _wrap_reduction_resultr   rB  r  r   r   s        rw   minDatetimeLikeArrayMixin.min6  I     	F#
ii0t}}4G**488ry   c                   [         R                  " SU5        [         R                  " XR                  5        [        R
                  " U R                  XS9nU R                  X5      $ )z
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   rA  )rD  validate_maxrF  r   rT   nanmaxr   rH  rI  s        rw   maxDatetimeLikeArrayMixin.maxH  rL  ry   r   )r  rB  c                  [        U R                  [        5      (       a"  [        S[	        U 5      R
                   S35      e[        R                  " U R                  X!U R                  5       S9nU R                  X#5      $ )a  
Return the mean value of the Array.

Parameters
----------
skipna : bool, default True
    Whether to ignore any NaT elements.
axis : int, optional, default 0
    Axis for the function to be applied on.

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.

Examples
--------
For :class:`pandas.DatetimeIndex`:

>>> idx = pd.date_range("2001-01-01 00:00", periods=3)
>>> idx
DatetimeIndex(['2001-01-01', '2001-01-02', '2001-01-03'],
              dtype='datetime64[us]', freq='D')
>>> idx.mean()
Timestamp('2001-01-02 00:00:00')

For :class:`pandas.TimedeltaIndex`:

>>> tdelta_idx = pd.to_timedelta([1, 2, 3], unit="D")
>>> tdelta_idx
TimedeltaIndex(['1 days', '2 days', '3 days'],
                dtype='timedelta64[s]', freq=None)
>>> tdelta_idx.mean()
Timedelta('2 days 00:00:00')
zmean is not implemented for zX since the meaning is ambiguous.  An alternative is obj.to_timestamp(how='start').mean()rB  r  r+  )r~   r   rM   r  r  r  rT   nanmeanr   rQ   rH  )r   r  rB  r   s       rw   meanDatetimeLikeArrayMixin.meanZ  st    Z djj+...tDz/B/B.C D7 7  MM$))+
 **488ry   c                   [         R                  " SU5        Ub$  [        U5      U R                  :  a  [	        S5      e[
        R                  " U R                  XS9nU R                  X5      $ )Nr   z abs(axis) must be less than ndimrA  )	rD  validate_medianabsr   r   rT   	nanmedianr   rH  rI  s        rw   medianDatetimeLikeArrayMixin.median  sZ    
2v&D	TYY 6?@@!!$--dJ**488ry   c                    S nU(       a  U R                  5       n[        R                  " U R                  S5      US9u  p4UR                  U R                  R
                  5      n[        [        R                  U5      nU R                  U5      $ )Nr}   )r+  )
rQ   rR   moder   r   r   r   r   rK  r   )r   dropnar+  i8modes_npmodess         rw   _modeDatetimeLikeArrayMixin._mode  sh    99;D__TYYt_4@
,,t}}223rzz7+&&w//ry   c                  U R                   nUR                  S:X  a.  US;   a  [        SU S35      eUS;   a  [        SU SU S35      eOX[        U[        5      (       a.  US;   a  [        SU S	35      eUS;   a  [        SU S
U S35      eOUS;   a  [        SU S	35      eU R
                  R                  S5      nSSKJn	  U	R                  U5      n
U	" XUS9nUR                  " U4UUUS S.UD6nUR                  UR                  ;   a  U$ UR                   S:X  d   eUS;   aw  SSKJn  [        U R                   [        5      (       a  [        S5      e[        SU 5      n SU R                    S3nUR                  U5      nUR"                  " XR                   S9$ UR                  U R
                  R                   5      nU R%                  U5      $ )Nr  )sumprodcumsumcumprodvarskewkurtz,datetime64 type does not support operation 'r<  )rj  allzN' with datetime64 dtypes is no longer supported. Use (obj != pd.Timestamp(0)).z() instead.zPeriod type does not support z operationszK' with PeriodDtype is no longer supported. Use (obj != pd.Period(0, freq)).)rg  ri  rk  rl  rj  z"timedelta64 type does not support r|   r   )WrappedCythonOp)howr  has_dropped_na)	min_countngroupscomp_idsr+  )stdsemr  z-'std' and 'sem' are not valid for PeriodDtyper`  zm8[r  r   )r   r  r  r~   rM   r   r   pandas.core.groupby.opsrn  get_kind_from_how_cython_op_ndim_compatro  cast_blocklistr  rq   r   rH  r  r   )r   ro  rp  rq  rr  idsr   r   npvaluesrn  r  rv   r  rq   	new_dtypes                  rw   _groupby_op"DatetimeLikeArrayMixin._groupby_op  s    

::QQ"NseST UVVn$u 4475E  % {++QQ"?uK PQQn$u 77:e;H  % >>@[QRR ==%%h/;005O..

 

 66R&&&  8+++. 9$**k22 OPP8$?Ddii[*I#3J!--j@P@PQQ__T]]%8%89
&&z22ry   r   returnrb  )NNF)r   Dtype | Noner   rb  r  None)r  ztype[DatetimeLikeScalar])r   r/  r  rr   )r   rr   r  z)np.int64 | np.datetime64 | np.timedelta64)r   rr   r  r  r  r   )r  rj   )r  znpt.NDArray[np.int64])r   zstr | floatr  npt.NDArray[np.object_])F)r   rb  r  zCallable[[object], str])NN)r   zNpDtype | Noner   zbool | Noner  r   )r   r6   r  rr   )r   z(SequenceIndexer | PositionalIndexerTupler  r
   )r   r4   r  zSelf | DTScalarOrNaT)r  r   )r   z,int | Sequence[int] | Sequence[bool] | slicer   zNaTType | Any | Sequence[Any]r  r  r  r  T)r   rb  r  r
   )r   zLiteral['M8[ns]']r  ro   )r   zLiteral['m8[ns]']r  rq   ).)r   r  r  r,   rt   )r+  npt.NDArray[np.bool_]r  r  )r5  rb  r6  rb  )r5  rb  r  r/  )r.  rb  )r  z6np.int64 | np.datetime64 | np.timedelta64 | np.ndarray)rX  zLiteral['ignore'] | None)r   r,   r  r  )r  r  )r   r   r  r   )r  z
str | None)r  zResolution | None)r  r/  )r  z@tuple[int | npt.NDArray[np.int64], None | npt.NDArray[np.bool_]])r  ro   )r   ro   r  ro   )r   zdatetime | np.datetime64r  rq   )r   ro   r  rq   )r   zTimestamp | DatetimeArrayr  rq   )r   r   r  rp   )r   rq   r  r
   )r   zTimedelta | TimedeltaArrayr  r
   )r   zPeriod | PeriodArrayr  r  )r   r  r  r   )r  r/  r  rb  r  r
   )r=  znpt.NDArray[np.float64]r>  r/  r  r
   )rB  AxisInt | Noner  rb  )r  rb  rB  r  )r_  rb  )
ro  r/  rp  rb  rq  intrr  r  rz  znpt.NDArray[np.intp])cr  
__module____qualname____firstlineno____doc____annotations__r@   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r*  r3  r9  r8  r0  rS  r   rR  r\   r\  rV   rQ   re  rk  r!   rq  rt  rx  r}  r  r  r  r  r  rx   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  re   r  r(  r*  r1  r6  r:  r   r?  rJ  rP  rU  r[  rc  r}  __static_attributes____classcell__r   s   @rw   r   r      s    $#44))
  IN('(AE(	(
 ( (((("(	2(.(,(D: 
( 
(  (-$
($
(	 
( AE#2=	( C C5 
 
&<!9! -! 
	!,
71 71r  B BC C? ?# #
"P  %;) 	;)
 ;)z>@D" 
 
" 	  	 2,n ! ! ' ' .24 	< !! !!F ! !F   - - ? ? ? ? @ @7v (	2G(4H'	2G(4H+M:K,^<L,^<L-o>M'	2G(4H*<8J+M:K
	I $ ' 'R Q QB   *-*	* *$ 
- 
- U U& 
 
(.(.$ 
 
 
 
* 2 2&  0 " "H 8< @ i(9 )9v# i(9 )9v'R E#E E 
	E E ,0 9 9" ,0 9 9" &*! 89t /3D 9 90H3 H3 	H3
 H3 H3 "H3 H3ry   r   c                  "    \ rS rSrSrSS jrSrg)DatelikeOpsi  zC
Common ops for DatetimeIndex/PeriodIndex, but not TimedeltaIndex.
c                    U R                  U[        R                  S9n[        5       (       a!  SSKJn  [        X#" [        R                  S9S9$ UR                  [        SS9$ )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 <https://docs.python.org/3/library/datetime.html
#strftime-and-strptime-behavior>`__.

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='str')
)r   r   r   )StringDtyper  r   Fr
  )	r   r   rn  r   rY  r  rM  r  r   )r   r   r   r  s       rw   strftimeDatelikeOps.strftime  sS    Z **{266*R*F+rvv*FGG}}V%}00ry   r   N)r   r/  r  r  )r  r  r  r  r  r  r  r   ry   rw   r  r    s    21ry   r  c                  d  ^  \ rS rSrSr\S 5       r\S 5       r\R                  S$S j5       r\
S%S j5       r\
\S&S j5       5       r\    S'S j5       r\S(S	 j5       r\S)S
 j5       rS*S+S jjrS rS,U 4S jjrS r  S-     S.S jjr  S-     S.S jjr  S-     S.S jjrSSS.S/S jjrSSS.S/S jjrS$S jrS0S jrS1U 4S jjr  S2   S3U 4S jjjr\ S4     S5U 4S jjj5       rS6S7U 4S jjjr          S8S jr SSSS .         S9U 4S! jjjr!\S:S" j5       r"S#r#U =r$$ );r  i0  zC
Common ops for TimedeltaIndex/DatetimeIndex, but not PeriodIndex.
c                    [        U 5      ert   r   )r  r   r   s      rw   _validate_dtypeTimelikeOps._validate_dtype5  s    !#&&ry   c                    U R                   $ )a  
Return the frequency object if it is set, otherwise None.

To learn more about the frequency strings, please see
:ref:`this link<timeseries.offset_aliases>`.

See Also
--------
DatetimeIndex.freq : Return the frequency object if it is set, otherwise None.
PeriodIndex.freq : Return the frequency object if it is set, otherwise None.

Examples
--------
>>> datetimeindex = pd.date_range(
...     "2022-02-22 02:22:22", periods=10, tz="America/Chicago", freq="h"
... )
>>> datetimeindex
DatetimeIndex(['2022-02-22 02:22:22-06:00', '2022-02-22 03:22:22-06:00',
               '2022-02-22 04:22:22-06:00', '2022-02-22 05:22:22-06:00',
               '2022-02-22 06:22:22-06:00', '2022-02-22 07:22:22-06:00',
               '2022-02-22 08:22:22-06:00', '2022-02-22 09:22:22-06:00',
               '2022-02-22 10:22:22-06:00', '2022-02-22 11:22:22-06:00'],
              dtype='datetime64[us, America/Chicago]', freq='h')
>>> datetimeindex.freq
<Hour>
r  r   s    rw   r   TimelikeOps.freq9  s    8 zzry   c                   Ubw  [        U5      nU R                  X5        U R                  R                  S:X  a&  [	        U[
        [        45      (       d  [        S5      eU R                  S:  a  [        S5      eXl
        g )Nr	  (TimedeltaArray/Index freq must be a Tickr   zCannot set freq with ndim > 1)r&   _validate_frequencyr   r  r~   r   r   r  r   r   r   r   s     rw   r   r  W  sh    e$E$$T1zz#%js.L.L JKKyy1} !@AA
ry   c                V   Uc  SU l         gUS:X  a)  U R                   c  [        U R                  5      U l         ggU[        R                  L a  gU R                   c.  [        U5      n[        U 5      R                  " X40 UD6  Xl         g[        U5      n[        XR                   5        g)z
Constructor helper to pin the appropriate `freq` attribute.  Assumes
that self._freq is currently set to any freq inferred in
_from_sequence_not_strict.
Ninfer)r   r&   rx  r   
no_defaultr  r  _validate_inferred_freq)r   r   validate_kwdss      rw   _maybe_pin_freqTimelikeOps._maybe_pin_freqd  s     <DJW_ zz! 't'9'9:
 " S^^# ZZ T?DJ**4GGJ T?D#D**5ry   c           	        UR                   nUR                  S:X  d  XBR                  :X  a  g U R                  " SUS   S[	        U5      UUR
                  S.UD6n[        R                  " UR                  UR                  5      (       d  [        eg! [         a2  nS[        U5      ;   a  Ue[        SU SUR                   35      UeSnAff = f)a%  
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
r   N)startendperiodsr   rH  z	non-fixedInferred frequency 9 from passed values does not conform to passed frequency r   )rx  r  rt  _generate_ranger   rH  r   array_equalr   r   r/  )r  indexr   r   inferredon_freqr2  s          rw   r  TimelikeOps._validate_frequency  s     &&::?h,,6	)) AhE
ZZ G >>%**gll;;   < 	c#h& 	 %hZ 088<~G 	s   A$B 
C-C

Cc                    [        U 5      ert   r   )r  r  r  r  r   r   r   s          rw   r  TimelikeOps._generate_range  s     "#&&ry   c                @    [        U R                  R                  5      $ rt   )r    r   r   r   s    rw   r  TimelikeOps._creso  s    "4==#6#677ry   c                ,    [        U R                  5      $ )a  
The precision unit of the datetime data.

Returns the precision unit for the dtype.
It means the smallest time frame that can be stored within this dtype.

Returns
-------
str
    Unit string representation (e.g. "ns").

See Also
--------
TimelikeOps.as_unit : Converts to a specific unit.

Examples
--------
>>> idx = pd.DatetimeIndex(["2020-01-02 01:02:03.004005006"])
>>> idx.unit
'ns'
>>> idx.as_unit("s").unit
's'
)dtype_to_unitr   r   s    rw   rH  TimelikeOps.unit  s    6 TZZ((ry   Tc                   US;  a  [        S5      e[        R                  " U R                  R                   SU S35      n[	        U R
                  X2S9n[        U R                  [        R                  5      (       a  UR                  nO[        SU 5      R                  n[        XaS9n[        U 5      R                  UUU R                  S9$ )	aZ  
Convert to a dtype with the given unit resolution.

The limits of timestamp representation depend on the chosen resolution.
Different resolutions can be converted to each other through as_unit.

Parameters
----------
unit : {'s', 'ms', 'us', 'ns'}
round_ok : bool, default True
    If False and the conversion requires rounding, raise ValueError.

Returns
-------
same type as self
    Converted to the specified unit.

See Also
--------
Timestamp.as_unit : Convert to the given unit.

Examples
--------
For :class:`pandas.DatetimeIndex`:

>>> idx = pd.DatetimeIndex(["2020-01-02 01:02:03.004005006"])
>>> idx
DatetimeIndex(['2020-01-02 01:02:03.004005006'],
              dtype='datetime64[ns]', freq=None)
>>> idx.as_unit("s")
DatetimeIndex(['2020-01-02 01:02:03'], dtype='datetime64[s]', freq=None)

For :class:`pandas.TimedeltaIndex`:

>>> tdelta_idx = pd.to_timedelta(["1 day 3 min 2 us 42 ns"])
>>> tdelta_idx
TimedeltaIndex(['1 days 00:03:00.000002042'],
                dtype='timedelta64[ns]', freq=None)
>>> tdelta_idx.as_unit("s")
TimedeltaIndex(['1 days 00:03:00'], dtype='timedelta64[s]', freq=None)
)r  msusnsz)Supported units are 's', 'ms', 'us', 'ns'z8[r  rA  ro   r  r  )r   r   r   r  r   r   r~   r   r  rK   r  r  r   )r   rH  rB  r   r  r|  r  s          rw   rI  TimelikeOps.as_unit  s    T ..HIIDJJOO,BtfA67(Q
djj"((++"((Iot,//B'29I Dz%% & 
 	
ry   c                    U R                   UR                   :w  aS  U R                   UR                   :  a  U R                  UR                  5      n X4$ UR                  U R                  5      nX4$ rt   )r  rI  rH  r   s     rw   r  "TimelikeOps._ensure_matching_resos  sZ    ;;%,,&{{U\\)||EJJ/ { dii0{ry   c                   > U[         R                  [         R                  [         R                  4;   a3  [	        U5      S:X  a$  US   U L a  [        X5      " U R                  40 UD6$ [        TU ]   " X/UQ70 UD6$ )Nr   r   )	r   isnanisinfisfiniter   r1  r   r   __array_ufunc__)r   ufuncmethodinputsr   r   s        rw   r  TimelikeOps.__array_ufunc__%  sk    bhh"++66Fq q	T! 5)$--B6BBw&uHvHHHry   c                :   [        U R                  [        5      (       aI  [        SU 5      n U R	                  S 5      nUR                  XX45      nUR	                  U R                  X4S9$ U R                  S5      n[        [        R                  U5      n[        XR                  5      nUS:X  a  U R                  5       $ [        XrU5      n	U R                  U	[        S9nUR                  U R                   R                  5      nU R#                  X`R                  S9$ )Nro   )	ambiguousnonexistentr}   r   rp  r   )r~   r   rK   r   tz_localize_roundr  r   r   rK  r*   r  r   r(   rq  r!   r   r  )
r   r   r^  r  r  naiver   r   nanos	result_i8s
             rw   r  TimelikeOps._round0  s    djj/22.D$$T*E\\$iEF%%9 &   4bjj&)"45A:99;!&6	))))ET]]001jj99ry   c                D    U R                  U[        R                  X#5      $ )av  
Perform round operation on the data to the specified `freq`.

Parameters
----------
freq : str or Offset
    The frequency level to round 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 a ValueError 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 a ValueError 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.

See Also
--------
DatetimeIndex.floor :
    Perform floor operation on the data to the specified `freq`.
DatetimeIndex.snap :
    Snap time stamps to nearest occurring frequency.

Notes
-----
If the timestamps have a timezone, rounding will take place relative to the
local ("wall") time and re-localized to the same timezone. When rounding
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[us]', freq='min')

>>> rng.round('h')
DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
               '2018-01-01 12:00:00'],
              dtype='datetime64[us]', 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[us]

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[us, Europe/Amsterdam]', freq=None)

>>> rng_tz.floor("2h", ambiguous=True)
DatetimeIndex(['2021-10-31 02:00:00+02:00'],
              dtype='datetime64[us, Europe/Amsterdam]', freq=None)
)r  r'   NEAREST_HALF_EVENr   r   r  r  s       rw   roundTimelikeOps.roundF  s    L {{4!:!:ISSry   c                D    U R                  U[        R                  X#5      $ )au  
Perform floor operation on the data to the specified `freq`.

Parameters
----------
freq : str or Offset
    The frequency level to floor 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 a ValueError 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 a ValueError 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.

See Also
--------
DatetimeIndex.floor :
    Perform floor operation on the data to the specified `freq`.
DatetimeIndex.snap :
    Snap time stamps to nearest occurring frequency.

Notes
-----
If the timestamps have a timezone, flooring will take place relative to the
local ("wall") time and re-localized to the same timezone. When flooring
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[us]', freq='min')

>>> rng.floor('h')
DatetimeIndex(['2018-01-01 11:00:00', '2018-01-01 12:00:00',
               '2018-01-01 12:00:00'],
              dtype='datetime64[us]', 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[us]

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[us, Europe/Amsterdam]', freq=None)

>>> rng_tz.floor("2h", ambiguous=True)
DatetimeIndex(['2021-10-31 02:00:00+02:00'],
              dtype='datetime64[us, Europe/Amsterdam]', freq=None)
)r  r'   MINUS_INFTYr  s       rw   floorTimelikeOps.floor  s    L {{4!4!4iMMry   c                D    U R                  U[        R                  X#5      $ )al  
Perform ceil operation on the data to the specified `freq`.

Parameters
----------
freq : str or Offset
    The frequency level to ceil 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 a ValueError 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 a ValueError 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.

See Also
--------
DatetimeIndex.floor :
    Perform floor operation on the data to the specified `freq`.
DatetimeIndex.snap :
    Snap time stamps to nearest occurring frequency.

Notes
-----
If the timestamps have a timezone, ceiling will take place relative to the
local ("wall") time and re-localized to the same timezone. When ceiling
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[us]', freq='min')

>>> rng.ceil('h')
DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
               '2018-01-01 13:00:00'],
              dtype='datetime64[us]', 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[us]

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[us, Europe/Amsterdam]', freq=None)

>>> rng_tz.ceil("h", ambiguous=True)
DatetimeIndex(['2021-10-31 02:00:00+02:00'],
              dtype='datetime64[us, Europe/Amsterdam]', freq=None)
)r  r'   
PLUS_INFTYr  s       rw   ceilTimelikeOps.ceil	  s    L {{4!3!3YLLry   NrA  c               ^    [         R                  " U R                  XU R                  5       S9$ NrS  )rT   nananyr   rQ   r   rB  r  s      rw   rj  TimelikeOps.any	  s    }}T]]499;WWry   c               ^    [         R                  " U R                  XU R                  5       S9$ r  )rT   nanallr   rQ   r  s      rw   rm  TimelikeOps.all	  s!     }}T]]499;WWry   c                    S U l         g rt   r  r   s    rw   r   TimelikeOps._maybe_clear_freq	  s	    
ry   c                >   Uc  O[        U 5      S:X  aV  [        U[        5      (       aA  U R                  R                  S:X  a&  [        U[
        [        45      (       d  [        S5      eOUS:X  d   e[        U R                  5      nU R                  5       nXl        U$ )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
r   r	  r  r  )r   r~   r   r   r  r   r   r  r&   rx  r   r   )r   r   r   s      rw   
_with_freqTimelikeOps._with_freq	  s     <Y!^
4 < <zz#%jc{.K.K JKK 7?"?T//0Diik	
ry   c                   > [        U R                  [        R                  5      (       a  U R                  $ [        TU ]  5       $ rt   )r~   r   r   r   r   _values_for_json)r   r   s    rw   r  TimelikeOps._values_for_json	  s0    djj"((++== w'))ry   Fc                  > U R                   b  U(       aV  U R                   R                  S:  a<  [        R                  " [	        U 5      S-
  SS[        R
                  S9nU S S S2   nX44$ [        R                  " [	        U 5      [        R
                  S9nU R                  5       nX44$ U(       a"  [        S[        U 5      R                   S35      e[        TU ]-  US9$ )Nr   r   r   zThe 'sort' keyword in zu.factorize is ignored unless arr.freq is not None. To factorize with sort, call pd.factorize(obj, sort=True) instead.)use_na_sentinel)r   r   r   aranger   intpr   NotImplementedErrorr  r  r   	factorize)r   r  sortcodesuniquesr   s        rw   r  TimelikeOps.factorize	  s    
 99 		a		#d)a-RrwwGtt* >! 		#d)277;))+>! &(d)<)<(= >= = 
 w  AAry   r   c                X  >^ [         TU ]  X5      nUS   mUS:X  a  U Vs/ s H  n[        U5      (       d  M  UPM     nnTR                  bW  [	        U4S jU 5       5      (       a=  [        US S USS  SS9n[	        U4S jU 5       5      (       a  TR                  nXcl        U$ s  snf )Nr   c              3  T   >#    U  H  oR                   TR                   :H  v   M     g 7frt   r   )r   r   r%  s     rw   r   0TimelikeOps._concat_same_type.<locals>.<genexpr>	  s     +R	1FFchh,>	s   %(r  r   T)strictc              3  ^   >#    U  H"  oS    S   TR                   -   US   S    :H  v   M$     g7f)r   r  r   Nr  )r   pairr%  s     rw   r   r  	  s-     NAwr{SXX-a;s   *-)r   _concat_same_typer   r   rm  zipr   )	r  	to_concatrB  new_objr   pairsr  r%  r   s	          @rw   r  TimelikeOps._concat_same_type	  s     '+I<l19 %.8IqQII8xx#+R	+R(R(RIcrNIabM$GNNNN"xxH$,M 9s
   B'B'c                D   > [         TU ]  US9nU R                  Ul        U$ )N)order)r   r   r   r   )r   r  r  r   s      rw   r   TimelikeOps.copy	  s#    ',U,+		ry   c          
        US:w  a  [         eU(       d  U R                  n	OU R                  R                  5       n	[        R                  " U	4UUUUUUS.UD6  U(       d  U $ [        U 5      R                  XR                  S9$ )z"
See NDFrame.interpolate.__doc__.
linear)r  rB  r  limitlimit_direction
limit_arear   )r  r   r   rS   interpolate_2d_inplacer  r  r   )
r   r  rB  r  r  r  r  r   r   out_datas
             rw   interpolateTimelikeOps.interpolate	  s      X%%}}H}}))+H&&		
+!		
 		
 KDz%%hjj%AAry   )
allow_fillrp  rB  c                 > [         TU ]  XX4S9n[        R                  " U[        R                  S9n[
        R                  " U[        U 5      5      n[        U[        5      (       a  U R                  U5      nXul        U$ )N)indicesr  rp  rB  r   )r   taker   r  r  r   maybe_indices_to_slicer   r~   r   r   r   )	r   r  r  rp  rB  r   maybe_slicer   r   s	           rw   r  TimelikeOps.take
  sp     z  
 **WBGG400#d)Dk5))))+6DLry   c                   [         R                  " U R                  5      (       d  gU R                  nU[        :g  n[        U R                  5      n[        U5      n[        R                  " X!U-  S:g  5      R                  5       S:H  nU$ )z
Check if we are round times at midnight (and no timezone), which will
be given a more compact __repr__ than other cases. For TimedeltaArray
we are checking for multiples of 24H.
Fr   )
r   r  r   r   r!   r    r$   r   logical_andrf  )r   
values_intconsider_valuesr  ppd	even_dayss         rw   _is_dates_onlyTimelikeOps._is_dates_only(
  st     tzz**YY
$,"4::.d# NN?4D4IJNNPTUU	ry   r  r  )r  dictr  r  )r   r   r  r  )r  
int | Noner  r
   )r  r  )r  rl   r  )rH  rl   rB  rb  r  r
   )r  znp.ufuncr  r/  )raiser+  )r  r9   r  r:   r  r
   )rB  r  r  rb  r  rb  r  r  )TF)r  rb  r  rb  )r   )r
  zSequence[Self]rB  r-   r  r
   )C)r  r/  r  r
   )
r  r2   rB  r  r  rn   r   rb  r  r
   )
r  r8   r  rb  rp  r   rB  r-   r  r
   r  )%r  r  r  r  r  classmethodr  r  r   setterr   r  r  r  r@   r  rH  rI  r  r  r  r  r  r  rj  rm  r   r  r  r  r  r   r  r  r'  r  r  r  s   @rw   r  r  0  s    ' '  : 
[[
 
 6 6@ (  (T '",'	' ' 8 8 ) )8<
@	I:2 $+'.	fT !fT %	fT
 
fTV $+'.	fN !fN %	fN
 
fNV $+'.	fM !fM %	fM
 
fMV -1 X -1 X@* !%BB B B2  !  
	 * 
$B #$B 	$B
 $B $B 
$BT ! 	
   
 0  ry   r  c                ^   [        U S5      (       dN  [        U [        [        45      (       d%  [        R
                  " U 5      S:X  a  [        U 5      n [        U 5      n SnO.[        U [        5      (       a  [        SU S35      e[        U SS9n [        U [        5      (       d/  [        U [        5      (       a3  U R                  R                  S;   a  U R                  S	[        S
9n SnX4$ [        U [        5      (       a%  U R!                  5       n U R                  5       n SnX4$ [        U [        R"                  [$        45      (       d  [        R&                  " U 5      n X4$ [        U [(        5      (       a4  U R*                  R-                  U R.                  [0        S9R2                  n SnX4$ )Nr   r   FzCannot create a z from a MultiIndex.TrF  r  r  r  r  )r=  r~   r   tupler   r   rB   rO   r  rb   r_   r]   r   r  rZ  r!   _maybe_convert_datelike_arrayrK  r^   r  rN   rN  r  r  r   _values)r   r   cls_names      rw   !ensure_arraylike_for_datetimeliker4  B
  sl    4!!$u..2774=A3E:D6t<	D-	(	(*8*4GHIIT6$%%4,--$**//T2I}}Wt}4  : 
D-	.	.113}} : rzz>:;;zz$ : 
D.	)	) ##DJJ3#?GG:ry   c                    g rt   r   r  s    rw   validate_periodsr7  i
  s    -0ry   c                    g rt   r   r6  s    rw   r7  r7  m
  s    +.ry   c                ^    U b)  [         R                  " U 5      (       d  [        SU  35      eU $ )z
If a `periods` argument is passed to the Datetime/Timedelta Array/Index
constructor, cast it to an integer.

Parameters
----------
periods : None, int

Returns
-------
periods : None or int

Raises
------
TypeError
    if periods is not None or int
z periods must be an integer, got )r   r  r  r6  s    rw   r7  r7  q
  s2    $ 3>>'#:#::7)DEE Nry   c                \    Ub(  U b   X:w  a  [        SU SU R                   35      eU c  Un U $ )z
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

Returns
-------
freq : DateOffset or None
r  r  )r   rt  )r   rx  s     rw   r  r  
  sM        5%m_ 5?<<." 
 < DKry   c                   [        U [        5      (       a  U R                  $ [        U [        5      (       a6  U R                  S;  a  [        SU < S35      eU R                  R                  $ [        R                  " U 5      S   $ )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  zdtype=z does not have a resolution.r   )	r~   rK   rH  rI   r  r   pyarrow_dtyper   datetime_datar   s    rw   r  r  
  sq     %))zz	E:	&	&::T!x'CDEE""'''E"1%%ry   )ru   r/  )r   r1   r  r1   )r   rb  r3  r/  r  ztuple[ArrayLike, bool])r  r  r  r  )r  r  r  r  )r  r*  r  r*  )r   r   rx  r   r  r   )r   z'DatetimeTZDtype | np.dtype | ArrowDtyper  r/  )
__future__r   r   r   	functoolsr   r  typingr   r   r	   r
   r   r   r   r   r   r  numpyr   pandas._configr   pandas._config.configr   pandas._libsr   r   pandas._libs.tslibsr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   pandas._libs.tslibs.fieldsr'   r(   pandas._libs.tslibs.np_datetimer)   pandas._libs.tslibs.timedeltasr*   pandas._libs.tslibs.timestampsr+   pandas._typingr,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   pandas.compat.numpyr<   rD  pandas.errorsr=   r>   r?   pandas.util._decoratorsr@   pandas.util._exceptionsrA   pandas.core.dtypes.castrB   pandas.core.dtypes.commonrC   rD   rE   rF   rG   rH   pandas.core.dtypes.dtypesrI   rJ   rK   rL   rM   pandas.core.dtypes.genericrN   rO   pandas.core.dtypes.missingrP   rQ   pandas.corerR   rS   rT   rU   pandas.core.algorithmsrV   rW   rX   pandas.core.array_algosrY   pandas.core.arraylikerZ   pandas.core.arrays._mixinsr[   r\   pandas.core.arrays.arrow.arrayr]   pandas.core.arrays.baser^   pandas.core.arrays.integerr_   pandas.core.commoncorecommonr   pandas.core.constructionr`   rM  ra   rb   pandas.core.indexersrc   rd   pandas.core.ops.commonre   pandas.core.ops.invalidrf   rg   pandas.tseriesrh   collections.abcri   rj   rk   rl   rY  rn   r  ro   rp   rq   rr   r  rx   r   r   r  r  r4  r7  r  r  r   ry   rw   <module>re     s   "  
 
 
   - ,     * K = C    $ / 
 5 K  
  
 ? * ? 2 3     
 <
 '  (  .7y 71
2k3X'B k3\171( 71tK( Kd$$ #$$N 
 0 
 0 
 . 
 .2
,=:&ry   