
    |ocha                      d dl mZ d dlmZmZ d dlmZ d dlZd dlmZm	Z	m
Z
mZmZmZmZmZ d dlZd dlZd dlmZ d dlmZmZ d dlmZ d d	lmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ d d
l,m-Z-m.Z. d dl/m0Z0 d dl1m2Z2 d dl3m4Z4 d dl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZE d dlFmGZH d dlImJZJmKZKmLZL d dlMmNZNmOZOmPZP d dlQmRZR d dlSmTZT d dlUmVZVmWZWmXZXmYZYmZZZm[Z[ d dl\m]Z]m^Z^m_Z_m`Z`maZa d dlbmcZcmdZd d dlemfZfmgZg d dlhmiZimjZjmkZkmlZl d dlmmnZnmoZompZp d dlqmrZr d dlsmtZt d dlumvZvmwZw d dlxmyZy d dlzm{Z{ d dl|m}Z} d dl~mc mZ d d lmZmZmZ d d!lmZmZ d d"lmZ d d#lmZmZ d d$lmZ erd d%lmZmZ d d&lmZ d d'lmZmZmZ ee8ef   Zd:d(Zd;d)Z G d* d+etev      Z G d, d-e      Zd.Zd/Zd0Zd1Z G d2 d3e      Z	 	 	 	 	 	 d<d4Zed=d5       Zed>d6       Zd?d7Z	 	 	 	 	 	 d@d8ZdAd9Zy)B    )annotations)datetime	timedelta)wrapsN)TYPE_CHECKINGAnyCallableLiteralUnioncastfinaloverload)using_string_dtype)algoslib)NDArrayBacked)
BaseOffset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	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SelfSequenceIndexerTimeAmbiguousTimeNonexistentnpt)function)AbstractMethodErrorInvalidComparisonPerformanceWarning)AppenderSubstitution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)IteratorSequenceIndex)DatetimeArrayPeriodArrayTimedeltaArrayc                :    t        |       } t        |       |      S N)rf   rd   )op_nameops     n/mnt/ACDE16A4DE16673C/PROJECTS/MIS_PORTAL/venv/lib/python3.12/site-packages/pandas/core/arrays/datetimelike.py_make_unpacked_invalid_oprt      s    		!B,#G,R00    c                J     t                fd       }t        t        |      S )z
    For PeriodArray methods, dispatch to DatetimeArray and re-wrap the results
    in PeriodArray.  We cannot use ._ndarray directly for the affected
    methods because the i8 data has different semantics on NaT values.
    c                @   t        | j                  t              s | g|i |S | j                  d      } |g|i |}|t        u rt        S t        |t
              r| j                  |j                        S |j                  d      }| j                  |      S )NM8[ns]i8)	
isinstancedtyperL   viewr   r   	_box_func_value_from_backing_data)selfargskwargsarrresultres_i8meths         rs   new_methz"_period_dispatch.<locals>.new_meth   s    $**k2.t.v..ii!c+D+F+S=J	*>>&--00T"&&v..ru   )r   r   r.   )r   r   s   ` rs   _period_dispatchr      s*     4[/ / 8ru   c                      e Zd ZU dZded<   ded<   ded<   ded	<   d
ed<   edod       Z	 dp	 	 	 	 	 dqdZedrd       Z	dsdZ
	 	 	 	 dtdZdudZd ZdvdZdwdZedxd       Zddd	 	 	 dydZdzd{dZ	 d|	 	 	 	 	 d}dZed~d       Ze	 	 	 	 dd       Zd fdZdd Z	 	 	 	 	 	 d fd!Zdd"Zdd fd$Zedd%       Zedd&       Zedd'       Zeddd(       Zdd fd)Zd* Zdd#d+	 	 	 dd,Zdzdd-Zdzdd.Zd/ Ze dd0       Z!e"dd1       Z#dd2Z$dd3Z%edd4       Z&edod5       Z'e(df	 	 	 dd6Z)edd7       Z*edd8       Z+edd9       Z,edd:       Z-edod;       Z.edod<       Z/edod=       Z0d> Z1 e2d?      Z3 e2d@      Z4 e2dA      Z5 e2dB      Z6 e2dC      Z7 e2dD      Z8 e2dE      Z9 e2dF      Z: e2dG      Z; e2dH      Z< e2dI      Z= e2dJ      Z>e 	 	 ddK       Z?e ddL       Z@e ddM       ZAe ddN       ZBe 	 	 	 	 ddO       ZCe ddP       ZDe ddQ       ZEe ddR       ZFdS ZGdT ZHddUZIe ddV       ZJe dW        ZKe dX        ZLe ddY       ZMe ddZ       ZNd#d[dd\ZO ePd]      d^        ZQd_ ZR ePd`      da        ZSdb ZTddcZUdddZVeW	 	 	 	 	 	 d fde       ZXeWdd#dfddg       ZYeWdd#dfddh       ZZd#didjddkZ[eWdd#dfddl       Z\dddmZ]	 	 	 	 	 	 	 	 	 	 ddnZ^ xZ_S )DatetimeLikeArrayMixinz
    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                     y)NT r   s    rs   _can_hold_naz#DatetimeLikeArrayMixin._can_hold_na   s    ru   NFc                    t        |       rp   r:   )r   datar{   r   copys        rs   __init__zDatetimeLikeArrayMixin.__init__   s     "$''ru   c                    t        |       )z
        The scalar associated with this datelike

        * PeriodArray : Period
        * DatetimeArray : Timestamp
        * TimedeltaArray : Timedelta
        r   r   s    rs   _scalar_typez#DatetimeLikeArrayMixin._scalar_type   s     "$''ru   c                    t        |       )ay  
        Construct a scalar type from a string.

        Parameters
        ----------
        value : str

        Returns
        -------
        Period, Timestamp, or Timedelta, or NaT
            Whatever the type of ``self._scalar_type`` is.

        Notes
        -----
        This should call ``self._check_compatible_with`` before
        unboxing the result.
        r   r   values     rs   _scalar_from_stringz*DatetimeLikeArrayMixin._scalar_from_string       $ "$''ru   c                    t        |       )a  
        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])
        numpy.datetime64('1970-01-01T00:00:00.000000000')
        r   r   s     rs   _unbox_scalarz$DatetimeLikeArrayMixin._unbox_scalar  s    * "$''ru   c                    t        |       )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     rs   _check_compatible_withz-DatetimeLikeArrayMixin._check_compatible_with  r   ru   c                    t        |       )zI
        box function to get object from internal representation
        r   )r   xs     rs   r}   z DatetimeLikeArrayMixin._box_func/  s     "$''ru   c                F    t        j                  || j                  d      S )z1
        apply box func to passed values
        F)convert)r   	map_inferr}   )r   valuess     rs   _box_valuesz"DatetimeLikeArrayMixin._box_values5  s     }}VT^^UCCru   c                      j                   dkD  r fdt        t                     D        S  fd j                  D        S )N   c              3  (   K   | ]	  }|     y wrp   r   ).0nr   s     rs   	<genexpr>z2DatetimeLikeArrayMixin.__iter__.<locals>.<genexpr>=  s     6DG6s   c              3  @   K   | ]  }j                  |        y wrp   )r}   )r   vr   s     rs   r   z2DatetimeLikeArrayMixin.__iter__.<locals>.<genexpr>?  s     9!DNN1%9s   )ndimrangelenasi8r   s   `rs   __iter__zDatetimeLikeArrayMixin.__iter__;  s1    99q=6U3t9%5669tyy99ru   c                8    | j                   j                  d      S )z
        Integer representation of the values.

        Returns
        -------
        ndarray
            An ndarray with int64 dtype.
        ry   )r   r|   r   s    rs   r   zDatetimeLikeArrayMixin.asi8A  s     }}!!$''ru   r   )na_repdate_formatc                   t        |       )z|
        Helper method for astype when converting to strings.

        Returns
        -------
        ndarray[str]
        r   )r   r   r   s      rs   _format_native_typesz+DatetimeLikeArrayMixin._format_native_typesQ  s     "$''ru   c                    dj                   S )Nz'{}')format)r   boxeds     rs   
