
    Owg\                      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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-m.Z. d dl/m0Z0 d dl1m2Z2 d dl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZC d dlDmEZF d dlGmHZHmIZImJZJ d dlKmLZLmMZMmNZN d dlOmPZP d dlQmRZR d dlSmTZTmUZUmVZVmWZWmXZXmYZY d dlZm[Z[m\Z\m]Z]m^Z^m_Z_ d dl`maZambZb d dlcmdZdmeZe d dlfmgZgmhZhmiZimjZj d dlkmlZlmmZmmnZn d dlompZp d dlqmrZr d dlsmtZtmuZu d dlvmwZw d dlxmyZy d dlzm{Z{ d dl|m}c m~Z 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e6ef   Zd9d'Zd:d(Z G d) d*eret      Z G d+ d,e      Zd-Zd.Zd/Zd0Z G d1 d2e      Z	 	 	 	 	 	 d;d3Zed<d4       Zed=d5       Zd>d6Z	 	 	 	 	 	 d?d7Zd@d8Zy)A    )annotations)datetime	timedelta)wrapsN)TYPE_CHECKINGAnyCallableLiteralUnioncastfinaloverload)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)re   rc   )op_nameops     V/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/core/arrays/datetimelike.py_make_unpacked_invalid_oprs      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dtyperK   viewr   r   	_box_func_value_from_backing_data)selfargskwargsarrresultres_i8meths         rr   new_methz"_period_dispatch.<locals>.new_meth   s    $**k2.t.v..ii!c+D+F+S=J	*>>&--00T"&&v..rt   )r   r   r-   )r   r   s   ` rr   _period_dispatchr      s*     4[/ / 8rt   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    rr   _can_hold_naz#DatetimeLikeArrayMixin._can_hold_na   s    rt   NFc                    t        |       ro   r9   )r   datarz   r   copys        rr   __init__zDatetimeLikeArrayMixin.__init__   s     "$''rt   c                    t        |       )z
        The scalar associated with this datelike

        * PeriodArray : Period
        * DatetimeArray : Timestamp
        * TimedeltaArray : Timedelta
        r   r   s    rr   _scalar_typez#DatetimeLikeArrayMixin._scalar_type   s     "$''rt   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     rr   _scalar_from_stringz*DatetimeLikeArrayMixin._scalar_from_string       $ "$''rt   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     rr   _unbox_scalarz$DatetimeLikeArrayMixin._unbox_scalar   s    * "$''rt   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     rr   _check_compatible_withz-DatetimeLikeArrayMixin._check_compatible_with  r   rt   c                    t        |       )zI
        box function to get object from internal representation
        r   )r   xs     rr   r|   z DatetimeLikeArrayMixin._box_func-  s     "$''rt   c                F    t        j                  || j                  d      S )z1
        apply box func to passed values
        F)convert)r   	map_inferr|   )r   valuess     rr   _box_valuesz"DatetimeLikeArrayMixin._box_values3  s     }}VT^^UCCrt   c                      j                   dkD  r fdt        t                     D        S  fd j                  D        S )N   c              3  (   K   | ]	  }|     y wro   r   ).0nr   s     rr   	<genexpr>z2DatetimeLikeArrayMixin.__iter__.<locals>.<genexpr>;  s     6DG6s   c              3  @   K   | ]  }j                  |        y wro   )r|   )r   vr   s     rr   r   z2DatetimeLikeArrayMixin.__iter__.<locals>.<genexpr>=  s     9!DNN1%9s   )ndimrangelenasi8r   s   `rr   __iter__zDatetimeLikeArrayMixin.__iter__9  s1    99q=6U3t9%5669tyy99rt   c                8    | j                   j                  d      S )z
        Integer representation of the values.

        Returns
        -------
        ndarray
            An ndarray with int64 dtype.
        rx   )r   r{   r   s    rr   r   zDatetimeLikeArrayMixin.asi8?  s     }}!!$''rt   r   )na_repdate_formatc                   t        |       )z|
        Helper method for astype when converting to strings.

        Returns
        -------
        ndarray[str]
        r   )r   r   r   s      rr   _format_native_typesz+DatetimeLikeArrayMixin._format_native_typesO  s     "$''rt   c                    dj                   S )Nz'{}')format)r   boxeds     rr   