_formatterz!DatetimeLikeArrayMixin._formatter]  s    }}ru   c                   t        |      rL|du r$t        j                  dt        t	                      t        j                  t        |       t              S |du r!t        j                  | j                  |      S | j                  S )NFaS  Starting with NumPy 2.0, the behavior of the 'copy' keyword has changed and passing 'copy=False' raises an error when returning a zero-copy NumPy array is not possible. pandas will follow this behavior starting with pandas 3.0.
This conversion to NumPy requires a copy, but 'copy=False' was passed. Consider using 'np.asarray(..)' instead.
stacklevelr{   T)
rE   warningswarnFutureWarningr@   npr_   listobjectr   )r   r{   r   s      rs   	__array__z DatetimeLikeArrayMixin.__array__d  sl     5!u}0 "/1	 88DJf554<88DMM77}}ru   c                     y rp   r   r   items     rs   __getitem__z"DatetimeLikeArrayMixin.__getitem__{      ru   c                     y rp   r   r   s     rs   r   z"DatetimeLikeArrayMixin.__getitem__  s    
 	ru   c                    t        dt        | 	  |            }t        j                  |      r|S t        t
        |      }| j                  |      |_        |S )z
        This getitem defers to the underlying array, which by-definition can
        only handle list-likes, slices, and integer scalars
        zUnion[Self, DTScalarOrNaT])r   superr   r   	is_scalarr4   _get_getitem_freq_freq)r   keyr   	__class__s      rs   r   z"DatetimeLikeArrayMixin.__getitem__  sR     2EG4G4LM== M $'F--c2ru   c                :   t        | j                  t              }|r| j                  }|S | j                  dk7  rd}|S t        | |      }d}t        |t              rA| j                  '|j                  |j                  | j                  z  }|S | j                  }|S |t        u r| j                  }|S t        j                  |      rSt        j                  |j                  t        j                              }t        |t              r| j!                  |      S |S )z\
        Find the `freq` attribute to assign to the result of a __getitem__ lookup.
        r   N)rz   r{   rL   r   r   rb   slicestepEllipsiscomis_bool_indexerr   maybe_booleans_to_slicer|   r   uint8r   )r   r   	is_periodr   new_keys        rs   r   z(DatetimeLikeArrayMixin._get_getitem_freq  s    tzz;7	99D& % YY!^D"  &dC0CD#u%99(SXX-A88dii/D   99D   yy
 	 $$S)55chhrxx6HIgu-11'::ru   c                f    t        |||       }t        | 	  ||       |ry | j                          y rp   )rc   r   __setitem___maybe_clear_freq)r   r   r   no_opr   s       rs   r   z"DatetimeLikeArrayMixin.__setitem__  s6     &c5$7 	C' ru   c                     y rp   r   r   s    rs   r   z(DatetimeLikeArrayMixin._maybe_clear_freq  s     	ru   Tc                `   t        |      }|t        k(  r| j                  j                  dk(  r=t	        d|       } | j
                  }t        || j                  d| j                        }|S | j                  j                  dk(  rt        | j                  d      S | j                  | j
                  j                               j                  | j                        S t        |      r`t!        |t"              r@| j%                  |j&                        }|j)                         }|j+                  ||d	
      S | j%                         S t!        |t"              rt,        	| ]  ||      S |j                  dv rO| j
                  }|t0        j2                  k7  rt5        d| j                   d| d      |r|j7                         }|S |j                  dv r| j                  |k7  s|j                  dk(  r&dt9        |       j:                   d| }t5        |      t1        j<                  | |      S )NMrl   	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   )rG   r   r{   kindr   r   r    r   _cresor!   r   r   ravelreshapeshaperF   rz   rK   r   na_valueconstruct_array_type_from_sequencer   astyper   int64	TypeErrorr   type__name__asarray)
r   r{   r   i8data	converted
arr_objectclsr   msgr   s
            rs   r   zDatetimeLikeArrayMixin.astype  s   
 U#F?zz#%OT2 .ww#		 ! C'*4==dCC##DIIOO$56>>tzzJJU#%0!66enn6M
002))*E)NN0022~.7>%d>33ZZ4 YYF &tzzl$ug >C C 
 MjjD TZZ5%8UZZ3=N !d!4!4 5ZwGCC. ::d%00ru   c                     y rp   r   r   s    rs   r|   zDatetimeLikeArrayMixin.view	  r   ru   c                     y rp   r   r   r{   s     rs   r|   zDatetimeLikeArrayMixin.view  r   ru   c                     y rp   r   r  s     rs   r|   zDatetimeLikeArrayMixin.view  r   ru   c                     y rp   r   r  s     rs   r|   zDatetimeLikeArrayMixin.view  r   ru   c                "    t         |   |      S rp   )r   r|   )r   r{   r   s     rs   r|   zDatetimeLikeArrayMixin.view  s     w|E""ru   c                   t        |t              r	 | j                  |      }t        || j                        s|t        u r%| j                  |      }	 | j                  |       |S t        |      st        |      t        |      t        |       k7  rt        d      	 | j                  |d      }| j                  |       |S # t        t        f$ r t        |      w xY w# t        t        f$ r}t        |      |d }~ww xY w# t        t        f$ r.}t        t        |dd             rnt        |      |Y d }~|S d }~ww xY w)NzLengths must matchT)allow_objectr{   )rz   strr   
ValueErrorr   r;   r   r   r   r   r  rD   r   _validate_listlikerE   getattr)r   r   errs      rs   _validate_comparison_valuez1DatetimeLikeArrayMixin._validate_comparison_value#  sM   eS!/007
 eT556%3,%%e,E8++E2, # e$#E**Z3t9$122<//D/I++E2 ;  56 /'../ 45 8'.C78 45 <"75'4#@A+E2;  <s;   C C# $D C #D2C>>DE#D>>E)allow_listlikeunboxc                  t        || j                        rnt        |t              r	 | j                  |      }nt        || j                        rt        }nmt        |      r| j                  ||      }t        |      t        || j                        r| j                  |      }n| j                  ||      }t        |      |s|S | j                  |      S # t        $ r#}| j                  ||      }t        |      |d}~ww xY w)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)rz   r   r  r   r  _validation_error_messager  rO   r{   r   rP   r   r   )r   r   r  r  r  r	  s         rs   _validate_scalarz'DatetimeLikeArrayMixin._validate_scalarG  s    0 eT../s#.007
 #5$**5E%[ 00GCC. t778 %%e,E 00GCC.  L!!%((9  .44UNKn#-.s   C 	D#DDc                   t        |d      r t        |dd      dkD  r|j                   d}ndt        |      j                   d}|rd| j
                  j                   d| d}|S d| j
                  j                   d	| d}|S )
a+  
        Construct an exception message on validation error.

        Some methods allow only scalar inputs, while others allow either scalar
        or listlike.

        Parameters
        ----------
        allow_listlike: bool, default False

        Returns
        -------
        str
        r{   r   r   z array'zvalue should be a 'z!', 'NaT', or array of those. Got z	 instead.z' or 'NaT'. Got )hasattrr  r{   r  r  r   )r   r   r  msg_gotr	  s        rs   r  z0DatetimeLikeArrayMixin._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*  
ru   c                   t        |t        |             r9| j                  j                  dv r|s|j	                  | j
                  d      }|S t        |t              r4t        |      dk(  r&t        |       j                  g | j                        S t        |d      rO|j                  t        k(  r<t        j                  |      | j                  v r	 t        |       j                  |      }t#        |d      }t%        |      }t#        |d      }t'        |      r'	 t        |       j                  || j                        }t        |j                  t(              r@|j*                  j                  | j                  k(  r|j-                         }t#        |d      }|rt/        |j                        rnAt        |       j1                  |j                        s| j!                  |d      }t        |      | j                  j                  dv r|s|j	                  | j
                  d      }|S # t        t        f$ r$ |r|cY S | j!                  |d      }t        |      w xY w# t        $ r Y .w xY w)	Nr   Fround_okr   r   r{   Textract_numpy)rz   r  r{   r   as_unitunitr   r   r   r  r   r   infer_dtyper   r  r  r  ra   pd_arrayrB   rI   
categories_internal_get_valuesrE   r   )r   r   r  r	  s       rs   r  z)DatetimeLikeArrayMixin._validate_listlike  s   eT$Z(zz$&|dii%@LeT"s5zQ:,,Rtzz,BB5'"u{{f'< u%)<)<<) J55e<E e48e48%  T
11%tzz1J ekk#34%%3224%e4@OEKK8d00=00=CC. ::??d"<MM$))eM<EO #I. )#$88EC#C.(	)&  s$   H1 &I' 1I$I$'	I43I4c                    t        |      r| j                  |      }n| j                  |d      S | j                  |      S )NT)r  )rD   r  r  _unboxr   s     rs   _validate_setitem_valuez.DatetimeLikeArrayMixin._validate_setitem_value  s?    ++E2E((t(DD{{5!!ru   c                    t        j                  |      r| j                  |      }|S | j                  |       |j                  }|S )zZ
        Unbox either a scalar with _unbox_scalar or an instance of our own type.
        )r   r   r   r   r   r   s     rs   r-  zDatetimeLikeArrayMixin._unbox  sE    
 ==&&u-E
  ''.NNEru   c                    ddl m} t        | ||      } ||      }t        |t              r|j                         S |j                  S )Nr   rj   )	na_action)pandasrk   rV   rz   rN   to_numpyr_   )r   mapperr1  rk   r   s        rs   mapzDatetimeLikeArrayMixin.map  s=     49=vfm,??$$<<ru   c                   |j                   j                  dv r%t        j                  | j                  t
              S t        |      }t        |t        |             sg d}|j                   t        k(  rt        j                  |d| j                         }|j                   t        k7  r| j                  |      S t        j                  |d      }||vrN|dk(  rnHd	|v rt        | j                  t              |      S t        j                  | j                  t
              S 	 t        |       j                  |      }t!        j"                  d
| j                    dt$        t'                      | j                   j                  dv r't+        d|       } |j-                  | j.                        }	 | j1                  |       t        | j4                  |j4                        S # t(        $ r" t        | j                  t              |      cY S w xY w# t2        t(        f$ r( t        j                  | j                  t
              cY S w xY w)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   )r   timedelta64r   
datetime64dateperiodT)convert_non_numericdtype_if_all_natFskipnastringmixedz"The behavior of 'isin' with dtype=z and castable values (e.g. strings) is deprecated. In a future version, these will not be considered matching by isin. Explicitly cast to the appropriate dtype before calling isin instead.r   r   DatetimeArray | TimedeltaArray)r{   r   r   zerosr   boolr`   rz   r  r   r   maybe_convert_objectsrU   r(  r   r   r   r   r   r@   r  r   r&  r'  r   r  r   )r   r   	inferableinferreds       rs   rU   zDatetimeLikeArrayMixin.isin  s    <<&88DJJd33/7&$t*-I ||v%22(,%)ZZ
 <<6)99V,,??6%@9,8+ H,#DKK$7@@!xx

$??d226: 8 E, ,
 "/1	 ::??d"8$?D ^^DII.F	4 ''/ DIIv{{++?  9DKK/8892 :& 	488DJJd33	4s$   &G# 2H #(HH4IIc                    | j                   S rp   )_isnanr   s    rs   rP   zDatetimeLikeArrayMixin.isnaX  s    {{ru   c                (    | j                   t        k(  S )z-
        return if each value is nan
        )r   r   r   s    rs   rI  zDatetimeLikeArrayMixin._isnan[  s    
 yyD  ru   c                H    t        | j                  j                               S )zJ
        return if I have any nans; enables various perf speedups
        )rD  rI  anyr   s    rs   _hasnazDatetimeLikeArrayMixin._hasnab  s    
 DKKOO%&&ru   c                    | j                   rF|r|j                  |      }|t        j                  }t        j                  || j
                  |       |S )az  
        Parameters
        ----------
        result : np.ndarray
        fill_value : object, default iNaT
        convert : str, dtype or None

        Returns
        -------
        result : ndarray with values replace by the fill_value

        mask the result if needed, convert to the provided dtype if its not
        None

        This is an internal routine.
        )rM  r   r   nanputmaskrI  )r   r   