_formatterz!DatetimeLikeArrayMixin._formatter[  s    }}rt   c                x    t        |      r$t        j                  t        |       t              S | j
                  S )Nrz   )rD   npr^   listobjectr   )r   rz   r   s      rr   	__array__z DatetimeLikeArrayMixin.__array__b  s+     5!88DJf55}}rt   c                     y ro   r   r   items     rr   __getitem__z"DatetimeLikeArrayMixin.__getitem__j      rt   c                     y ro   r   r   s     rr   r   z"DatetimeLikeArrayMixin.__getitem__n  s    
 	rt   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_scalarr3   _get_getitem_freq_freq)r   keyr   	__class__s      rr   r   z"DatetimeLikeArrayMixin.__getitem__u  sR     2EG4G4LM== M $'F--c2rt   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)ry   rz   rK   r   r   ra   slicestepEllipsiscomis_bool_indexerr   maybe_booleans_to_slicer{   r   uint8r   )r   r   	is_periodr   new_keys        rr   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'::rt   c                f    t        |||       }t        | 	  ||       |ry | j                          y ro   )rb   r   __setitem___maybe_clear_freq)r   r   r   no_opr   s       rr   r   z"DatetimeLikeArrayMixin.__setitem__  s6     &c5$7 	C' rt   c                     y ro   r   r   s    rr   r   z(DatetimeLikeArrayMixin._maybe_clear_freq  s     	rt   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        |t               rt"        | I  ||      S t'        |      r| j)                         S |j                  d	v rO| j
                  }|t*        j,                  k7  rt/        d
| j                   d| d      |r|j1                         }|S |j                  dv r| j                  |k7  s|j                  dk(  r&dt3        |       j4                   d| }t/        |      t+        j6                  | |      S )NMrk   	timestamp)tzboxresomT)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   )rF   r   rz   kindr   r   r   r   _cresor    r   r   ravelreshapeshapery   rJ   r   astyperE   r   r   int64	TypeErrorr   type__name__asarray)r   rz   r   i8data	convertedr   msgr   s          rr   r   zDatetimeLikeArrayMixin.astype  s   
 U#F?zz#%OT2 .ww#		 ! C'*4==dCC##DIIOO$56>>tzzJJ~.7>%d>33U#,,..ZZ4 YYF &tzzl$ug >C C 
 MjjD TZZ5%8UZZ3=N !d!4!4 5ZwGCC. ::d%00rt   c                     y ro   r   r   s    rr   r{   zDatetimeLikeArrayMixin.view  r   rt   c                     y ro   r   r   rz   s     rr   r{   zDatetimeLikeArrayMixin.view  r   rt   c                     y ro   r   r  s     rr   r{   zDatetimeLikeArrayMixin.view  r   rt   c                     y ro   r   r  s     rr   r{   zDatetimeLikeArrayMixin.view  r   rt   c                "    t         |   |      S ro   )r   r{   )r   rz   r   s     rr   r{   zDatetimeLikeArrayMixin.view  s     w|E""rt   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_objectrz   )ry   strr   
ValueErrorr   r:   r   r   r   r   r   rC   r   _validate_listlikerD   getattr)r   r   errs      rr   _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)ry   r   r  r   r  _validation_error_messager   rN   rz   r   rO   r   r   )r   r   r  r  r  r   s         rr   _validate_scalarz'DatetimeLikeArrayMixin._validate_scalar0  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
        rz   r   r   z array'zvalue should be a 'z!', 'NaT', or array of those. Got z	 instead.z' or 'NaT'. Got )hasattrr
  rz   r   r   r   )r   r   r  msg_gotr   s        rr   r  z0DatetimeLikeArrayMixin._validation_error_messagem  s     5'"wufa'@1'DV,G$u+../q1G%d&7&7&@&@%A B**1)=  
 &d&7&7&@&@%A Biy*  