fill_valuer   s       rs   _maybe_mask_resultsz*DatetimeLikeArrayMixin._maybe_mask_resultsi  sD    & ;;w/!VV
JJvt{{J7ru   c                H    | j                   y| j                   j                  S )a{  
        Return the frequency object as a string if it's set, otherwise None.

        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    rs   rT  zDatetimeLikeArrayMixin.freqstr  s!    4 99yy   ru   c                l    | j                   dk7  ry	 t        j                  |       S # t        $ r Y yw xY w)ax  
        Tries to return a string representing a frequency generated by infer_freq.

        Returns None if it can't autodetect the frequency.

        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[ns]', freq=None)
        >>> tdelta_idx.inferred_freq
        '10D'
        r   N)r   rg   
infer_freqr  r   s    rs   inferred_freqz$DatetimeLikeArrayMixin.inferred_freq  s:    0 99>	))$// 		s   ' 	33c                j    | j                   }|y 	 t        j                  |      S # t        $ r Y y w xY wrp   )rT  r   get_reso_from_freqstrKeyError)r   rT  s     rs   _resolution_objz&DatetimeLikeArrayMixin._resolution_obj  s;    ,,?	33G<< 		s   & 	22c                .    | j                   j                  S )zO
        Returns day, hour, minute, second, millisecond or microsecond
        )r[  attrnamer   s    rs   
resolutionz!DatetimeLikeArrayMixin.resolution  s     ##,,,ru   c                J    t        j                  | j                  d      d   S )NTtimeliker   r   is_monotonicr   r   s    rs   _is_monotonic_increasingz/DatetimeLikeArrayMixin._is_monotonic_increasing      !!$))d;A>>ru   c                J    t        j                  | j                  d      d   S )NTr`  r   rb  r   s    rs   _is_monotonic_decreasingz/DatetimeLikeArrayMixin._is_monotonic_decreasing  re  ru   c                v    t        t        | j                  j                  d                  | j                  k(  S )NK)r   rW   r   r   sizer   s    rs   
_is_uniquez!DatetimeLikeArrayMixin._is_unique  s(    8DIIOOC012dii??ru   c                   | j                   dkD  rXt        |dd       | j                  k(  r> || j                         |j                               j	                  | j                        S 	 | j                  |      }t        |dd       }t        |      r?t        j                  |t        j                  | j                  t                    |      }|S |t        u r`|t         j"                  u r't        j$                  | j                  t&              }|S t        j(                  | j                  t&              }|S t+        | j,                  t.              st1        t2        |       } | j4                  |j4                  k7  rWt+        |t7        |             s	 |j9                  | j:                  d      }n#|jD                  }tC        | jD                  ||      S | jG                  |      } || jD                  jI                  d      |jI                  d            }tK        |      }| jL                  |z  }|jO                         r)|t         j"                  u }	t        jP                  |||	       |S # t        $ r t        | ||      cY S w xY w# t<        $ r9 t        j>                  |j@                        }tC        | jD                  ||      cY S w xY w)Nr   r   r{   r   Fr"  ry   ))r   r  r   r   r   r  r;   re   rE   rT   comp_method_OBJECT_ARRAYr   r  r   r   r   operatorneonesrD  rC  rz   r{   rL   r   TimelikeOpsr   r  r&  r'  r  r_   asm8r&   r   r-  r|   rP   rI  rL  rP  )
r   r   rr   r{   r   	other_arr
other_valso_maskmask
nat_results
             rs   _cmp_methodz"DatetimeLikeArrayMixin._cmp_method  s3   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T*D{{ell*!%d4 %dii% H !&I9$--TVWW[['
DMM&&t,jood.CDe{{V#88:x{{*JJJvtZ0] ! 	7%dE266	76 & $&HHUZZ$8	= MM9b  s$   )I* J *JJ?KK__pow____rpow____mul____rmul____truediv____rtruediv____floordiv____rfloordiv____mod____rmod__
__divmod____rdivmod__c                    t        |t              r|j                  }d}||fS t        |t        t        f      r|j
                  }d}||fS |j                  }|j                  }||fS )zN
        Get the int64 values and b_mask to pass to add_overflowsafe.
        N)rz   r   ordinalr   r   r~   rI  r   )r   r   i8valuesrv  s       rs   _get_i8_values_and_maskz.DatetimeLikeArrayMixin._get_i8_values_and_mask.  sq     eV$}}HD ~ 	956||HD
 ~ <<DzzH~ru   c                    t        | j                  t              r| j                  S t	        j
                  |      syt        | j                  t              r| j                  S y)zP
        Check if we can preserve self.freq in addition or subtraction.
        N)rz   r{   rL   r   r   r   r   r   s     rs   _get_arithmetic_result_freqz2DatetimeLikeArrayMixin._get_arithmetic_result_freqA  sF     djj+.99u%		4(99ru   c                   t        j                  | j                  d      s7t        dt	        |       j
                   dt	        |      j
                         t        d|       } ddlm} ddl	m
} |t        usJ t        |      r\| j                  t        j                         j                  d| j                    d	      z   } |j"                  ||j                  
      S t%        |      }| j'                  |      \  } }t        d|       } | j)                  |      \  }}t+        | j,                  t/        j0                  |d
            }|j3                  d| j                    d	      } ||j4                  | j                         }|j3                  d| j                    d	      }| j7                  |      }	 |j"                  |||	      S )Nr   cannot add  and rn   r   rl   )tz_to_dtypezM8[]r   ry   r   r'  r{   r   )r   is_np_dtyper{   r  r  r  r   pandas.core.arraysrl   pandas.core.arrays.datetimesr  r   rP   r   to_datetime64r   r'  _simple_newr   _ensure_matching_resosr  r   r   r   r  r|   r   r  )
r   r   rl   r  r   other_i8ru  
res_valuesr{   new_freqs
             rs   _add_datetimelike_scalarz/DatetimeLikeArrayMixin._add_datetimelike_scalarQ  s   tzz3/d4j112%U8L8L7MN  $d+4<C; ]]S%6%6%8%?%?#dii[PQ@R%SSF,=,,V6<<HH% 11%8e$d+77>&!$))RZZ-MN[[3tyyk!34
uxxdii8[[3tyyk!34
33E:(}((5xPPru   c                    t        j                  | j                  d      s7t        dt	        |       j
                   dt	        |      j
                         || z   S )Nr   r  r  )r   r  r{   r  r  r  r   s     rs   _add_datetime_arraylikez.DatetimeLikeArrayMixin._add_datetime_arraylikes  sS    tzz3/d4j112%U8L8L7MN 
 t|ru   c                   | j                   j                  dk7  r!t        dt        |       j                         t        d|       } t        |      r	| t        z
  S t        |      }| j                  |      \  } }| j                  |      S )Nr   "cannot subtract a datelike from a rl   )r{   r   r  r  r  r   rP   r   r   r  _sub_datetimelike)r   r   tss      rs   _sub_datetimelike_scalarz/DatetimeLikeArrayMixin._sub_datetimelike_scalar}  s     ::??c!@dATAT@UVWWOT* ;#:u..r2b%%b))ru   c                   | j                   j                  dk7  r!t        dt        |       j                         t        |       t        |      k7  rt        d      t        d|       } | j                  |      \  } }| j                  |      S )Nr   r  $cannot add indices of unequal lengthrl   )
r{   r   r  r  r  r   r  r   r  r  r   s     rs   _sub_datetime_arraylikez.DatetimeLikeArrayMixin._sub_datetime_arraylike  s}    ::??c!@dATAT@UVWWt9E
"CDDOT*11%8e%%e,,ru   c                   t        d|       } ddlm} 	 | j                  |       | j                  |      \  }}t        | j                  t        j                  | d            }|j                  d| j                   d	      }| j                  |      }	t        d
|	      }	 |j                   ||j"                  |	      S # t        $ r2}t        |      j                  dd      } t        |      |      |d }~ww xY w)Nrl   r   rn   comparesubtractry   r   timedelta64[r  zTick | Noner  )r   r  rn   _assert_tzawareness_compatr  r  replacer  r  r   r   r   r  r|   r'  r  r  r{   )
r   r   rn   r  new_messager  ru  r  res_m8r  s
             rs   r  z(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   C   	C;	-C66C;c                ,   t        j                  | j                  d      s!t        dt	        |       j
                         ddlm} t        j                  |j                  | j                        }t        |j                        } |||      }|| z   S )Nr   zcannot add Period to a r   )rm   r   )r   r  r{   r  r  r  pandas.core.arrays.periodrm   r   broadcast_tor  r   rL   r   )r   r   rm   i8valsr{   parrs         rs   _add_periodz"DatetimeLikeArrayMixin._add_period  ss    tzz3/5d4j6I6I5JKLL 	:

;EJJ'6/d{ru   c                    t        |       rp   r   )r   offsets     rs   _add_offsetz"DatetimeLikeArrayMixin._add_offset  s    !$''ru   c                   t        |      rt        j                  | j                  d      j	                  | j
                  j                        }|j                  t               t        |       j                  || j                        S t        d|       } t        |      }| j                  |      \  } }| j                  |      S )zk
        Add a delta of a timedeltalike

        Returns
        -------
        Same type as self
        ry   r   rB  )rP   r   emptyr   r|   r   r{   fillr   r  r  r   r   r  _add_timedeltalike)r   r   
new_valuess      rs   _add_timedeltalike_scalarz0DatetimeLikeArrayMixin._add_timedeltalike_scalar  s     ;$**D9>>t}}?R?RSJOOD!:))*DJJ)GG 4d;% 11%8e&&u--ru   c                    t        |       t        |      k7  rt        d      t        d|       } | j                  |      \  } }| j	                  |      S )zl
        Add a delta of a TimedeltaIndex

        Returns
        -------
        Same type as self
        r  rB  )r   r  r   r  r  r   s     rs   _add_timedelta_arraylikez/DatetimeLikeArrayMixin._add_timedelta_arraylike  sR     t9E
"CDD4d;11%8e&&u--ru   c                R   t        d|       } | j                  |      \  }}t        | j                  t	        j
                  |d            }|j                  | j                  j                        }| j                  |      }t        |       j                  || j                  |      S )NrB  ry   r   r  )r   r  r   r   r   r  r|   r   r{   r  r  r  )r   r   r  ru  r  r  r  s          rs   r  z)DatetimeLikeArrayMixin._add_timedeltalike  s    4d;77>&%diiHD1QR
__T]]%8%89
33E:
 Dz%%djjx & 
 	
ru   c                   t        | j                  t              r;t        dt	        |       j
                   dt	        t              j
                         t        d|       } t        j                  | j                  t        j                        }|j                  t               |j                  | j                  j                        }t	        |       j!                  || j                  d      S )z$
        Add pd.NaT to self
        zCannot add r  zTimedeltaArray | DatetimeArrayr   Nr  )rz   r{   rL   r  r  r  r   r   r   r  r   r   r  r   r|   r   r  r   r   s     rs   _add_natzDatetimeLikeArrayMixin._add_nat  s    
 djj+.d4j112%S	8J8J7KL  4d; $**BHH5DT]]001 Dz%%$**4 & 
 	
ru   c                2   t        j                  | j                  t         j                        }|j	                  t
               | j                  j                  dv r+t        d|       } |j                  d| j                   d      S |j                  d      S )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|   r'  r  s     rs   _sub_natzDatetimeLikeArrayMixin._sub_nat  sq     $**BHH5D::??d"7>D;;dii[:;;;;011ru   c                .   t        | j                  t              s7t        dt	        |      j
                   dt	        |       j
                         t        d|       } | j                  |       | j                  |      \  }}t        | j                  t        j                  | d            }t        j                  |D cg c]  }| j                  j                  |z   c}      }|| j                   }n| j                   |z  }t"        ||<   |S c c}w )Ncannot subtract  from rm   ry   r   )rz   r{   rL   r  r  r  r   r   r  r   r   r   r  r_   r   baserI  r   )r   r   r  ru  new_i8_datar   new_datarv  s           rs   _sub_periodlikez&DatetimeLikeArrayMixin._sub_periodlike#  s     $**k2"4;#7#7"8tDz?R?R>ST  M4(##E*77>&&tyy"**hYd2ST88EATYY^^a/EF>;;D ;;'D Fs    Dc                   |t         j                  t         j                  fv sJ t        |      dk(  r| j                  dk(  r || |d         S t        j                  dt        |       j                   dt        t                      | j                  |j                  k(  sJ | j                  |j                  f        || j                  d      t        j                  |            }|S )aZ  
        Add or subtract array-like of DateOffset objects

        Parameters
        ----------
        other : np.ndarray[object]
        op : {operator.add, operator.sub}

        Returns
        -------
        np.ndarray[object]
            Except in fastpath case with length 1 where we operate on the
            contained scalar.
        r   r   z)Adding/subtracting object-dtype array to z not vectorized.r   O)rn  addsubr   r   r   r   r  r  r<   r@   r   r   r   r  )r   r   rr   r  s       rs   _addsub_object_arrayz+DatetimeLikeArrayMixin._addsub_object_array<  s      hllHLL1111u:?tyyA~ dE!H%%7Dz""##35')		
 zzU[[(C4::u{{*CC(C("**U*;<
ru   r>  c                   |dvrt        d| dt        |              t        t        |      } || j	                         fd|i|}t        |       j                  || j                        S )N>   cummaxcumminzAccumulation z not supported for r?  r   )r  r  r  rX   r   r  r{   )r   namer?  r   rr   r   s         rs   _accumulatez"DatetimeLikeArrayMixin._accumulate`  sm    ++mD61DT$ZLQRR/6DIIK99&9Dz%%fDJJ%??ru   __add__c                   t        |dd       }t        |      }|t        u r| j                         }nUt	        |t
        t        t        j                  f      r| j                  |      }nt	        |t              r| j                  |      }nt	        |t        t        j                  f      r| j                  |      }nt	        |t              r3t!        j"                  | j$                  d      r| j'                  |      }nt!        j(                  |      rjt	        | j$                  t*              st-        |       t/        d|       }|j1                  ||j$                  j2                  z  t4        j6                        }nt!        j"                  |d      r| j9                  |      }nt;        |      r!| j=                  |t4        j6                        }nt!        j"                  |d      st	        |t>              r| jA                  |      S tC        |      rit	        | j$                  t*              st-        |       t/        d|       }|j1                  ||j$                  j2                  z  t4        j6                        }ntD        S t	        |t        jF                        r8t!        j"                  |j$                  d      rddl$m%}  |jL                  |      S |S )Nr{   r   rm   r   r   r  )'r  r`   r   r  rz   r   r   r   r8  r  r   r  r   r9  r  r   r   r  r{   r  
is_integerrL   r(   r   _addsub_int_array_or_scalar_nrn  r  r  rE   r  rJ   r  rC   NotImplementedndarrayr  rn   r   r   r   other_dtyper   objrn   s         rs   r  zDatetimeLikeArrayMixin.__add__i  s   eWd3.u5 C<]]_Fi@A33E:Fz*%%e,F"--892259Fv&3??4::s+K%%e,F^^E" djj+6.t44}d+C44USYY\\5I8<<XF __[#.2259F[)..uhllCF__[#.*3
 //66k*djj+6.t44}d+C44USYY\\5I8<<XF "!fbjj)coofllC.P90>0088ru   c                $    | j                  |      S rp   )r  r   s     rs   __radd__zDatetimeLikeArrayMixin.__radd__  s    ||E""ru   __sub__c                   t        |dd       }t        |      }|t        u r| j                         }n\t	        |t
        t        t        j                  f      r| j                  |       }n#t	        |t              r| j                  |       }nt	        |t        t        j                  f      r| j                  |      }nt        j                   |      rjt	        | j"                  t$              st'        |       t)        d|       }|j+                  ||j"                  j,                  z  t.        j0                        }nMt	        |t2              r| j5                  |      }n*t        j6                  |d      r| j9                  |       }n t;        |      r!| j=                  |t.        j0                        }nt        j6                  |d      st	        |t>              r| jA                  |      }nt	        |t$              r| j5                  |      }nztC        |      rit	        | j"                  t$              st'        |       t)        d|       }|j+                  ||j"                  j,                  z  t.        j0                        }ntD        S t	        |t        jF                        r8t        j6                  |j"                  d      rddl$m%}  |jL                  |      S |S )Nr{   rm   r   r   r   r  )'r  r`   r   r  rz   r   r   r   r8  r  r   r  r   r9  r  r   r  r{   rL   r(   r   r  r  rn  r  r   r  r  r  rE   r  rJ   r  rC   r  r  r  rn   r   r  s         rs   r  zDatetimeLikeArrayMixin.__sub__  s   eWd3.u5 C<]]_Fi@A33UF;Fz*%%uf-F"--892259F^^E" djj+6.t44}d+C44USYY\\5I8<<XFv&))%0F __[#.22E6:F[)..uhllCF__[#.*3
 11%8F[1))%0Fk*djj+6.t44}d+C44USYY\\5I8<<XF "!fbjj)coofllC.P90>0088ru   c                8   t        |dd       }t        j                  |d      xs t        |t              }|rpt        j                  | j
                  d      rPt        j                  |      rt        |      | z
  S t        |t              sddl	m
}  |j                  |      }|| z
  S | j
                  j                  dk(  rEt        |d      r9|s7t        dt        |       j                    dt        |      j                          t        | j
                  t"              rDt        j                  |d      r.t        dt        |       j                    d|j
                         t        j                  | j
                  d      rt%        d|       } |  |z   S | |z
   S )	Nr{   r   r   r   r  r  r  rn   )r  r   r  rz   rJ   r{   r   r   r   r  rl   r   r   r  r  r  r  rL   r   )r   r   r  other_is_dt64rl   s        rs   __rsub__zDatetimeLikeArrayMixin.__rsub__  s^   eWd3S9 
Z>
 S__TZZ= }}U# '$..e%;<<444U;4<ZZ__#w(? "4:#6#6"7vd5k>R>R=ST  

K0S__[RU5V.tDz/B/B.C6%++WXX__TZZ-($/DEU?" ru   c                v    | |z   }|d d  | d d  t        | j                  t              s|j                  | _        | S rp   rz   r{   rL   r   r   r   r   r   s      rs   __iadd__zDatetimeLikeArrayMixin.__iadd__  6    )Q$**k2DJru   c                v    | |z
  }|d d  | d d  t        | j                  t              s|j                  | _        | S rp   r  r  s      rs   __isub__zDatetimeLikeArrayMixin.__isub__  r  ru   c                &    t         |   ||      S )N)qsinterpolation)r   	_quantile)r   r  r  r   s      rs   r  z DatetimeLikeArrayMixin._quantile  s     w Bm DDru   axisr?  c                   t        j                  d|       t        j                  || j                         t	        j
                  | j                  ||      }| j                  ||      S )a  
        Return the minimum value of the Array or minimum along
        an axis.

        See Also
        --------
        numpy.ndarray.min
        Index.min : Return the minimum value in an Index.
        Series.min : Return the minimum value in a Series.
        r   r  )nvvalidate_minvalidate_minmax_axisr   rS   nanminr   _wrap_reduction_resultr   r  r?  r   r   s        rs   minzDatetimeLikeArrayMixin.min  O     	F#
dii0t}}4G**488ru   c                   t        j                  d|       t        j                  || j                         t	        j
                  | j                  ||      }| j                  ||      S )a  
        Return the maximum value of the Array or maximum along
        an axis.

        See Also
        --------
        numpy.ndarray.max
        Index.max : Return the maximum value in an Index.
        Series.max : Return the maximum value in a Series.
        r   r  )r  validate_maxr  r   rS   nanmaxr   r  r  s        rs   maxzDatetimeLikeArrayMixin.max.  r  ru   r   )r?  r  c                   t        | j                  t              r"t        dt	        |       j
                   d      t        j                  | j                  ||| j                               }| j                  ||      S )a  
        Return the mean value of the Array.

        Parameters
        ----------
        skipna : bool, default True
            Whether to ignore any NaT elements.
        axis : int, optional, default 0

        Returns
        -------
        scalar
            Timestamp or Timedelta.

        See Also
        --------
        numpy.ndarray.mean : Returns the average of array elements along a given axis.
        Series.mean : Return the mean value in a Series.

        Notes
        -----
        mean is only defined for Datetime and Timedelta dtypes, not for Period.

        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[ns]', 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[ns]', 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()r  r?  rv  )rz   r{   rL   r  r  r  rS   nanmeanr   rP   r  )r   r?  r  r   s       rs   meanzDatetimeLikeArrayMixin.mean@  su    X djj+..tDz/B/B.C D7 7  MMV$))+
 **488ru   c                   t        j                  d|       |#t        |      | j                  k\  rt	        d      t        j                  | j                  ||      }| j                  ||      S )Nr   z abs(axis) must be less than ndimr  )	r  validate_medianabsr   r  rS   	nanmedianr   r  r  s        rs   medianzDatetimeLikeArrayMixin.mediany  s^    
2v&D	TYY 6?@@!!$--d6J**488ru   c                   d }|r| j                         }t        j                  | j                  d      |      }|j                  | j                  j
                        }t        t        j                  |      }| j                  |      S )Nry   )rv  )
rP   rQ   moder|   r   r{   r   r   r  r   )r   dropnarv  i8modesnpmodess        rs   _modezDatetimeLikeArrayMixin._mode  sf    99;D//$))D/=,,t}}223rzz7+&&w//ru   c                  | j                   }|j                  dk(  rC|dv rt        d| d      |dv rt        j                  d| d| dt
        t               	       nft        |t              rC|dv rt        d
| d      |dv r?t        j                  d| d| dt
        t               	       n|dv rt        d| d      | j                  j                  d      }ddlm}	 |	j                  |      }
 |	||