rt   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   rz   Textract_numpy)ry   r   rz   r   as_unitunitr   r   _from_sequencer  r   r   infer_dtyper   r  r   r  r`   pd_arrayrA   rH   
categories_internal_get_valuesrD   r   )r   r   r  r   s       rr   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  )rC   r	  r  _unboxr   s     rr   _validate_setitem_valuez.DatetimeLikeArrayMixin._validate_setitem_value  s?    ++E2E((t(DD{{5!!rt   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     rr   r#  zDatetimeLikeArrayMixin._unbox  sE    
 ==&&u-E
  ''.NNErt   c                    ddl m} t        | ||      } ||      }t        |t              r|j                         S |j                  S )Nr   ri   )	na_action)pandasrj   rU   ry   rM   to_numpyr^   )r   mapperr'  rj   r   s        rr   mapzDatetimeLikeArrayMixin.map  s=     49=vfm,??$$<<rt   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.
stacklevelr   DatetimeArray | TimedeltaArray)rz   r   r   zerosr   boolr_   ry   r   r   r   maybe_convert_objectsrT   r  r   r  warningswarnFutureWarningr?   r  r   r  r  r   r   r   )r   r   	inferableinferreds       rr   rT   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 ro   )_isnanr   s    rr   rO   zDatetimeLikeArrayMixin.isnaA  s    {{rt   c                (    | j                   t        k(  S )z-
        return if each value is nan
        )r   r   r   s    rr   rD  zDatetimeLikeArrayMixin._isnanD  s    
 yyD  rt   c                H    t        | j                  j                               S )zJ
        return if I have any nans; enables various perf speedups
        )r<  rD  anyr   s    rr   _hasnazDatetimeLikeArrayMixin._hasnaK  s    
 DKKOO%&&rt   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.
        )rH  r   r   nanputmaskrD  )r   r   
fill_valuer   s       rr   _maybe_mask_resultsz*DatetimeLikeArrayMixin._maybe_mask_resultsR  sD    & ;;w/!VV
JJvt{{J7rt   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    rr   rO  zDatetimeLikeArrayMixin.freqstrp  s!    4 99yy   rt   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   rf   
infer_freqr  r   s    rr   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ro   )rO  r   get_reso_from_freqstrKeyError)r   rO  s     rr   _resolution_objz&DatetimeLikeArrayMixin._resolution_obj  s;    ,,?	33G<< 		s   & 	22c                .    | j                   j                  S )zO
        Returns day, hour, minute, second, millisecond or microsecond
        )rV  attrnamer   s    rr   
resolutionz!DatetimeLikeArrayMixin.resolution  s     ##,,,rt   c                J    t        j                  | j                  d      d   S )NTtimeliker   r   is_monotonicr   r   s    rr   _is_monotonic_increasingz/DatetimeLikeArrayMixin._is_monotonic_increasing      !!$))d;A>>rt   c                J    t        j                  | j                  d      d   S )NTr[  r   r]  r   s    rr   _is_monotonic_decreasingz/DatetimeLikeArrayMixin._is_monotonic_decreasing  r`  rt   c                v    t        t        | j                  j                  d                  | j                  k(  S )NK)r   rV   r   r   sizer   s    rr   
_is_uniquez!DatetimeLikeArrayMixin._is_unique  s(    8DIIOOC012dii??rt   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   rz   r   Fr  rx   ))r   r
  r   r   r   r  r:   rd   rD   rS   comp_method_OBJECT_ARRAYr   r   r   r   r   operatorneonesr<  r;  ry   rz   rK   r   TimelikeOpsr   r   r  r  r  r^   asm8r%   r   r#  r{   rO   rD  rG  rK  )
r   r   rq   rz   r   	other_arr
other_valso_maskmask
nat_results
             rr   _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)ry   r   ordinalr   r   r}   rD  r   )r   r   i8valuesrq  s       rr   _get_i8_values_and_maskz.DatetimeLikeArrayMixin._get_i8_values_and_mask  sq     eV$}}HD ~ 	956||HD
 ~ <<DzzH~rt   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)ry   rz   rK   r   r   r   r   r   s     rr   _get_arithmetic_result_freqz2DatetimeLikeArrayMixin._get_arithmetic_result_freq*  sF     djj+.99u%		4(99rt   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 rm   r   rk   )tz_to_dtypezM8[]r   rx   r   r  rz   r   )r   is_np_dtyperz   r   r   r   r   pandas.core.arraysrk   pandas.core.arrays.datetimesr  r   rO   r   to_datetime64r   r  _simple_newr   _ensure_matching_resosr  r   r   r   r   r{   r   r  )