|      } |j                  |f|||d d|}|j                  |j                   v r|S |j                   dk(  sJ |dv rvddlm} t        | j                   t              rt        d      t'        d|       } d| j(                   d}|j                  |      } |j*                  ||j                         S |j                  | j                  j                         }| j-                  |      S )Nr   )sumprodcumsumcumprodvarskewz!datetime64 type does not support z operations)rL  allr  zh' with datetime64 dtypes is deprecated and will raise in a future version. Use (obj != pd.Timestamp(0)).z() instead.r   zPeriod type does not support ze' with PeriodDtype is deprecated and will raise in a future version. Use (obj != pd.Period(0, freq)).)r  r  r  r  z"timedelta64 type does not support rx   r   )WrappedCythonOp)howr   has_dropped_na)	min_countngroupscomp_idsrv  )stdsemr  z-'std' and 'sem' are not valid for PeriodDtyperB  zm8[r  r   )r{   r   r  r   r   r   r@   rz   rL   r   r|   pandas.core.groupby.opsr  get_kind_from_how_cython_op_ndim_compatr  cast_blocklistr  rn   r   r'  r  r   )r   r  r  r  r  idsr   r{   npvaluesr  r   rr   r  rn   	new_dtypes                  rs   _groupby_opz"DatetimeLikeArrayMixin._groupby_op  s    

::II"CC5 TUUn$u DDG5U!/1	 {+II"?uK PQQn$u GGJe;X!/1	 88"DSE UVV ==%%h/;0054O.R..

 

 66R&&&  8+++. 9$**k2 OPP8$?Ddii[*I#3J->--j
@P@PQQ__T]]%8%89
&&z22ru   returnrD  )NNF)r{   Dtype | Noner   rD  r+  None)r+  ztype[DatetimeLikeScalar])r   r  r+  DTScalarOrNaT)r   r.  r+  z)np.int64 | np.datetime64 | np.timedelta64)r   r.  r+  r-  r+  r   )r+  rh   )r+  znpt.NDArray[np.int64])r   zstr | floatr+  npt.NDArray[np.object_])F)r   rD  )NN)r{   zNpDtype | Noner   zbool | Noner+  r   )r   r3   r+  r.  )r   z(SequenceIndexer | PositionalIndexerTupler+  r4   )r   r1   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   rD  r+  r4   )r{   zLiteral['M8[ns]']r+  rl   )r{   zLiteral['m8[ns]']r+  rn   ).)r{   r,  r+  r)   rp   )r  rD  r  rD  )r  rD  r+  r  )r  rD  )r+  z6np.int64 | np.datetime64 | np.timedelta64 | np.ndarray)r   r)   r+  npt.NDArray[np.bool_])r+  r4  )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+  rl   )r   rl   r+  rl   )r   zdatetime | np.datetime64r+  rn   )r   rl   r+  rn   )r   zTimestamp | DatetimeArrayr+  rn   )r   r   r+  rm   )r   rn   )r   zTimedelta | TimedeltaArray)r   zPeriod | PeriodArrayr+  r0  )r   r0  )r  r  r?  rD  r+  r4   )r  znpt.NDArray[np.float64]r  r  r+  r4   )r  AxisInt | Noner?  rD  )r?  rD  r  r6  )r  rD  )
r  r  r  rD  r  intr  r7  r&  znpt.NDArray[np.intp])`r  
__module____qualname____doc____annotations__r?   r   r   propertyr   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[   r5  rU   rP   rI  rM  r   rR  rT  rW  r[  r^  rd  rg  rk  rx  rt   ry  rz  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  rd   r  r  r  r  r  r  r   r  r  r  r  r  r  r)  __classcell__r   s   @rs   r   r      s    $#44))
  IN('(AE(	(
 ( (((("(	2(.(,(D: 
( 
(  (-$
($
(	 
( AE#2=	.   6 
 "<!9! -! 
	!,
71r        #"P  %;) 	;)
 ;)z>8t" 
 
" 	  	 P,j ! ! ' ' .24 	< ! !:  <   - - ? ? ? ? @ @5r (	2G(4H'	2G(4H+M:K,^<L,^<L-o>M'	2G(4H*<8J+M:K
	I $   Q QB   *-*	* *$ 
- 
- U U& 
 
(.(.$ 
 
  
 
, 2 2&  0 ! !F 8< @ i(5 )5n# i(5 )5n D E#E E 
	E E ,0 9 9" ,0 9 9" &*! 79r /3D 9 90M3 M3 	M3
 M3 M3 "M3ru   r   c                  0    e Zd ZdZ ed      dd       Zy)DatelikeOpszK
    Common ops for DatetimeIndex/PeriodIndex, but not TimedeltaIndex.
    zNhttps://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior)URLc                    | j                  |t        j                        }t               r(ddlm} t        | |t        j                              S |j                  t        d      S )a  
        Convert to Index using specified date_format.

        Return an Index of formatted strings specified by date_format, which
        supports the same string format as the python standard library. Details
        of the string format can be found in `python string format
        doc <%(URL)s>`__.

        Formats supported by the C `strftime` API but not by the python string format
        doc (such as `"%%R"`, `"%%r"`) are not officially supported and should be
        preferably replaced with their supported equivalents (such as `"%%H:%%M"`,
        `"%%I:%%M:%%S %%p"`).

        Note that `PeriodIndex` support additional directives, detailed in
        `Period.strftime`.

        Parameters
        ----------
        date_format : str
            Date format string (e.g. "%%Y-%%m-%%d").

        Returns
        -------
        ndarray[object]
            NumPy ndarray of formatted strings.

        See Also
        --------
        to_datetime : Convert the given argument to datetime.
        DatetimeIndex.normalize : Return DatetimeIndex with times to midnight.
        DatetimeIndex.round : Round the DatetimeIndex to the specified freq.
        DatetimeIndex.floor : Floor the DatetimeIndex to the specified freq.
        Timestamp.strftime : Format a single Timestamp.
        Period.strftime : Format a single Period.

        Examples
        --------
        >>> rng = pd.date_range(pd.Timestamp("2018-03-10 09:00"),
        ...                     periods=3, freq='s')
        >>> rng.strftime('%%B %%d, %%Y, %%r')
        Index(['March 10, 2018, 09:00:00 AM', 'March 10, 2018, 09:00:01 AM',
               'March 10, 2018, 09:00:02 AM'],
              dtype='object')
        )r   r   r   )StringDtyper   r   Fr   )	r   r   rO  r   r2  rC  r)  r   r   )r   r   r   rC  s       rs   strftimezDatelikeOps.strftime  sP    b **{266*R*F+rvv*FGG}}V%}00ru   N)r   r  r+  r0  )r  r8  r9  r:  r>   rE  r   ru   rs   r@  r@    s%     *21	21ru   r@  aO	  
    Perform {op} operation on the data to the specified `freq`.

    Parameters
    ----------
    freq : str or Offset
        The frequency level to {op} the index to. Must be a fixed
        frequency like 'S' (second) not 'ME' (month end). See
        :ref:`frequency aliases <timeseries.offset_aliases>` for
        a list of possible `freq` values.
    ambiguous : 'infer', bool-ndarray, 'NaT', default 'raise'
        Only relevant for DatetimeIndex:

        - 'infer' will attempt to infer fall dst-transition hours based on
          order
        - bool-ndarray where True signifies a DST time, False designates
          a non-DST time (note that this flag is only applicable for
          ambiguous times)
        - 'NaT' will return NaT where there are ambiguous times
        - 'raise' will raise an AmbiguousTimeError if there are ambiguous
          times.

    nonexistent : 'shift_forward', 'shift_backward', 'NaT', timedelta, default 'raise'
        A nonexistent time does not exist in a particular timezone
        where clocks moved forward due to DST.

        - 'shift_forward' will shift the nonexistent time forward to the
          closest existing time
        - 'shift_backward' will shift the nonexistent time backward to the
          closest existing time
        - 'NaT' will return NaT where there are nonexistent times
        - timedelta objects will shift nonexistent times by the timedelta
        - 'raise' will raise an NonExistentTimeError if there are
          nonexistent times.

    Returns
    -------
    DatetimeIndex, TimedeltaIndex, or Series
        Index of the same type for a DatetimeIndex or TimedeltaIndex,
        or a Series with the same index for a Series.

    Raises
    ------
    ValueError if the `freq` cannot be converted.

    Notes
    -----
    If the timestamps have a timezone, {op}ing will take place relative to the
    local ("wall") time and re-localized to the same timezone. When {op}ing
    near daylight savings time, use ``nonexistent`` and ``ambiguous`` to
    control the re-localization behavior.

    Examples
    --------
    **DatetimeIndex**

    >>> rng = pd.date_range('1/1/2018 11:59:00', periods=3, freq='min')
    >>> rng
    DatetimeIndex(['2018-01-01 11:59:00', '2018-01-01 12:00:00',
                   '2018-01-01 12:01:00'],
                  dtype='datetime64[ns]', freq='min')
    a  >>> rng.round('h')
    DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
                   '2018-01-01 12:00:00'],
                  dtype='datetime64[ns]', freq=None)

    **Series**

    >>> pd.Series(rng).dt.round("h")
    0   2018-01-01 12:00:00
    1   2018-01-01 12:00:00
    2   2018-01-01 12:00:00
    dtype: datetime64[ns]

    When rounding near a daylight savings time transition, use ``ambiguous`` or
    ``nonexistent`` to control how the timestamp should be re-localized.

    >>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam")

    >>> rng_tz.floor("2h", ambiguous=False)
    DatetimeIndex(['2021-10-31 02:00:00+01:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)

    >>> rng_tz.floor("2h", ambiguous=True)
    DatetimeIndex(['2021-10-31 02:00:00+02:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
    a  >>> rng.floor('h')
    DatetimeIndex(['2018-01-01 11:00:00', '2018-01-01 12:00:00',
                   '2018-01-01 12:00:00'],
                  dtype='datetime64[ns]', freq=None)

    **Series**

    >>> pd.Series(rng).dt.floor("h")
    0   2018-01-01 11:00:00
    1   2018-01-01 12:00:00
    2   2018-01-01 12:00:00
    dtype: datetime64[ns]

    When rounding near a daylight savings time transition, use ``ambiguous`` or
    ``nonexistent`` to control how the timestamp should be re-localized.

    >>> rng_tz = pd.DatetimeIndex(["2021-10-31 03:30:00"], tz="Europe/Amsterdam")

    >>> rng_tz.floor("2h", ambiguous=False)
    DatetimeIndex(['2021-10-31 02:00:00+01:00'],
                 dtype='datetime64[ns, Europe/Amsterdam]', freq=None)

    >>> rng_tz.floor("2h", ambiguous=True)
    DatetimeIndex(['2021-10-31 02:00:00+02:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
    a  >>> rng.ceil('h')
    DatetimeIndex(['2018-01-01 12:00:00', '2018-01-01 12:00:00',
                   '2018-01-01 13:00:00'],
                  dtype='datetime64[ns]', freq=None)

    **Series**

    >>> pd.Series(rng).dt.ceil("h")
    0   2018-01-01 12:00:00
    1   2018-01-01 12:00:00
    2   2018-01-01 13:00:00
    dtype: datetime64[ns]

    When rounding near a daylight savings time transition, use ``ambiguous`` or
    ``nonexistent`` to control how the timestamp should be re-localized.

    >>> rng_tz = pd.DatetimeIndex(["2021-10-31 01:30:00"], tz="Europe/Amsterdam")

    >>> rng_tz.ceil("h", ambiguous=False)
    DatetimeIndex(['2021-10-31 02:00:00+01:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)

    >>> rng_tz.ceil("h", ambiguous=True)
    DatetimeIndex(['2021-10-31 02:00:00+02:00'],
                  dtype='datetime64[ns, Europe/Amsterdam]', freq=None)
    c                      e Zd ZU dZded<   dej                  df	 	 	 d&dZed        Z	e
d        Zej                  d'd	       Zed(d
       Zeed)d              Ze	 	 	 	 d*d       Zed+d       Zed,d       Zd-d.dZd Zd/ fdZd Z eeez   j7                  d            	 	 d0	 	 	 	 	 d1d       Z eeez   j7                  d            	 	 d0	 	 	 	 	 d1d       Z eeez   j7                  d            	 	 d0	 	 	 	 	 d1d       Z dddd2dZ!dddd2dZ"d'dZ#d3dZ$d4 fd Z%	 	 d5	 	 	 d6 fd!Z&e	 d7	 	 	 	 	 d8 fd"       Z'd9d: fd#Z(	 	 	 	 	 	 	 	 	 	 d;d$Z)e
d<d%       Z* xZ+S )=rq  zK
    Common ops for TimedeltaIndex/DatetimeIndex, but not PeriodIndex.
    znp.dtype_default_dtypeNFc                N   t        j                  t        |       j                   dt        t                      |t        |      }t        |d      }t        |t              r|j                  dt              }t        |dd       }|d u }|t        j                  ur|nd }t        |t        |             r|rn>||j                  }n/|r-|j                  r!t!        |      }t#        ||j                        }|*||j$                  k7  rt'        d| d	|j$                         |j$                  }|j(                  }n|t        |t*        j,                        r%|j$                  j.                  d
v r|j$                  }nF| j0                  }t        |t*        j,                        r |j$                  dk(  r|j3                  |      }t        |t*        j,                        s8t5        dt        |      j                   dt        |       j                   d      |j6                  dvrt5        d      |j$                  dk(  r|(| j0                  }|j3                  | j0                        }nqt        j8                  |d      r|j3                  |      }nIt        |t:              r9| j0                  j.                  }| d|j<                   d}|j3                  |      }| j?                  ||      }|dk(  r"t5        dt        |       j                   d      |r|jA                         }|r?t!        |      }|j$                  j.                  dk(  rt        |tB              st'        d      tE        jF                  | ||       || _$        ||t        |       jK                  | |       y y y )NzV.__init__ is deprecated and will be removed in a future version. Use pd.array instead.r   Tr$  r   rD  r   dtype=z does not match data dtype Mmry   zUnexpected type 'z'. 'values' must be a z6, ndarray, or Series or Index containing one of those.)r      z.Only 1-dimensional input arrays are supported.r   8[r  inferz#Frequency inference not allowed in z$.__init__. Use 'pd.array()' instead.r   (TimedeltaArray/Index freq must be a Tick)r   r{   )&r   r   r  r  r   r@   rG   ra   rz   r^   r3  r   r  r   
no_defaultr   r#   _validate_inferred_freqr{   r  r   r   r  r   rG  r|   r  r   r  rJ   r'  _validate_dtyper   r   r   r   r   _validate_frequency)	r   r   r{   r   r   rW  explicit_noner   r(  s	            rs   r   zTimelikeOps.__init__  s9    	Dz""# $A A')	
  'EvT:fl+__Wt_<F63>>1ttfd4j){{&++ .tV[[A Ufll%:UG#>v||nM  LLE__F]&"**-&,,2C2Ct2K++fbjj1flld6J#[[/F&"**-#DL$9$9#::P:&&' (++ 
 ;;f$MNN<<4 }++T%8%89-U+E?3**//#fBuzzl!4	Y/$$VU37?5d4j6I6I5J K, , 
 [[]FT?D||  C'
40F JKKtF%@
 T%5J**46 &6 ru   c                    t        |       rp   r   )r  r   r{   s      rs   rQ  zTimelikeOps._validate_dtype  s    !#&&ru   c                    | j                   S )zK
        Return the frequency object if it is set, otherwise None.
        r   r   s    rs   r   zTimelikeOps.freq  s    
 zzru   c                    |kt        |      }| j                  | |       | j                  j                  dk(  rt	        |t
              st        d      | j                  dkD  rt        d      || _	        y )Nr   rN  r   zCannot set freq with ndim > 1)
r#   rR  r{   r   rz   r   r  r   r  r   r   s     rs   r   zTimelikeOps.freq  se    e$E$$T51zz#%j.E JKKyy1} !@AA
ru   c                R   |d| _         y|dk(  r(| j                   t        | j                        | _         yy|t        j                  u ry| j                   0t        |      } t        |       j                  | |fi | || _         yt        |      }t        || j                          y)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.
        NrM  )r   r#   rW  r   rO  r  rR  rP  )r   r   validate_kwdss      rs   _maybe_pin_freqzTimelikeOps._maybe_pin_freq*  s     <DJW_ zz! 't'9'9:
 " S^^# ZZ T?D*DJ**4GGDJ T?D#D$**5ru   c           	        |j                   }|j                  dk(  s||j                  k(  ry	  | j                  d|d   dt	        |      ||j
                  d|}t        j                  |j                  |j                        st        y# t        $ r0}dt        |      v r|t        d| d|j                         |d}~ww xY w)am  
        Validate that a frequency is compatible with the values of a given
        Datetime Array/Index or Timedelta Array/Index

        Parameters
        ----------
        index : DatetimeIndex or TimedeltaIndex
            The index on which to determine if the given frequency is valid
        freq : DateOffset
            The frequency to validate
        r   N)startendperiodsr   r'  z	non-fixedInferred frequency 9 from passed values does not conform to passed frequency r   )rW  rj  rT  _generate_ranger   r'  r   array_equalr   r  r  )r  indexr   r   rG  on_freqr  s          rs   rR  zTimelikeOps._validate_frequencyK  s     &&::?h$,,6	)c)) AhE
ZZ G >>%**gll;   < 	c#h& 	 %hZ 088<~G 	s   AB 	C+C  Cc                    t        |       rp   r   )r  r\  r]  r^  r   r   r   s          rs   ra  zTimelikeOps._generate_rangew  s     "#&&ru   c                @    t        | j                  j                        S rp   )r   r   r{   r   s    rs   r   zTimelikeOps._creso  s    "4==#6#677ru   c                ,    t        | j                        S rp   )dtype_to_unitr{   r   s    rs   r'  zTimelikeOps.unit  s    
 TZZ((ru   Tc                   |dvrt        d      t        j                  | j                  j                   d| d      }t	        | j
                  ||      }t        | j                  t        j                        r|j                  }n#t        d|       j                  }t        ||      }t        |       j                  ||| j                        S )	N)smsusnsz)Supported units are 's', 'ms', 'us', 'ns'rL  r  r"  rl   r  r  )r  r   r{   r   r   r   rz   r   r   rJ   r  r  r   )r   r'  r#  r{   r  r(  r   s          rs   r&  zTimelikeOps.as_unit  s    ..HIIDJJOO,BtfA67(Q
djj"((+"((Iot,//B'2D9I Dz%%idii & 
 	
ru   c                    | j                   |j                   k7  rS| j                   |j                   k  r| j                  |j                        } | |fS |j                  | j                        }| |fS rp   )r   r&  r'  r   s     rs   r  z"TimelikeOps._ensure_matching_resos  s^    ;;%,,&{{U\\)||EJJ/ U{ dii0U{ru   c                    |t         j                  t         j                  t         j                  fv r2t	        |      dk(  r$|d   | u r t        ||      | j                  fi |S t        |    ||g|i |S )Nr   r   )	r   isnanisinfisfiniter   r  r   r   __array_ufunc__)r   ufuncmethodinputsr   r   s        rs   rs  zTimelikeOps.__array_ufunc__  sq    bhh"++66Fq q	T! *75&)$--B6BBw&ufHvHHHru   c                L   t        | j                  t              rOt        d|       } | j	                  d       }|j                  ||||      }|j	                  | j                  ||      S | j                  d      }t        t        j                  |      }t        || j                        }|dk(  r| j                         S t        |||      }	| j                  |	t              }|j                  | j                   j                        }| j#                  || j                        S )Nrl   )	ambiguousnonexistentry   r   rQ  r   )rz   r{   rJ   r   tz_localize_roundr   r|   r   r  r'   r   r   r%   rR  r   r   r  )
r   r   r  rx  ry  naiver   r   nanos	result_i8s
             rs   r|  zTimelikeOps._round  s    djj/2.D$$T*E\\$iEF%%9+ &   4bjj&)"45A:99;!&$6	))))ET]]001djj99ru   round)rr   c                F    | j                  |t        j                  ||      S rp   )r|  r$   NEAREST_HALF_EVENr   r   rx  ry  s       rs   r  zTimelikeOps.round  s     {{4!:!:I{SSru   floorc                F    | j                  |t        j                  ||      S rp   )r|  r$   MINUS_INFTYr  s       rs   r  zTimelikeOps.floor  s     {{4!4!4iMMru   ceilc                F    | j                  |t        j                  ||      S rp   )r|  r$   
PLUS_INFTYr  s       rs   r  zTimelikeOps.ceil  s     {{4!3!3YLLru   r  c               d    t        j                  | j                  ||| j                               S Nr  )rS   nananyr   rP   r   r  r?  s      rs   rL  zTimelikeOps.any  s!    }}T]]f499;WWru   c               d    t        j                  | j                  ||| j                               S r  )rS   nanallr   rP   r  s      rs   r  zTimelikeOps.all  s#     }}T]]f499;WWru   c                    d | _         y rp   rV  r   s    rs   r   zTimelikeOps._maybe_clear_freq  s	    
ru   c                   |nnt        |       dk(  rDt        |t              r4| j                  j                  dk(  r7t        |t
              s't        d      |dk(  sJ t        | j                        }| j                         }||_
        |S )z
        Helper to get a view on the same data, with a new freq.

        Parameters
        ----------
        freq : DateOffset, None, or "infer"

        Returns
        -------
        Same type as self
        r   r   rN  rM  )r   rz   r   r{   r   r   r  r#   rW  r|   r   )r   r   r   s      rs   
_with_freqzTimelikeOps._with_freq  sz     <Y!^
4 <zz#%jt.D JKK 7?"?T//0Diik	
ru   c                    t        | j                  t        j                        r| j                  S t        |          S rp   )rz   r{   r   r   r   _values_for_json)r   r   s    rs   r  zTimelikeOps._values_for_json	  s-    djj"((+== w'))ru   c                ^   | j                   mt        j                  t        |       t        j                        }| j                         }|r)| j                   j                  dk  r|d d d   }|d d d   }||fS |r"t        dt        |       j                   d      t        | -  |      S )Nr   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   aranger   intpr   r   NotImplementedErrorr  r  r   	factorize)r   r  sortcodesuniquesr   s        rs   r  zTimelikeOps.factorize	  s    
 99 IIc$irww7EiikG		add!$B$-'>! &(d)<)<(= >= = 
 w  AAru   c                0   t         |   ||      }|d   |dk(  rt|D cg c]  }t        |      s| }}j                  Mt	        fd|D              r9t        |d d |dd        }t	        fd|D              rj                  }||_        |S c c}w )Nr   c              3  P   K   | ]  }|j                   j                   k(    y wrp   r   )r   r   r  s     rs   r   z0TimelikeOps._concat_same_type.<locals>.<genexpr>E	  s     +R1AFFchh,>+Rs   #&r  r   c              3  Z   K   | ]"  }|d    d   j                   z   |d   d    k(   $ yw)r   r  r   Nr  )r   pairr  s     rs   r   z0TimelikeOps._concat_same_type.<locals>.<genexpr>G	  s/     NtAwr{SXX-a;Ns   (+)r   _concat_same_typer   r   r  zipr   )	r  	to_concatr  new_objr   pairsr  r  r   s	          @rs   r  zTimelikeOps._concat_same_type6	  s     '+It<l19 %.8qQ8I8xx#+R	+R(RIcrNIabM:NNN"xxH$,GM 9s
   BBc                J    t         |   |      }| j                  |_        |S )N)order)r   r   r   r   )r   r  r  r   s      rs   r   zTimelikeOps.copyL	  s#    ',U,+		ru   c          
         |dk7  rt         |s| j                  }	n| j                  j                         }	t        j                  |	f||||||d| |s| S t        |       j                  |	| j                        S )z2
        See NDFrame.interpolate.__doc__.
        linear)ru  r  rc  limitlimit_direction
limit_arear   )r  r   r   rR   interpolate_2d_inplacer  r  r{   )
r   ru  r  rc  r  r  r  r   r   out_datas
             rs   interpolatezTimelikeOps.interpolateQ	  s      X%%}}H}}))+H&&		
+!		
 		
 KDz%%hdjj%AAru   c                
   t        j                  | j                        sy| j                  }|t        k7  }t        | j                        }t        |      }t        j                  |||z  dk7        j                         dk(  }|S )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_andr  )r   
values_intconsider_valuesr   ppd	even_dayss         rs   _is_dates_onlyzTimelikeOps._is_dates_onlyz	  ss     tzz*YY
$,"4::.d# NN?J4D4IJNNPTUU	ru   )r   rD  r+  r-  r1  )rY  dict)r   r   )r^  
int | Noner+  r4   )r+  r7  r5  r2  )r'  r  r#  rD  r+  r4   )rt  znp.ufuncru  r  )raiser  )rx  r6   ry  r7   r+  r4   )r  r6  r?  rD  r+  rD  r3  r/  )TF)r  rD  r  rD  )r   )r  zSequence[Self]r  r*   r+  r4   )C)r  r  r+  r4   )
ru  r/   r  r7  rc  rk   r   rD  r+  r4   r*  ),r  r8  r9  r:  r;  r   rO  r   classmethodrQ  r<  r   setterr   rZ  rR  ra  r?   r   r'  r&  r  rs  r|  r=   
_round_doc_round_exampler   r  _floor_exampler  _ceil_exampler  rL  r  r   r  r  r  r  r   r  r  r=  r>  s   @rs   rq  rq    s     !s~~EZ7=AZ7	Z7x ' '   
[[
 
 6 6@ (  (T '",'	' ' 8 8 ) )
*	I:, zN*22g2>? $+'.	T !T %	T
 
T @T zN*22g2>? $+'.	N !N %	N
 
N @N zM)11V1<= $+'.	M !M %	M
 
M >M -1 X -1 X@* !%BB B0  !  
	 *
$B #$B 	$B
 $B $B 
$BR  ru   rq  c                   t        | d      sGt        | t        t        f      s#t	        j
                  |       dk(  rt        |       } t        |       } d}n,t        | t              rt        d| d      t        | d      } t        | t              s(t        | t              r5| j                  j                  dv r| j                  d	t        
      } d}| |fS t        | t              r&| j!                         } | j                         } d}| |fS t        | t        j"                  t$        f      st	        j&                  |       } | |fS t        | t(              r7| j*                  j-                  | j.                  t0              j2                  } d}| |fS )Nr{   r   FzCannot create a z from a MultiIndex.Tr$  r   r   rD  rz  )r  rz   r   tupler   r   rA   rN   r  ra   r^   r\   r{   r   r3  r   _maybe_convert_datelike_arrayr  r]   r  rM   r*  taker  r   _values)r   r   cls_names      rs   !ensure_arraylike_for_datetimeliker  	  s\    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:ru   c                     y rp   r   r^  s    rs   validate_periodsr  	      ru   c                     y rp   r   r  s    rs   r  r  	  r  ru   c                    | it        j                  |       r1t        j                  dt        t                      t        |       } | S t        j                  |       st        d|        | S )a9  
    If a `periods` argument is passed to the Datetime/Timedelta Array/Index
    constructor, cast it to an integer.

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

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

    Raises
    ------
    TypeError
        if periods is None, float, or int
    zNon-integer 'periods' in pd.date_range, pd.timedelta_range, pd.period_range, and pd.interval_range are deprecated and will raise in a future version.r   zperiods must be a number, got )	r   is_floatr   r   r   r@   r7  r  r  r  s    rs   r  r  	  sj    $ << MM2 +- 'lG N (<WIFGGNru   c                V    |&|  | |k7  rt        d| d| j                         | |} | S )a
  
    If the user passes a freq and another freq is inferred from passed data,
    require that they match.

    Parameters
    ----------
    freq : DateOffset or None
    inferred_freq : DateOffset or None

    Returns
    -------
    freq : DateOffset or None
    r_  r`  )r  rT  )r   rW  s     rs   rP  rP  	  sO        5%m_ 5?<<." 
 < DKru   c                    t        | t              r| j                  S t        | t              r3| j                  dvrt        d| d      | j                  j                  S t        j                  |       d   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   rI  z does not have a resolution.r   )	rz   rJ   r'  rH   r   r  pyarrow_dtyper   datetime_datar   s    rs   rh  rh  
  sk     %)zz	E:	&::T!x'CDEE""'''E"1%%ru   )rq   r  )r   r.   r+  r.   )r   rD  r  r  r+  ztuple[ArrayLike, bool])r^  r-  r+  r-  )r^  zint | floatr+  r7  )r^  zint | float | Noner+  r  )r   r   rW  r   r+  r   )r{   z'DatetimeTZDtype | np.dtype | ArrowDtyper+  r  )