r   r   rk   r  r   other_i8rp  
res_valuesrz   new_freqs
             rr   _add_datetimelike_scalarz/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,=,,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Prt   c                    t        j                  | j                  d      s7t        dt	        |       j
                   dt	        |      j
                         || z   S )Nr   r  r  )r   r  rz   r   r   r   r   s     rr   _add_datetime_arraylikez.DatetimeLikeArrayMixin._add_datetime_arraylike\  sS    tzz3/d4j112%U8L8L7MN 
 t|rt   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 rk   )rz   r   r   r   r   r   rO   r   r   r  _sub_datetimelike)r   r   tss      rr   _sub_datetimelike_scalarz/DatetimeLikeArrayMixin._sub_datetimelike_scalarf  s     ::??c!@dATAT@UVWWOT* ;#:u..r2b%%b))rt   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 lengthrk   )
rz   r   r   r   r   r   r  r   r  r  r   s     rr   _sub_datetime_arraylikez.DatetimeLikeArrayMixin._sub_datetime_arraylikey  s}    ::??c!@dATAT@UVWWt9E
"CDDOT*11%8e%%e,,rt   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)Nrk   r   rm   comparesubtractrx   r   timedelta64[r  zTick | Noner  )r   r  rm   _assert_tzawareness_compatr   r  replacer   r  r   r   r   r   r{   r  r  r  rz   )
r   r   rm   r  new_messager  rp  r  res_m8r  s
             rr   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   )rl   r   )r   r  rz   r   r   r   pandas.core.arrays.periodrl   r   broadcast_tor  r   rK   r   )r   r   rl   i8valsrz   parrs         rr   _add_periodz"DatetimeLikeArrayMixin._add_period  ss    tzz3/5d4j6I6I5JKLL 	:

;EJJ'6/d{rt   c                    t        |       ro   r   )r   offsets     rr   _add_offsetz"DatetimeLikeArrayMixin._add_offset  s    !$''rt   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
        rx   r   r:  )rO   r   emptyr   r{   r   rz   fillr   r   r  r   r   r  _add_timedeltalike)r   r   
new_valuess      rr   _add_timedeltalike_scalarz0DatetimeLikeArrayMixin._add_timedeltalike_scalar  s     ;$**D9>>t}}?R?RSJOOD!:))*DJJ)GG 4d;% 11%8e&&u--rt   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  r:  )r   r  r   r  r  r   s     rr   _add_timedelta_arraylikez/DatetimeLikeArrayMixin._add_timedelta_arraylike  sR     t9E
"CDD4d;11%8e&&u--rt   c                R   t        d|       } | j                  |      \  }}t        | j                  t	        j
                  |d            }|j                  | j                  j                        }| j                  |      }t        |       j                  || j                  |      S )Nr:  rx   r   r  )r   r  r   r   r   r   r{   r   rz   r  r   r  )r   r   r  rp  r  r  r  s          rr   r  z)DatetimeLikeArrayMixin._add_timedeltalike  s    4d;77>&%diiHD1QR
__T]]%8%89
33E:
 Dz%%djjx & 
 	
rt   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  )ry   rz   rK   r   r   r   r   r   r   r  r   r   r  r   r{   r   r  r   r   s     rr   _add_natzDatetimeLikeArrayMixin._add_nat  s    
 djj+.d4j112%S	8J8J7KL  4d; $**BHH5DT]]001 Dz%%$**4 & 
 	
rt   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   rz   r   r   r{   r  r  s     rr   _sub_natzDatetimeLikeArrayMixin._sub_nat  sq     $**BHH5D::??d"7>D;;dii[:;;;;011rt   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 rl   rx   r   )ry   rz   rK   r   r   r   r   r   r  r   r   r   r   r^   r   baserD  r   )r   r   r  rp  new_i8_datar   new_datarq  s           rr   _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.r8  O)ri  addsubr   r   r>  r?  r   r   r;   r?   r   r   r   r   )r   r   rq   r  s       rr   _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*;<
rt   r4  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 r5  r   )r   r   r
  rW   r   r  rz   )r   namer5  r   rq   r   s         rr   _accumulatez"DatetimeLikeArrayMixin._accumulateI  sm    ++mD61DT$ZLQRR/6DIIK99&9Dz%%fDJJ%??rt   __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 )Nrz   r   rl   r   r   r  )'r
  r_   r   r  ry   r   r   r   r.  r  r   r  r   r/  r  r   r   r  rz   r  