__future__r   r   r   	functoolsr   rn  typingr   r   r	   r
   r   r   r   r   r   numpyr   pandas._configr   pandas._libsr   r   pandas._libs.arraysr   pandas._libs.tslibsr   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,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   pandas.compat.numpyr9   r  pandas.errorsr:   r;   r<   pandas.util._decoratorsr=   r>   r?   pandas.util._exceptionsr@   pandas.core.dtypes.castrA   pandas.core.dtypes.commonrB   rC   rD   rE   rF   rG   pandas.core.dtypes.dtypesrH   rI   rJ   rK   rL   pandas.core.dtypes.genericrM   rN   pandas.core.dtypes.missingrO   rP   pandas.corerQ   rR   rS   rT   pandas.core.algorithmsrU   rV   rW   pandas.core.array_algosrX   pandas.core.arraylikerY   pandas.core.arrays._mixinsrZ   r[   pandas.core.arrays.arrow.arrayr\   pandas.core.arrays.baser]   pandas.core.arrays.integerr^   pandas.core.commoncorecommonr   pandas.core.constructionr_   r)  r`   ra   pandas.core.indexersrb   rc   pandas.core.ops.commonrd   pandas.core.ops.invalidre   rf   pandas.tseriesrg   collections.abcrh   ri   r2  rk   r  rl   rm   rn   r.  rt   r   r   r@  r  r  r  r  rq  r  r  rP  rh  r   ru   rs   <module>r     s   "  	 	 	   - .    & K = C    $ / 
 
 5 K  
  
 ? * ? 2 3     
 <
 '
   ('121
6W3)W3t0;1( ;1|=
~668^( ^J$$ #$$N 
 
 
 
D
,=:&ru   