is_integerrK   r'   r   _addsub_int_array_or_scalar_nri  r  r  rD   r  rI   r  rB   NotImplementedndarrayr  rm   r  r   r   other_dtyper   objrm   s         rr   r  zDatetimeLikeArrayMixin.__add__R  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rt   c                $    | j                  |      S ro   )r  r   s     rr   __radd__zDatetimeLikeArrayMixin.__radd__  s    ||E""rt   __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 )Nrz   rl   r   r   r   r  )'r
  r_   r   r  ry   r   r   r   r.  r  r   r  r   r/  r  r   r  rz   rK   r'   r   r  r  ri  r  r   r  r  r  rD   r  rI   r  rB   r  r  r  rm   r  r  s         rr   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rt   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 )	Nrz   r   r   r   r  r  r  rm   )r
  r   r  ry   rI   rz   r   r   r   r  rk   r  r   r  r   r   r   rK   r   )r   r   r  other_is_dt64rk   s        rr   __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?" rt   c                v    | |z   }|d d  | d d  t        | j                  t              s|j                  | _        | S ro   ry   rz   rK   r   r   r   r   r   s      rr   __iadd__zDatetimeLikeArrayMixin.__iadd__  6    )Q$**k2DJrt   c                v    | |z
  }|d d  | d d  t        | j                  t              s|j                  | _        | S ro   r  r  s      rr   __isub__zDatetimeLikeArrayMixin.__isub__  r  rt   c                &    t         |   ||      S )N)qsinterpolation)r   	_quantile)r   r  r  r   s      rr   r  z DatetimeLikeArrayMixin._quantile  s     w Bm DDrt   axisr5  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   rR   nanminr   _wrap_reduction_resultr   r  r5  r   r   s        rr   minzDatetimeLikeArrayMixin.min  O     	F#
dii0t}}4G**488rt   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   rR   nanmaxr   r  r  s        rr   maxzDatetimeLikeArrayMixin.max  r  rt   r   )r5  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  r5  rq  )ry   rz   rK   r   r   r   rR   nanmeanr   rO   r  )r   r5  r  r   s       rr   meanzDatetimeLikeArrayMixin.mean)  su    X djj+..tDz/B/B.C D7 7  MMV$))+
 **488rt   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  rR   	nanmedianr   r  r  s        rr   medianzDatetimeLikeArrayMixin.medianb  s^    
2v&D	TYY 6?@@!!$--d6J**488rt   c                   d }|r| j                         }t        j                  | j                  d      |      }|j                  | j                  j
                        }t        t        j                  |      }| j                  |      S )Nrx   )rq  )
rO   rP   moder{   r   rz   r   r   r  r~   )r   dropnarq  i8modesnpmodess        rr   _modezDatetimeLikeArrayMixin._model  sf    99;D//$))D/=,,t}}223rzz7+&&w//rt   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)rG  allr  zh' with datetime64 dtypes is deprecated and will raise in a future version. Use (obj != pd.Timestamp(0)).z() instead.r8  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 rw   r   )WrappedCythonOp)howr   has_dropped_na)	min_countngroupscomp_idsrq  )stdsemr  z-'std' and 'sem' are not valid for PeriodDtyper:  zm8[r  r   )rz   r   r   r>  r?  r@  r?   ry   rK   r   r{   pandas.core.groupby.opsr  get_kind_from_how_cython_op_ndim_compatr  cast_blocklistr  rm   r   r  r  r~   )r   r  r  r  r  idsr   rz   npvaluesr  r   rq   r  rm   	new_dtypes                  rr   _groupby_opz"DatetimeLikeArrayMixin._groupby_opy  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2rt   returnr<  )NNF)rz   Dtype | Noner   r<  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&  rg   )r&  znpt.NDArray[np.int64])r   zstr | floatr&  npt.NDArray[np.object_])F)r   r<  )NN)rz   zNpDtype | Noner   zbool | Noner&  r   )r   r2   r&  r)  )r   z(SequenceIndexer | PositionalIndexerTupler&  r3   )r   r0   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   r<  r&  r3   )rz   zLiteral['M8[ns]']r&  rk   )rz   zLiteral['m8[ns]']r&  rm   ).)rz   r'  r&  r(   ro   )r  r<  r  r<  )r  r<  r&  r  )r  r<  )r&  z6np.int64 | np.datetime64 | np.timedelta64 | np.ndarray)r   r(   r&  npt.NDArray[np.bool_])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&  rk   )r   rk   r&  rk   )r   zdatetime | np.datetime64r&  rm   )r   rk   r&  rm   )r   zTimestamp | DatetimeArrayr&  rm   )r   r   r&  rl   )r   rm   )r   zTimedelta | TimedeltaArray)r   zPeriod | PeriodArrayr&  r+  )r   r+  )r  r  r5  r<  r&  r3   )r  znpt.NDArray[np.float64]r  r  r&  r3   )r  AxisInt | Noner5  r<  )r5  r<  r  r1  )r	  r<  )
r  r  r  r<  r  intr  r2  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#  rZ   r+  rT   rO   rD  rH  r   rM  rO  rR  rV  rY  r_  rb  rf  rs  rs   rt  ru  rv  rw  rx  ry  rz  r{  r|  r}  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rc   r  r  r  r  r  r  r   r  r  r  r  r  r  r$  __classcell__r   s   @rr   r   r      s    $#44))
  IN('(AE(	(
 ( (((("(	2(.(,(D: 
( 
(  (-$
($
(	 
( AE#2=	   6 
 "<!9! -! 
	!,
11f        #"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3rt   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                r    | j                  |t        j                        }|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   Fr   )r   r   rJ  r   r   )r   r   r   s      rr   strftimezDatelikeOps.strftime  s1    b **{266*R}}V%}00rt   N)r   r  r&  r+  )r   r3  r4  r5  r=   r>  r   rt   rr   r;  r;    s%     *.1	.1rt   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 )=rl  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.r8  Tr  r   na_valuer   dtype=z does not match data dtype Mmrx   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   rz   )&r>  r?  r   r   r@  r?   rF   r`   ry   r]   r)  r   r
  r   
no_defaultr   r"   _validate_inferred_freqrz   r   r   r   r  r   r@  r{   r  r   r  rI   r  _validate_dtyper   r   r   r   r   _validate_frequency)	r   r   rz   r   r   rR  explicit_noner   r#  s	            rr   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 rt   c                    t        |       ro   r   )clsr   rz   s      rr   rL  zTimelikeOps._validate_dtype  s    !#&&rt   c                    | j                   S )zK
        Return the frequency object if it is set, otherwise None.
        r   r   s    rr   r   zTimelikeOps.freq  s    
 zzrt   c                    |kt        |      }| j                  | |       | j                  j                  dk(  rt	        |t
              st        d      | j                  dkD  rt        d      || _	        y )Nr   rI  r   zCannot set freq with ndim > 1)
r"   rM  rz   r   ry   r   r   r   r  r   r   s     rr   r   zTimelikeOps.freq  se    e$E$$T51zz#%j.E JKKyy1} !@AA
rt   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.
        NrH  )r   r"   rR  r   rJ  r   rM  rK  )r   r   validate_kwdss      rr   _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$**5rt   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   )rR  re  rO  _generate_ranger   r  r   array_equalr   r  r  )rP  indexr   r   rB  on_freqr  s          rr   rM  zTimelikeOps._validate_frequency0  s     &&::?h$,,6	)c)) AhE
ZZ G >>%**gll;   < 	c#h& 	 %hZ 088<~G 	s   AB 	C+C  Cc                    t        |       ro   r   )rP  rX  rY  rZ  r   r   r   s          rr   r]  zTimelikeOps._generate_range\  s     "#&&rt   c                @    t        | j                  j                        S ro   )r   r   rz   r   s    rr   r   zTimelikeOps._cresod  s    "4==#6#677rt   c                ,    t        | j                        S ro   )dtype_to_unitrz   r   s    rr   r  zTimelikeOps.unith  s    
 TZZ((rt   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'rG  r  r  rk   r  r  )r  r   rz   r   r   r   ry   r   r   rI   r   r  r   )r   r  r  rz   r  r#  r   s          rr   r  zTimelikeOps.as_unito  s    ..HIIDJJOO,BtfA67(Q
djj"((+"((Iot,//B'2D9I Dz%%idii & 
 	
rt   c                    | j                   |j                   k7  rS| j                   |j                   k  r| j                  |j                        } | |fS |j                  | j                        }| |fS ro   )r   r  r  r   s     rr   r  z"TimelikeOps._ensure_matching_resos  s^    ;;%,,&{{U\\)||EJJ/ U{ dii0U{rt   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        rr   ro  zTimelikeOps.__array_ufunc__  sq    bhh"++66Fq q	T! *75&)$--B6BBw&ufHvHHHrt   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 )Nrk   )	ambiguousnonexistentrx   r   rL  r   )ry   rz   rI   r   tz_localize_roundr   r{   r   r  r&   r   r   r$   rM  r   r   r  )
r   r   r  rt  ru  naiver   r   nanos	result_i8s
             rr   rx  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9rt   round)rq   c                F    | j                  |t        j                  ||      S ro   )rx  r#   NEAREST_HALF_EVENr   r   rt  ru  s       rr   r|  zTimelikeOps.round  s     {{4!:!:I{SSrt   floorc                F    | j                  |t        j                  ||      S ro   )rx  r#   MINUS_INFTYr  s       rr   r  zTimelikeOps.floor  s     {{4!4!4iMMrt   ceilc                F    | j                  |t        j                  ||      S ro   )rx  r#   
PLUS_INFTYr  s       rr   r  zTimelikeOps.ceil  s     {{4!3!3YLLrt   r  c               d    t        j                  | j                  ||| j                               S Nr  )rR   nananyr   rO   r   r  r5  s      rr   rG  zTimelikeOps.any  s!    }}T]]f499;WWrt   c               d    t        j                  | j                  ||| j                               S r  )rR   nanallr   rO   r  s      rr   r  zTimelikeOps.all  s#     }}T]]f499;WWrt   c                    d | _         y ro   rR  r   s    rr   r   zTimelikeOps._maybe_clear_freq  s	    
rt   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   rI  rH  )r   ry   r   rz   r   r   r   r"   rR  r{   r   )r   r   r   s      rr   
_with_freqzTimelikeOps._with_freq  sz     <Y!^
4 <zz#%jt.D JKK 7?"?T//0Diik	
rt   c                    t        | j                  t        j                        r| j                  S t        |          S ro   )ry   rz   r   r   r   _values_for_json)r   r   s    rr   r  zTimelikeOps._values_for_json  s-    djj"((+== w'))rt   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        rr   r  zTimelikeOps.factorize	  s    
 99 IIc$irww7EiikG		add!$B$-'>! &(d)<)<(= >= = 
 w  AArt   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ro   r   )r   r   r  s     rr   r   z0TimelikeOps._concat_same_type.<locals>.<genexpr>*	  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     rr   r   z0TimelikeOps._concat_same_type.<locals>.<genexpr>,	  s/     NtAwr{SXX-a;Ns   (+)r   _concat_same_typer   r   r  zipr   )	rP  	to_concatr  new_objr   pairsr  r  r   s	          @rr   r  zTimelikeOps._concat_same_type	  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      rr   r   zTimelikeOps.copy1	  s#    ',U,+		rt   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)rq  r  r_  limitlimit_direction
limit_arear   )r  r   r   rQ   interpolate_2d_inplacer   r  rz   )
r   rq  r  r_  r  r  r  r   r   out_datas
             rr   interpolatezTimelikeOps.interpolate6	  s      X%%}}H}}))+H&&		
+!		
 		
 KDz%%hdjj%AArt   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  rz   r   r   r   r!   r   logical_andr  )r   
values_intconsider_valuesr   ppd	even_dayss         rr   _is_dates_onlyzTimelikeOps._is_dates_only_	  ss     tzz*YY
$,"4::.d# NN?J4D4IJNNPTUU	rt   )r   r<  r&  r(  r,  )rU  dict)r   r   )rZ  
int | Noner&  r3   )r&  r2  r0  r-  )r  r  r  r<  r&  r3   )rp  znp.ufuncrq  r  )raiser  )rt  r5   ru  r6   r&  r3   )r  r1  r5  r<  r&  r<  r.  r*  )TF)r  r<  r  r<  )r   )r  zSequence[Self]r  r)   r&  r3   )C)r  r  r&  r3   )
rq  r.   r  r2  r_  rj   r   r<  r&  r3   r%  ),r   r3  r4  r5  r6  r   rJ  r   classmethodrL  r7  r   setterr   rV  rM  r]  r>   r   r  r  r  ro  rx  r<   
_round_doc_round_exampler   r|  _floor_exampler  _ceil_exampler  rG  r  r   r  r  r  r  r   r  r  r8  r9  s   @rr   rl  rl    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  rt   rl  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 )Nrz   r   FzCannot create a z from a MultiIndex.Tr  r   r   rB  rv  )r  ry   r   tupler   r   r@   rM   r   r`   r]   r[   rz   r   r)  r   _maybe_convert_datelike_arrayr  r\   r   rL   r   taker  r   _values)r   r   cls_names      rr   !ensure_arraylike_for_datetimeliker  y	  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:rt   c                     y ro   r   rZ  s    rr   validate_periodsr  	      rt   c                     y ro   r   r  s    rr   r  r  	  r  rt   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.r8  zperiods must be a number, got )	r   is_floatr>  r?  r@  r?   r2  r  r   r  s    rr   r  r  	  sj    $ << MM2 +- 'lG N (<WIFGGNrt   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  rO  )r   rR  s     rr   rK  rK  	  sO        5%m_ 5?<<." 
 < DKrt   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   rD  z does not have a resolution.r   )	ry   rI   r  rG   r   r  pyarrow_dtyper   datetime_datar   s    rr   rd  rd  	  sk     %)zz	E:	&::T!x'CDEE""'''E"1%%rt   )rp   r  )r   r-   r&  r-   )r   r<  r  r  r&  ztuple[ArrayLike, bool])rZ  r(  r&  r(  )rZ  zint | floatr&  r2  )rZ  zint | float | Noner&  r  )r   r   rR  r   r&  r   )rz   z'DatetimeTZDtype | np.dtype | ArrowDtyper&  r  )
__future__r   r   r   	functoolsr   ri  typingr   r   r	   r
   r   r   r   r   r>  numpyr   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.   r/   r0   r1   r2   r3   r4   r5   r6   r7   pandas.compat.numpyr8   r  pandas.errorsr9   r:   r;   pandas.util._decoratorsr<   r=   r>   pandas.util._exceptionsr?   pandas.core.dtypes.castr@   pandas.core.dtypes.commonrA   rB   rC   rD   rE   rF   pandas.core.dtypes.dtypesrG   rH   rI   rJ   rK   pandas.core.dtypes.genericrL   rM   pandas.core.dtypes.missingrN   rO   pandas.corerP   rQ   rR   rS   pandas.core.algorithmsrT   rU   rV   pandas.core.array_algosrW   pandas.core.arraylikerX   pandas.core.arrays._mixinsrY   rZ   pandas.core.arrays.arrow.arrayr[   pandas.core.arrays.baser\   pandas.core.arrays.integerr]   pandas.core.commoncorecommonr   pandas.core.constructionr^   r  r_   r`   pandas.core.indexersra   rb   pandas.core.ops.commonrc   pandas.core.ops.invalidrd   re   pandas.tseriesrf   collections.abcrg   rh   r(  rj   r  rk   rl   rm   r)  rs   r   r   r;  r  r  r  r  rl  r  r  rK  rd  r   rt   rr   <module>r     s   "  	 	 	   .    & K = C    $ / 
 
 5 K  
  
 ? * ? 2 3     
 <
 '
   ('121
6B3)B3J071( 71t=
~668^( ^J$$ #$$N 
 
 
 
D
,=:&rt   