a
    DBìj´a ã                   @  sè  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  m€Z� d d l‚mƒZ„m…Z…m†Z† d d!l‡mˆZˆm‰Z‰ d d"lŠm‹Z‹ d d#lŒm�Z�mŽZŽ d d$l�m�Z� e�rd d%l‘m’Z’m“Z“ d d&l”m•Z• d d'l–m—Z—m˜Z˜m™Z™ ee8ef Zšd(d)œd*d+„Z›d,d,d-œd.d/„ZœG d0d1„ d1etevƒZ�G d2d3„ d3e�ƒZžd4ZŸd5Z d6Z¡d7Z¢G d8d9„ d9e�ƒZ£d:d(d;d<œd=d>„Z¤ed?d?d@œdAdB„ƒZ¥edCdDd@œdEdB„ƒZ¥dFdGd@œdHdB„Z¥dIdIdIdJœdKdL„Z¦dMd(dNœdOdP„Z§dS )Qé    )Ú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ÚTimedeltaArrayÚstr)Úop_namec                 C  s   t | ƒ}t| ƒ|ƒS ©N)re   rc   )ro   Úop© rr   ú^/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pandas/core/arrays/datetimelike.pyÚ_make_unpacked_invalid_op¦   s    rt   r-   )ÚmethÚreturnc                   s   t ˆ ƒ‡ fd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                   sx   t | jtƒs"ˆ | g|¢R i |¤ŽS |  d¡}ˆ |g|¢R i |¤Ž}|tu rNtS t |tƒrd|  |j¡S | d¡}|  |¡S )NúM8[ns]Úi8)	Ú
isinstanceÚdtyperK   Úviewr   r   Ú	_box_funcÚ_valueÚ_from_backing_data)ÚselfÚargsÚkwargsÚarrÚresultZres_i8©ru   rr   rs   Únew_meth²   s    


z"_period_dispatch.<locals>.new_meth)r   r   r-   )ru   r…   rr   r„   rs   Ú_period_dispatch«   s    r†   c                      sÀ  e Zd ZU dZded< ded< ded< ded	< d
ed< eddœdd„ƒZdñddddœdd„Zeddœdd„ƒZ	dddœdd„Z
dddœd d!„Zddd"œd#d$„Zd%d&„ Zddœd'd(„Zd)dœd*d+„Zed,dœd-d.„ƒZd/dd0œd1d2d3œd4d5„Zdòdd6œd7d8„Zdód9d:ddœd;d<„Zed=dd>œd?d@„ƒZedAdBd>œdCd@„ƒZdDdEdFœ‡ fdGd@„Zd
dœdHdI„ZdJdKddLœ‡ fdMdN„ZddœdOdP„ZdôddRœ‡ fdSdT„ZedBdœdUdV„ƒZedWdXdYœdZdV„ƒZed[d\dYœd]dV„ƒZedõdd_dYœd`dV„ƒZdödd_dYœ‡ fdadV„Zdbdc„ ZddQddœddddœdedf„Zd÷dddgœdhdi„Zdøddjœdkdl„Zdmdn„ Ze dodœdpdq„ƒZ!e"dùdrds„ƒZ#d_dtduœdvdw„Z$dtdœdxdy„Z%edtdœdzd{„ƒZ&eddœd|d}„ƒZ'e(dfddd~œdd€„Z)ed�dœd‚dƒ„ƒZ*ed�dœd„d…„ƒZ+ed†dœd‡dˆ„ƒZ,eddœd‰dŠ„ƒZ-eddœd‹dŒ„ƒZ.eddœd�dŽ„ƒZ/eddœd�d�„ƒZ0d‘d’„ Z1e2d“ƒZ3e2d”ƒZ4e2d•ƒZ5e2d–ƒZ6e2d—ƒZ7e2d˜ƒZ8e2d™ƒZ9e2dšƒZ:e2d›ƒZ;e2dœƒZ<e2d�ƒZ=e2džƒZ>e dŸdœd d¡„ƒZ?e d
dœd¢d£„ƒZ@e dXdœd¤d¥„ƒZAe dXdXd"œd¦d§„ƒZBe d¨d\d"œd©dª„ƒZCe dXd\d"œd«d¬„ƒZDe d­d\d"œd®d¯„ƒZEe d°d±d"œd²d³„ƒZFd´dµ„ ZGd¶d·„ ZHd\d¸œd¹dº„ZIe d»d¸œd¼d½„ƒZJe d¾d¿„ ƒZKe dÀdÁ„ ƒZLe dÂd2d"œdÃdÄ„ƒZMe d2d¸œdÅdÆ„ƒZNdQdÇœdddBdÈœdÉdÊ„ZOePdËƒdÌdÍ„ ƒZQdÎdÏ„ ZRePdÐƒdÑdÒ„ ƒZSdÓdÔ„ ZTdBdœdÕdÖ„ZUdBdœd×dØ„ZVeWdÙddBdÚœ‡ fdÛdÜ„ƒZXeWddQdÝœdÞddÝœdßdà„ƒZYeWddQdÝœdÞddÝœdádâ„ƒZZdQdãdäœddÞdäœdådæ„Z[eWddQdÝœdÞddÝœdçdè„ƒZ\dúddéœdêdë„Z]dddìdìdídîœdïdð„Z^‡  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ÚfreqÚbool©rv   c                 C  s   dS )NTrr   ©r   rr   rr   rs   Ú_can_hold_naÚ   s    z#DatetimeLikeArrayMixin._can_hold_naNFzDtype | NoneÚNone)rz   Úcopyrv   c                 C  s   t | ƒ‚d S rp   ©r9   )r   Údatarz   rŽ   r”   rr   rr   rs   Ú__init__Þ   s    zDatetimeLikeArrayMixin.__init__ztype[DatetimeLikeScalar]c                 C  s   t | ƒ‚dS )z£
        The scalar associated with this datelike

        * PeriodArray : Period
        * DatetimeArray : Timestamp
        * TimedeltaArray : Timedelta
        Nr•   r‘   rr   rr   rs   Ú_scalar_typeã   s    	z#DatetimeLikeArrayMixin._scalar_typern   ÚDTScalarOrNaT)Úvaluerv   c                 C  s   t | ƒ‚dS )ay  
        Construct a scalar type from a string.

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

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

        Notes
        -----
        This should call ``self._check_compatible_with`` before
        unboxing the result.
        Nr•   ©r   rš   rr   rr   rs   Ú_scalar_from_stringî   s    z*DatetimeLikeArrayMixin._scalar_from_stringz)np.int64 | np.datetime64 | np.timedelta64c                 C  s   t | ƒ‚dS )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')
        Nr•   r›   rr   rr   rs   Ú_unbox_scalar  s    z$DatetimeLikeArrayMixin._unbox_scalar)Úotherrv   c                 C  s   t | ƒ‚dS )a|  
        Verify that `self` and `other` are compatible.

        * DatetimeArray verifies that the timezones (if any) match
        * PeriodArray verifies that the freq matches
        * Timedelta has no verification

        In each case, NaT is considered compatible.

        Parameters
        ----------
        other

        Raises
        ------
        Exception
        Nr•   ©r   rž   rr   rr   rs   Ú_check_compatible_with  s    z-DatetimeLikeArrayMixin._check_compatible_withc                 C  s   t | ƒ‚dS )zI
        box function to get object from internal representation
        Nr•   )r   Úxrr   rr   rs   r|   /  s    z DatetimeLikeArrayMixin._box_funcc                 C  s   t j|| jdd�S )z1
        apply box func to passed values
        F)Úconvert)r   Z	map_inferr|   )r   Úvaluesrr   rr   rs   Ú_box_values5  s    z"DatetimeLikeArrayMixin._box_valuesrg   c                   s<   ˆ j dkr$‡ fdd„ttˆ ƒƒD ƒS ‡ fdd„ˆ jD ƒS d S )Né   c                 3  s   | ]}ˆ | V  qd S rp   rr   )Ú.0Únr‘   rr   rs   Ú	<genexpr>=  ó    z2DatetimeLikeArrayMixin.__iter__.<locals>.<genexpr>c                 3  s   | ]}ˆ   |¡V  qd S rp   )r|   )r¦   Úvr‘   rr   rs   r¨   ?  r©   )ÚndimÚrangeÚlenÚasi8r‘   rr   r‘   rs   Ú__iter__;  s    
zDatetimeLikeArrayMixin.__iter__znpt.NDArray[np.int64]c                 C  s   | j  d¡S )z‘
        Integer representation of the values.

        Returns
        -------
        ndarray
            An ndarray with int64 dtype.
        rx   )rŒ   r{   r‘   rr   rr   rs   r®   A  s    zDatetimeLikeArrayMixin.asi8r   )Úna_repÚdate_formatzstr | floatúnpt.NDArray[np.object_])r°   rv   c                C  s   t | ƒ‚dS )z|
        Helper method for astype when converting to strings.

        Returns
        -------
        ndarray[str]
        Nr•   )r   r°   r±   rr   rr   rs   Ú_format_native_typesQ  s    
z+DatetimeLikeArrayMixin._format_native_types)Úboxedc                 C  s   dj S )Nz'{}')Úformat)r   r´   rr   rr   rs   Ú
_formatter]  s    z!DatetimeLikeArrayMixin._formatterzNpDtype | Nonezbool | Nonec                 C  sR   t |ƒr4|du r"tjdttƒ d� tjt| ƒtd�S |du rLtj| j	|d�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©rz   T)
rD   ÚwarningsÚwarnÚFutureWarningr?   Únpr^   ÚlistÚobjectrŒ   )r   rz   r”   rr   rr   rs   Ú	__array__d  s    øz DatetimeLikeArrayMixin.__array__r2   )Úitemrv   c                 C  s   d S rp   rr   ©r   rÁ   rr   rr   rs   Ú__getitem__{  s    z"DatetimeLikeArrayMixin.__getitem__z(SequenceIndexer | PositionalIndexerTupler3   c                 C  s   d S rp   rr   rÂ   rr   rr   rs   rÃ     s    r0   zSelf | DTScalarOrNaT)Úkeyrv   c                   s:   t dtƒ  |¡ƒ}t |¡r |S t t|ƒ}|  |¡|_|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   rÄ   rƒ   ©Ú	__class__rr   rs   rÃ   †  s    

c                 C  s®   t | jtƒ}|r| j}n’| jdkr(d}n‚t| |ƒ}d}t |tƒrj| jdurb|jdurb|j| j }qª| j}n@|tu rz| j}n0t	 
|¡rªt | tj¡¡}t |tƒrª|  |¡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ÚcomZis_bool_indexerr   Zmaybe_booleans_to_slicer{   r½   Zuint8rÇ   )r   rÄ   Z	is_periodrŽ   Znew_keyrr   rr   rs   rÇ   —  s$    





z(DatetimeLikeArrayMixin._get_getitem_freqz,int | Sequence[int] | Sequence[bool] | slicezNaTType | Any | Sequence[Any])rÄ   rš   rv   c                   s.   t ||| ƒ}tƒ  ||¡ |r"d S |  ¡  d S rp   )rb   rÅ   Ú__setitem__Ú_maybe_clear_freq)r   rÄ   rš   Zno_oprÉ   rr   rs   rÏ   µ  s
    z"DatetimeLikeArrayMixin.__setitem__c                 C  s   d S rp   rr   r‘   rr   rr   rs   rÐ   Ë  s    z(DatetimeLikeArrayMixin._maybe_clear_freqT©r”   c           	        sp  t |ƒ}|tkrv| jjdkrDtd| ƒ} | j}t|| jd| jd�}|S | jjdkr^t	| j
dd�S |  | j ¡ ¡ | j¡S t|ƒr¸t|tƒr®| j|jd�}| ¡ }|j||d	d
�S |  ¡ S n´t|tƒrÒtƒ j||d�S |jdv �r| j}|tjk�rtd| j› d|› d�ƒ‚|�r| ¡ }|S |jdv �r2| j|k�s>|jdk�r^dt| ƒj› d|› �}t|ƒ‚ntj| |d�S d S )NÚMrk   Ú	timestamp)ÚtzÚboxÚresoÚmT)rÕ   )r°   F)rz   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ÚshaperE   ry   rJ   r³   Úna_valueZconstruct_array_typeÚ_from_sequencerÅ   Úastyper½   Úint64Ú	TypeErrorr”   ÚtypeÚ__name__Úasarray)	r   rz   r”   Zi8dataZ	convertedZ
arr_objectÚclsr£   ÚmsgrÉ   rr   rs   râ   Ð  sH    
ü


ÿ$
zDatetimeLikeArrayMixin.astypec                 C  s   d S rp   rr   r‘   rr   rr   rs   r{   	  s    zDatetimeLikeArrayMixin.viewzLiteral['M8[ns]']rk   ©rz   rv   c                 C  s   d S rp   rr   ©r   rz   rr   rr   rs   r{     s    zLiteral['m8[ns]']rm   c                 C  s   d S rp   rr   rë   rr   rr   rs   r{     s    .r(   c                 C  s   d S rp   rr   rë   rr   rr   rs   r{     s    c                   s   t ƒ  |¡S rp   )rÅ   r{   rë   rÉ   rr   rs   r{     s    c              
   C  s0  t |tƒr8z|  |¡}W n ttfy6   t|ƒ‚Y n0 t || jƒsL|tu rš|  |¡}z|  	|¡ W n2 t
tfy– } zt|ƒ|‚W Y d }~n
d }~0 0 n’t|ƒs¬t|ƒ‚n€t|ƒt| ƒkrÆtdƒ‚nfz| j|dd�}|  	|¡ W nH t
tf�y* } z*tt|dd ƒƒ�rn
t|ƒ|‚W Y d }~n
d }~0 0 |S )NzLengths must matchT©Úallow_objectrz   )ry   rn   rœ   Ú
ValueErrorr   r:   rŠ   r   r˜   r    rä   rC   r­   Ú_validate_listlikerD   Úgetattr)r   rž   Úerrrr   rr   rs   Ú_validate_comparison_value#  s.    

"

 z1DatetimeLikeArrayMixin._validate_comparison_value)Úallow_listlikeÚunboxc             
   C  sÒ   t || jƒrn²t |tƒrdz|  |¡}W qÀ ty` } z"|  ||¡}t|ƒ|‚W Y d}~qÀd}~0 0 n\t|| jƒrvt	}nJt
|ƒr”|  ||¡}t|ƒ‚n,t || jƒr¬|  |¡}n|  ||¡}t|ƒ‚|sÈ|S |  |¡S )a  
        Validate that the input value can be cast to our scalar_type.

        Parameters
        ----------
        value : object
        allow_listlike: bool, default False
            When raising an exception, whether the message should say
            listlike inputs are allowed.
        unbox : bool, default True
            Whether to unbox the result before returning.  Note: unbox=False
            skips the setitem compatibility check.

        Returns
        -------
        self._scalar_type or NaT
        N)ry   r˜   rn   rœ   rî   Ú_validation_error_messagerä   rN   rz   r   rO   rŠ   r�   )r   rš   ró   rô   rñ   ré   rr   rr   rs   Ú_validate_scalarG  s(    
"
z'DatetimeLikeArrayMixin._validate_scalar)ró   rv   c                 C  sp   t |dƒr(t|ddƒdkr(|j› d�}ndt|ƒj› d�}|rVd| jj› d|› d�}n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ó   Zmsg_gotré   rr   rr   rs   rõ   „  s    ÿÿÿÿz0DatetimeLikeArrayMixin._validation_error_messagerì   c              	   C  s¶  t |t| ƒƒr2| jjdv r.|s.|j| jdd�}|S t |tƒr\t|ƒdkr\t| ƒjg | jd�S t	|dƒrÊ|jt
krÊt |¡| jv rÊzt| ƒ |¡}W n6 ttfyÈ   |r°| Y S |  |d¡}t|ƒ‚Y n0 t|dd�}t|ƒ}t|dd�}t|ƒ�r"zt| ƒj|| jd�}W n t�y    Y n0 t |jtƒ�rT|jj| jk�rT| ¡ }t|dd�}|�rht|jƒ�rhn&t| ƒ |j¡�sŽ|  |d¡}t|ƒ‚| jjdv �r²|�s²|j| jdd�}|S )	NrÙ   F©Úround_okr   r¹   rz   T©Zextract_numpy)ry   rå   rz   rÛ   Úas_unitÚunitr¾   r­   rá   rø   r¿   r   Úinfer_dtyperˆ   rî   rä   rõ   r`   Úpd_arrayrA   rH   Ú
categoriesZ_internal_get_valuesrD   r‰   )r   rš   rí   ré   rr   rr   rs   rï   £  sF    
z)DatetimeLikeArrayMixin._validate_listlikec                 C  s,   t |ƒr|  |¡}n| j|dd�S |  |¡S )NT)ró   )rC   rï   rö   Ú_unboxr›   rr   rr   rs   Ú_validate_setitem_valueÝ  s    z.DatetimeLikeArrayMixin._validate_setitem_valuez6np.int64 | np.datetime64 | np.timedelta64 | np.ndarrayc                 C  s*   t  |¡r|  |¡}n|  |¡ |j}|S )zZ
        Unbox either a scalar with _unbox_scalar or an instance of our own type.
        )r   rÆ   r�   r    rŒ   rŸ   rr   rr   rs   r  å  s
    

zDatetimeLikeArrayMixin._unboxc                 C  s>   ddl m} t| ||d�}||ƒ}t|tƒr4| ¡ S |jS d S )Nr   ri   )Ú	na_action)Úpandasrj   rU   ry   rM   Úto_numpyr^   )r   Zmapperr  rj   rƒ   rr   rr   rs   Úmap÷  s    
zDatetimeLikeArrayMixin.mapznpt.NDArray[np.bool_])r£   rv   c              	   C  sp  |j jdv rtj| jtd�S t|ƒ}t|t| ƒƒ�sg d¢}|j t	kr´t
j|d| j d�}|j t	krl|  |¡S t
j|dd�}||vr´|dkrŒn(d	|v r¤t|  t	¡|ƒS tj| jtd�S zt| ƒ |¡}W n" tyè   t|  t	¡|ƒ Y S 0 tjd
| j › d�ttƒ d� | j jdv �r*td| ƒ} | | j¡}z|  |¡ W n( ttf�y`   tj| jtd� Y S 0 t| j|jƒS )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]
        Zfiucr¹   )r   Útimedelta64r   Ú
datetime64ÚdateZperiodT)Zconvert_non_numericZ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)rz   rÛ   r½   Úzerosrß   r�   r_   ry   rå   r¿   r   Zmaybe_convert_objectsrT   rþ   râ   rá   rî   rº   r»   r¼   r?   r   rü   rý   r    rä   r®   )r   r£   Z	inferableÚinferredrr   rr   rs   rT     sJ    
ý

ø
zDatetimeLikeArrayMixin.isinc                 C  s   | j S rp   )Ú_isnanr‘   rr   rr   rs   rO   X  s    zDatetimeLikeArrayMixin.isnac                 C  s
   | j tkS )z-
        return if each value is nan
        )r®   r   r‘   rr   rr   rs   r  [  s    zDatetimeLikeArrayMixin._isnanc                 C  s   t | j ¡ ƒS )zJ
        return if I have any nans; enables various perf speedups
        )r�   r  Úanyr‘   rr   rr   rs   Ú_hasnab  s    zDatetimeLikeArrayMixin._hasna)rƒ   rv   c                 C  s6   | j r2|r| |¡}|du r"tj}t || j|¡ |S )az  
        Parameters
        ----------
        result : np.ndarray
        fill_value : object, default iNaT
        convert : str, dtype or None

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

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

        This is an internal routine.
        N)r  râ   r½   ÚnanÚputmaskr  )r   rƒ   Ú
fill_valuer¢   rr   rr   rs   Ú_maybe_mask_resultsi  s    
z*DatetimeLikeArrayMixin._maybe_mask_resultsz
str | Nonec                 C  s   | j du rdS | 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‘   rr   rr   rs   r  ‡  s    
zDatetimeLikeArrayMixin.freqstrc                 C  s4   | j dkrdS zt | ¡W S  ty.   Y dS 0 dS )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   Z
infer_freqrî   r‘   rr   rr   rs   Úinferred_freq¥  s    
z$DatetimeLikeArrayMixin.inferred_freqzResolution | Nonec                 C  s8   | j }|d u rd S zt |¡W S  ty2   Y d S 0 d S rp   )r  r   Zget_reso_from_freqstrÚKeyError)r   r  rr   rr   rs   Ú_resolution_objÄ  s    z&DatetimeLikeArrayMixin._resolution_objc                 C  s   | j jS )zO
        Returns day, hour, minute, second, millisecond or microsecond
        )r  Úattrnamer‘   rr   rr   rs   Ú
resolutionÎ  s    z!DatetimeLikeArrayMixin.resolutionc                 C  s   t j| jdd�d S )NT©Ztimeliker   ©r   Zis_monotonicr®   r‘   rr   rr   rs   Ú_is_monotonic_increasingÙ  s    z/DatetimeLikeArrayMixin._is_monotonic_increasingc                 C  s   t j| jdd�d S )NTr  r¥   r  r‘   rr   rr   rs   Ú_is_monotonic_decreasingÝ  s    z/DatetimeLikeArrayMixin._is_monotonic_decreasingc                 C  s   t t| j d¡ƒƒ| jkS )NÚK)r­   rV   r®   rÝ   Úsizer‘   rr   rr   rs   Ú
_is_uniqueá  s    z!DatetimeLikeArrayMixin._is_uniquec           
      C  s¸  | j dkr6t|dd ƒ| jkr6||  ¡ | ¡ ƒ | j¡S z|  |¡}W n tyb   t| ||ƒ Y S 0 t|dd ƒ}t|ƒr–t	 
|t |  t¡¡|¡}|S |tu rÎ|tju rºtj| jtd�}ntj| jtd�}|S t| jtƒ�s^tt| ƒ} | j|jk�r^t|t| ƒƒ�sJz|j| jdd�}W n. t�yF   t |j ¡}t!| j"||ƒ Y S 0 n|j"}t!| j"||ƒS |  #|¡}|| j" $d¡| $d¡ƒ}t%|ƒ}| j&|B }| '¡ �r´|tju }	t (|||	¡ |S )Nr¥   rß   rz   r¹   Frù   rx   ))r«   rð   rß   rÝ   rÞ   rò   r:   rd   rD   rS   Zcomp_method_OBJECT_ARRAYr½   rç   râ   r¿   r   ÚoperatorÚneZonesr�   r  ry   rz   rK   r   ÚTimelikeOpsrÜ   rå   rü   rý   rî   r^   Zasm8r%   rŒ   r  r{   rO   r  r  r  )
r   rž   rq   rz   rƒ   Z	other_arrZ
other_valsÚo_maskÚmaskZ
nat_resultrr   rr   rs   Ú_cmp_methodè  sL    ÿ

ÿ



z"DatetimeLikeArrayMixin._cmp_methodÚ__pow__Ú__rpow__Ú__mul__Ú__rmul__Ú__truediv__Ú__rtruediv__Ú__floordiv__Ú__rfloordiv__Ú__mod__Ú__rmod__Ú
__divmod__Ú__rdivmod__z@tuple[int | npt.NDArray[np.int64], None | npt.NDArray[np.bool_]]c                 C  sD   t |tƒr|j}d}n&t |ttfƒr0|j}d}n|j}|j}||fS )zN
        Get the int64 values and b_mask to pass to add_overflowsafe.
        N)ry   r   Úordinalr   r   r}   r  r®   )r   rž   Zi8valuesr)  rr   rr   rs   Ú_get_i8_values_and_mask.  s    
z.DatetimeLikeArrayMixin._get_i8_values_and_maskc                 C  s6   t | jtƒr| jS t |¡s dS t | jtƒr2| jS dS )zP
        Check if we can preserve self.freq in addition or subtraction.
        N)ry   rz   rK   rŽ   r   rÆ   r   rŸ   rr   rr   rs   Ú_get_arithmetic_result_freqA  s    
z2DatetimeLikeArrayMixin._get_arithmetic_result_freqc           
      C  s(  t  | jd¡s.tdt| ƒj› dt|ƒj› �ƒ‚td| ƒ} ddlm} ddl	m
} |tus\J ‚t|ƒr’| jt ¡  d| j› d	�¡ }|j||jd
�S t|ƒ}|  |¡\} }td| ƒ} |  |¡\}}t| jtj|dd
�ƒ}| d| j› d	�¡}||j| jd�}| d| j› d	�¡}|  |¡}	|j|||	d�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   Zpandas.core.arrays.datetimesr=  r   rO   rŒ   Zto_datetime64râ   rý   Ú_simple_newr   Ú_ensure_matching_resosr8  r   r®   r½   rç   r{   rÔ   r9  )
r   rž   rk   r=  rƒ   Úother_i8r(  Ú
res_valuesrz   Únew_freqrr   rr   rs   Ú_add_datetimelike_scalarQ  s*    ÿ


z/DatetimeLikeArrayMixin._add_datetimelike_scalarc                 C  s6   t  | jd¡s.tdt| ƒj› dt|ƒj› �ƒ‚||  S )Nr×   r:  r;  )r   rA  rz   rä   rå   ræ   rŸ   rr   rr   rs   Ú_add_datetime_arraylikes  s
    ÿz.DatetimeLikeArrayMixin._add_datetime_arraylikezdatetime | np.datetime64c                 C  sZ   | j jdkr tdt| ƒj› �ƒ‚td| ƒ} t|ƒr:| t S t|ƒ}|  	|¡\} }|  
|¡S )NrÒ   ú"cannot subtract a datelike from a rk   )rz   rÛ   rä   rå   ræ   r   rO   r   r   rD  Ú_sub_datetimelike)r   rž   Útsrr   rr   rs   Ú_sub_datetimelike_scalar}  s    
z/DatetimeLikeArrayMixin._sub_datetimelike_scalarc                 C  sZ   | j jdkr tdt| ƒj› �ƒ‚t| ƒt|ƒkr8tdƒ‚td| ƒ} |  |¡\} }|  	|¡S )NrÒ   rJ  ú$cannot add indices of unequal lengthrk   )
rz   rÛ   rä   rå   ræ   r­   rî   r   rD  rK  rŸ   rr   rr   rs   Ú_sub_datetime_arraylike�  s    
z.DatetimeLikeArrayMixin._sub_datetime_arraylikezTimestamp | DatetimeArrayc           
   
   C  sÈ   t d| ƒ} ddlm} z|  |¡ W nB tyf } z*t|ƒ dd¡}t|ƒ|ƒ|‚W Y d }~n
d }~0 0 |  |¡\}}t	| j
tj| dd�ƒ}| d| j› d	�¡}|  |¡}	t d
|	ƒ}	|j||j|	d�S )Nrk   r   ©rm   ÚcompareÚsubtractrx   r¹   útimedelta64[r>  zTick | Noner@  )r   rB  rm   Z_assert_tzawareness_compaträ   rn   Úreplacerå   r8  r   r®   r½   rç   r{   rý   r9  rC  rz   )
r   rž   rm   rñ   Znew_messagerE  r(  rF  Zres_m8rG  rr   rr   rs   rK  �  s    
$

z(DatetimeLikeArrayMixin._sub_datetimeliker   rl   c                 C  s\   t  | jd¡s"tdt| ƒj› �ƒ‚ddlm} t 	|j
| j¡}t|jƒ}|||d�}||  S )Nr×   zcannot add Period to a r   )rl   r¹   )r   rA  rz   rä   rå   ræ   Zpandas.core.arrays.periodrl   r½   Zbroadcast_tor7  rß   rK   rŽ   )r   rž   rl   Zi8valsrz   Zparrrr   rr   rs   Ú_add_period±  s    
z"DatetimeLikeArrayMixin._add_periodc                 C  s   t | ƒ‚d S rp   r•   )r   Úoffsetrr   rr   rs   Ú_add_offset¾  s    z"DatetimeLikeArrayMixin._add_offsetc                 C  sj   t |ƒr@tj| jdd� | jj¡}| t¡ t	| ƒj
|| jd�S td| ƒ} t|ƒ}|  |¡\} }|  |¡S )zk
        Add a delta of a timedeltalike

        Returns
        -------
        Same type as self
        rx   r¹   r  )rO   r½   Úemptyrß   r{   rŒ   rz   Úfillr   rå   rC  r   r   rD  Ú_add_timedeltalike)r   rž   Ú
new_valuesrr   rr   rs   Ú_add_timedeltalike_scalarÁ  s    

z0DatetimeLikeArrayMixin._add_timedeltalike_scalar)rž   c                 C  s:   t | ƒt |ƒkrtdƒ‚td| ƒ} |  |¡\} }|  |¡S )zl
        Add a delta of a TimedeltaIndex

        Returns
        -------
        Same type as self
        rN  r  )r­   rî   r   rD  rZ  rŸ   rr   rr   rs   Ú_add_timedelta_arraylikeÕ  s
    

z/DatetimeLikeArrayMixin._add_timedelta_arraylikezTimedelta | TimedeltaArrayc                 C  s\   t d| ƒ} |  |¡\}}t| jtj|dd�ƒ}| | jj¡}|  	|¡}t
| ƒj|| j|d�S )Nr  rx   r¹   r@  )r   r8  r   r®   r½   rç   r{   rŒ   rz   r9  rå   rC  )r   rž   rE  r(  r[  rF  rG  rr   rr   rs   rZ  ç  s    

ÿz)DatetimeLikeArrayMixin._add_timedeltalikec                 C  sv   t | jtƒr,tdt| ƒj› dttƒj› �ƒ‚td| ƒ} tj	| j
tjd�}| t¡ | | jj¡}t| ƒj|| jd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½   rX  rß   rã   rY  r   r{   rŒ   rC  ©r   rƒ   rr   rr   rs   Ú_add_natø  s    ÿ

ÿzDatetimeLikeArrayMixin._add_natc                 C  sT   t j| jt jd�}| t¡ | jjdv rFtd| ƒ} | 	d| j
› d�¡S | 	d¡S dS )z+
        Subtract pd.NaT from self
        r¹   rÙ   zDatetimeArray| TimedeltaArrayrS  r>  ztimedelta64[ns]N)r½   rX  rß   rã   rY  r   rz   rÛ   r   r{   rý   r^  rr   rr   rs   Ú_sub_nat  s    

zDatetimeLikeArrayMixin._sub_natzPeriod | PeriodArrayc                   s¤   t ˆ jtƒs,tdt|ƒj› dtˆ ƒj› �ƒ‚tdˆ ƒ‰ ˆ  |¡ ˆ  |¡\}}t	ˆ j
tj| dd�ƒ}t ‡ fdd„|D ƒ¡}|d u rŽˆ j}n
ˆ j|B }t||< |S )Núcannot subtract ú from rl   rx   r¹   c                   s   g | ]}ˆ j j| ‘qS rr   )rŽ   Úbase©r¦   r¡   r‘   rr   rs   Ú
<listcomp>1  r©   z:DatetimeLikeArrayMixin._sub_periodlike.<locals>.<listcomp>)ry   rz   rK   rä   rå   ræ   r   r    r8  r   r®   r½   rç   r^   r  r   )r   rž   rE  r(  Znew_i8_dataZnew_datar)  rr   r‘   rs   Ú_sub_periodlike#  s    ÿ


z&DatetimeLikeArrayMixin._sub_periodlikec                 C  sŽ   |t jt jfv sJ ‚t|ƒdkr8| jdkr8|| |d ƒS tjdt| ƒj› d�t	t
ƒ d� | j|jkstJ | j|jfƒ‚||  d¡t |¡ƒ}|S )aZ  
        Add or subtract array-like of DateOffset objects

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

        Returns
        -------
        np.ndarray[object]
            Except in fastpath case with length 1 where we operate on the
            contained scalar.
        r¥   r   z)Adding/subtracting object-dtype array to z not vectorized.r·   ÚO)r%  ÚaddÚsubr­   r«   rº   r»   rå   ræ   r;   r?   rß   râ   r½   rç   )r   rž   rq   rF  rr   rr   rs   Ú_addsub_object_array<  s    ÿüz+DatetimeLikeArrayMixin._addsub_object_arrayr
  )Únamer  rv   c                K  sV   |dvr t d|› dt| ƒ› �ƒ‚tt|ƒ}||  ¡ fd|i|¤Ž}t| ƒj|| jd�S )N>   ZcumminZcummaxzAccumulation z not supported for r  r¹   )rä   rå   rð   rW   r”   rC  rz   )r   rk  r  r�   rq   rƒ   rr   rr   rs   Ú_accumulate`  s
    
z"DatetimeLikeArrayMixin._accumulateÚ__add__c                 C  s¶  t |dd ƒ}t|ƒ}|tu r(|  ¡ }�nVt|tttjfƒrH|  	|¡}�n6t|t
ƒr`|  |¡}�nt|ttjfƒr~|  |¡}�n t|tƒr¢t | jd¡r¢|  |¡}nÜt |¡rât| jtƒsÀt| ƒ‚td| ƒ}| ||jj tj¡}nœt |d¡rú|  |¡}n„t|ƒ�r|  |tj¡}njt |d¡�s.t|tƒ�r8|   |¡S t!|ƒ�rzt| jtƒ�sXt| ƒ‚td| ƒ}| ||jj tj¡}nt"S t|tj#ƒ�r²t |jd¡�r²ddl$m%} | &|¡S |S )Nrz   r×   rl   rÒ   r   rP  )'rð   r_   r   r_  ry   r   r   r½   r  r\  r   rW  r   r  rH  r   r   rA  rz   rU  Ú
is_integerrK   r'   r   Ú_addsub_int_array_or_scalarÚ_nr%  rh  r]  rD   rj  rI   rI  rB   ÚNotImplementedÚndarrayrB  rm   rá   ©r   rž   Úother_dtyperƒ   Úobjrm   rr   rr   rs   rm  i  sF    



ÿ



zDatetimeLikeArrayMixin.__add__c                 C  s
   |   |¡S rp   )rm  rŸ   rr   rr   rs   Ú__radd__¡  s    zDatetimeLikeArrayMixin.__radd__Ú__sub__c                 C  sÈ  t |dd ƒ}t|ƒ}|tu r(|  ¡ }�nht|tttjfƒrJ|  	| ¡}�nFt|t
ƒrd|  | ¡}�n,t|ttjfƒr‚|  |¡}�nt |¡rÂt| jtƒs t| ƒ‚td| ƒ}| ||jj tj¡}nÎt|tƒrØ|  |¡}n¸t |d¡rò|  | ¡}nžt|ƒ�r|  |tj¡}n„t |d¡�s&t|tƒ�r2|   |¡}n^t|tƒ�rJ|  |¡}nFt!|ƒ�rŒt| jtƒ�sjt| ƒ‚td| ƒ}| ||jj tj¡}nt"S t|tj#ƒ�rÄt |jd¡�rÄddl$m%} | &|¡S |S )Nrz   rl   r×   rÒ   r   rP  )'rð   r_   r   r`  ry   r   r   r½   r  r\  r   rW  r   r  rM  r   rn  rz   rK   r'   r   ro  rp  r%  ri  r   rf  rA  r]  rD   rj  rI   rO  rB   rq  rr  rB  rm   rá   rs  rr   rr   rs   rw  ¥  sJ    




ÿ


zDatetimeLikeArrayMixin.__sub__c                 C  s  t |dd ƒ}t |d¡p t|tƒ}|rrt | jd¡rrt |¡rJt|ƒ|  S t|tƒsjddl	m
} | |¡}||  S | jjdkr®t|dƒr®|s®tdt| ƒj› dt|ƒj› �ƒ‚nZt| jtƒrät |d¡rätdt| ƒj› d|j› �ƒ‚n$t | jd¡�rtd| ƒ} |  | S | |  S )	Nrz   rÒ   r×   r   r<  ra  rb  rm   )rð   r   rA  ry   rI   rz   rÆ   r   r‡   rB  rk   rá   rÛ   rø   rä   rå   ræ   rK   r   )r   rž   rt  Zother_is_dt64rk   rr   rr   rs   Ú__rsub__Ý  s*    ÿ


ÿ

zDatetimeLikeArrayMixin.__rsub__c                 C  s4   | | }|d d … | d d …< t | jtƒs0|j| _| S rp   ©ry   rz   rK   rŽ   rÈ   ©r   rž   rƒ   rr   rr   rs   Ú__iadd__ÿ  s
    zDatetimeLikeArrayMixin.__iadd__c                 C  s4   | | }|d d … | d d …< t | jtƒs0|j| _| S rp   ry  rz  rr   rr   rs   Ú__isub__  s
    zDatetimeLikeArrayMixin.__isub__znpt.NDArray[np.float64])ÚqsÚinterpolationrv   c                   s   t ƒ j||d�S )N)r}  r~  )rÅ   Ú	_quantile)r   r}  r~  rÉ   rr   rs   r    s    z DatetimeLikeArrayMixin._quantile©Úaxisr  úAxisInt | Nonec                K  s8   t  d|¡ t  || j¡ tj| j||d�}|  ||¡S )a  
        Return the minimum value of the Array or minimum along
        an axis.

        See Also
        --------
        numpy.ndarray.min
        Index.min : Return the minimum value in an Index.
        Series.min : Return the minimum value in a Series.
        rr   r€  )ÚnvZvalidate_minÚvalidate_minmax_axisr«   rR   ZnanminrŒ   Ú_wrap_reduction_result©r   r�  r  r�   rƒ   rr   rr   rs   Úmin  s    zDatetimeLikeArrayMixin.minc                K  s8   t  d|¡ t  || j¡ tj| j||d�}|  ||¡S )a  
        Return the maximum value of the Array or maximum along
        an axis.

        See Also
        --------
        numpy.ndarray.max
        Index.max : Return the maximum value in an Index.
        Series.max : Return the maximum value in a Series.
        rr   r€  )rƒ  Zvalidate_maxr„  r«   rR   ZnanmaxrŒ   r…  r†  rr   rr   rs   Úmax.  s    zDatetimeLikeArrayMixin.maxr   )r  r�  c                C  sF   t | jtƒr"tdt| ƒj› d�ƒ‚tj| j|||  	¡ d�}|  
||¡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  r)  )ry   rz   rK   rä   rå   ræ   rR   ZnanmeanrŒ   rO   r…  )r   r  r�  rƒ   rr   rr   rs   Úmean@  s    ,ÿÿzDatetimeLikeArrayMixin.meanc                K  sH   t  d|¡ |d ur*t|ƒ| jkr*tdƒ‚tj| j||d�}|  ||¡S )Nrr   z abs(axis) must be less than ndimr€  )	rƒ  Zvalidate_medianÚabsr«   rî   rR   Z	nanmedianrŒ   r…  r†  rr   rr   rs   Úmediany  s
    zDatetimeLikeArrayMixin.median)Údropnac                 C  sH   d }|r|   ¡ }tj|  d¡|d�}| | jj¡}ttj|ƒ}|  	|¡S )Nrx   )r)  )
rO   rP   Úmoder{   rŒ   rz   r   r½   rr  r~   )r   r�  r)  Zi8modesZnpmodesrr   rr   rs   Ú_modeƒ  s    zDatetimeLikeArrayMixin._modeÚintznpt.NDArray[np.intp])ÚhowÚhas_dropped_naÚ	min_countÚngroupsÚidsc                K  sš  | j }|jdkrR|dv r(td|› d�ƒ‚|dv r¶tjd|› d|› d�ttƒ d	� ndt|tƒrž|dv rttd
|› d�ƒ‚|dv r¶tjd|› d|› d�ttƒ d	� n|dv r¶td|› d�ƒ‚| j	 
d¡}ddlm}	 |	 |¡}
|	||
|d�}|j|f|||d dœ|¤Ž}|j|jv �r|S |j dk�s$J ‚|dv �r‚ddlm} t| j tƒ�rPtdƒ‚td| ƒ} d| j› d�}| 
|¡}|j||j d�S | 
| j	j ¡}|  |¡S )NrÒ   )ÚsumÚprodZcumsumÚcumprodÚvarÚskewz!datetime64 type does not support z operations)r  Ú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 rw   r   )ÚWrappedCythonOp)r‘  rÛ   r’  )r“  r”  Zcomp_idsr)  )ZstdZsemrP  z-'std' and 'sem' are not valid for PeriodDtyper  zm8[r>  r¹   )rz   rÛ   rä   rº   r»   r¼   r?   ry   rK   rŒ   r{   Zpandas.core.groupby.opsrœ  Zget_kind_from_howZ_cython_op_ndim_compatr‘  Zcast_blocklistrB  rm   r   rý   rC  r~   )r   r‘  r’  r“  r”  r•  r�   rz   Znpvaluesrœ  rÛ   rq   rF  rm   Ú	new_dtyperr   rr   rs   Ú_groupby_op�  sh    

ÿü
ÿü
ÿûú	


z"DatetimeLikeArrayMixin._groupby_op)NNF)F)NN)T).)N)F)F)N)T)`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   r  r  r   r  r  r  r  r  r   r!  r$  r*  rt   r+  r,  r-  r.  r/  r0  r1  r2  r3  r4  r5  r6  r8  r9  rH  rI  rM  rO  rK  rU  rW  r\  r]  rZ  r_  r`  rf  rj  rl  rc   rm  rv  rw  rx  r{  r|  r†   r  r‡  rˆ  rŠ  rŒ  r�  rž  Ú__classcell__rr   rr   rÉ   rs   r‡   Æ   s  
 ÿ
ÿ ÿ9	(û=:Uÿ	
9!	

#	
7
7"	9	r‡   c                   @  s*   e Zd ZdZedd�dddœdd„ƒZd	S )
ÚDatelikeOpszK
    Common ops for DatetimeIndex/PeriodIndex, but not TimedeltaIndex.
    zNhttps://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior)ÚURLrn   r²   )r±   rv   c                 C  sD   | j |tjd�}tƒ r6ddlm} t||tjd�d�S |jtd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½   r  r   r  r§  rÿ   râ   r¿   )r   r±   rƒ   r§  rr   rr   rs   Ústrftimeå  s
    1zDatelikeOps.strftimeN)ræ   rŸ  r   r¡  r=   r©  rr   rr   rr   rs   r¥  à  s
   ÿ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                      sF  e Zd ZU dZded< dejdfdddœd	d
„Zedd„ ƒZ	e
dd„ ƒZejddœdd„ƒZeddœdd„ƒZeeddœdd„ƒƒZedddœdd„ƒZeddœdd „ƒZed!dœd"d#„ƒZd`d!ddd%œd&d'„Zd(d)„ Zd*d!d+œ‡ fd,d-„Zd.d/„ Zeee jd0d1�ƒdad3d4dd5œd6d7„ƒZeee jd8d1�ƒdbd3d4dd5œd9d:„ƒZeee jd;d1�ƒdcd3d4dd5œd<d=„ƒZ dd$d>œd?ddd@œdAdB„Z!dd$d>œd?ddd@œdCdD„Z"ddœdEdF„Z#ddœdGdH„Z$dIdœ‡ fdJdK„Z%dddddLœ‡ fdMdN„Z&ededPdQddRœ‡ fdSdT„ƒZ'dfd!ddVœ‡ fdWdX„Z(dYddZddd[œd\d]„Z)e
ddœd^d_„ƒZ*‡  Z+S )gr'  zK
    Common ops for TimedeltaIndex/DatetimeIndex, but not PeriodIndex.
    znp.dtypeÚ_default_dtypeNFr�   r“   )r”   rv   c           	      C  s¨  t jt| ƒj› d�ttƒ d� |d ur.t|ƒ}t|dd�}t|t	ƒrR|j
dtd�}t|dd ƒ}|d u }|tjurt|nd }t|t| ƒƒrð|rŒn.|d u rœ|j}n|rº|jrºt|ƒ}t||jƒ}|d urâ||jkrâtd|› d	|j› �ƒ‚|j}|j}nX|d u �rHt|tjƒ�r|jjd
v �r|j}n*| j}t|tjƒ�rH|jdk�rH| |¡}t|tjƒ�sxtdt|ƒj› dt| ƒj› d�ƒ‚|jdv�rŒtdƒ‚|jdk�r |d u �r¶| j}| | j¡}nJt |d¡�rÐ| |¡}n0t|tƒ�r | jj}|› d|j› d�}| |¡}|  ||¡}|dk�r,tdt| ƒj› d�ƒ‚|�r:|  ¡ }|�rjt|ƒ}|jjdk�rjt|t!ƒ�sjtdƒ‚t"j#| ||d� || _$|d u �r¤|d u�r¤t| ƒ %| |¡ d S )NzV.__init__ is deprecated and will be removed in a future version. Use pd.array instead.r·   Trû   rã   r¨  rÈ   údtype=z does not match data dtype Z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½   rr  rÛ   rª  r{   rî   r«   rA  rI   rý   Ú_validate_dtyper”   r   r   r—   rÈ   Ú_validate_frequency)	r   r£   rz   rŽ   r”   r  Zexplicit_nonerÛ   r�  rr   rr   rs   r—   ¶  s„    û

ÿ

ÿÿ


ÿzTimelikeOps.__init__c                 C  s   t | ƒ‚d S rp   r•   )rè   r£   rz   rr   rr   rs   r²    s    zTimelikeOps._validate_dtypec                 C  s   | j S )zK
        Return the frequency object if it is set, otherwise None.
        ©rÈ   r‘   rr   rr   rs   rŽ     s    zTimelikeOps.freqr�   c                 C  sV   |d urLt |ƒ}|  | |¡ | jjdkr:t|tƒs:tdƒ‚| jdkrLtdƒ‚|| _	d S )Nr×   r¯  r¥   zCannot set freq with ndim > 1)
r"   r³  rz   rÛ   ry   r   rä   r«   rî   rÈ   r›   rr   rr   rs   rŽ     s    
Údict)Úvalidate_kwdsc                 C  s†   |du rd| _ nr|dkr0| j du r‚t| jƒ| _ nR|tju r<nF| j du rnt|ƒ}t| ƒj| |fi |¤Ž || _ nt|ƒ}t|| j ƒ dS )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.
        Nr®  )rÈ   r"   r  r   r°  rå   r³  r±  )r   rŽ   r¶  rr   rr   rs   Ú_maybe_pin_freq*  s    


zTimelikeOps._maybe_pin_freqr   ©rŽ   c              
   K  s®   |j }|jdks||jkrdS z>| jf |d dt|ƒ||jdœ|¤Ž}t |j|j¡sZt	‚W nL t	y¨ } z4dt
|ƒv r||‚t	d|› d|j› �ƒ|‚W Y d}~n
d}~0 0 dS )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  r#  r  Ú_generate_ranger­   rý   r½   Zarray_equalr®   rî   rn   )rè   ÚindexrŽ   r�   r  Zon_freqrñ   rr   rr   rs   r³  K  s2    ûúÿÿýzTimelikeOps._validate_frequencyú
int | Noner3   ©r»  rv   c                 O  s   t | ƒ‚d S rp   r•   )rè   r¹  rº  r»  rŽ   r€   r�   rr   rr   rs   r¾  w  s    zTimelikeOps._generate_ranger�  c                 C  s   t | jjƒS rp   )r   rŒ   rz   r‘   rr   rr   rs   rÜ     s    zTimelikeOps._cresorn   c                 C  s
   t | jƒS rp   )Údtype_to_unitrz   r‘   rr   rr   rs   rý   ƒ  s    zTimelikeOps.unitT)rý   rú   rv   c                 C  s~   |dvrt dƒ‚t | jj› d|› d�¡}t| j||d�}t| jtjƒrP|j}ntd| ƒj}t	||d�}t
| ƒj||| jd�S )	N)ÚsÚmsÚusÚnsz)Supported units are 's', 'ms', 'us', 'ns'r­  r>  rù   rk   r?  r@  )rî   r½   rz   rÛ   r   rŒ   ry   r   rÔ   rI   rå   rC  rŽ   )r   rý   rú   rz   r[  r�  rÔ   rr   rr   rs   rü   Š  s    ÿzTimelikeOps.as_unitc                 C  s:   | j |j kr2| j |j k r&|  |j¡} n| | j¡}| |fS rp   )rÜ   rü   rý   rŸ   rr   rr   rs   rD  Ÿ  s
    z"TimelikeOps._ensure_matching_resosznp.ufunc)ÚufuncÚmethodc                   s`   |t jt jt jfv rDt|ƒdkrD|d | u rDt||ƒ| jfi |¤ŽS tƒ j||g|¢R i |¤ŽS )Nr¥   r   )	r½   ÚisnanÚisinfÚisfiniter­   rð   rŒ   rÅ   Ú__array_ufunc__)r   rÇ  rÈ  Úinputsr�   rÉ   rr   rs   rÌ  ª  s    ÿ
þ
ýzTimelikeOps.__array_ufunc__c           
      C  s¬   t | jtƒrBtd| ƒ} |  d ¡}| ||||¡}|j| j||d�S |  d¡}ttj	|ƒ}t
|| jƒ}|dkrt|  ¡ S t|||ƒ}	| j|	td�}| | jj¡}| j|| jd�S )Nrk   )Ú	ambiguousÚnonexistentrx   r   ©r  r¹   )ry   rz   rI   r   Ztz_localizeÚ_roundrÔ   r{   r½   rr  r&   rÜ   r”   r$   r  r   rŒ   rC  )
r   rŽ   rŽ  rÎ  rÏ  Znaiverƒ   r£   ZnanosZ	result_i8rr   rr   rs   rÑ  µ  s     

ÿ
zTimelikeOps._roundÚround)rq   Úraiser5   r6   )rÎ  rÏ  rv   c                 C  s   |   |tj||¡S rp   )rÑ  r#   ZNEAREST_HALF_EVEN©r   rŽ   rÎ  rÏ  rr   rr   rs   rÒ  Ë  s    zTimelikeOps.roundÚfloorc                 C  s   |   |tj||¡S rp   )rÑ  r#   ZMINUS_INFTYrÔ  rr   rr   rs   rÕ  Ô  s    zTimelikeOps.floorÚceilc                 C  s   |   |tj||¡S rp   )rÑ  r#   Z
PLUS_INFTYrÔ  rr   rr   rs   rÖ  Ý  s    zTimelikeOps.ceilr€  r‚  )r�  r  rv   c                C  s   t j| j|||  ¡ d�S ©Nr‰  )rR   ZnananyrŒ   rO   ©r   r�  r  rr   rr   rs   r  é  s    zTimelikeOps.anyc                C  s   t j| j|||  ¡ d�S r×  )rR   ZnanallrŒ   rO   rØ  rr   rr   rs   r›  í  s    zTimelikeOps.allc                 C  s
   d | _ d S rp   r´  r‘   rr   rr   rs   rÐ   õ  s    zTimelikeOps._maybe_clear_freqc                 C  sh   |du r
nLt | ƒdkr@t|tƒr@| jjdkrVt|tƒsVtdƒ‚n|dksLJ ‚t| jƒ}|  	¡ }||_
|S )z×
        Helper to get a view on the same data, with a new freq.

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

        Returns
        -------
        Same type as self
        Nr   r×   r¯  r®  )r­   ry   r   rz   rÛ   r   rä   r"   r  r{   rÈ   )r   rŽ   r‚   rr   rr   rs   Ú
_with_freqø  s    

zTimelikeOps._with_freqr‹   c                   s   t | jtjƒr| jS tƒ  ¡ S rp   )ry   rz   r½   rŒ   rÅ   Ú_values_for_jsonr‘   rÉ   rr   rs   rÚ  	  s    zTimelikeOps._values_for_json)Úuse_na_sentinelÚsortc                   s‚   | j d urZtjt| ƒtjd�}|  ¡ }|rR| j jdk rR|d d d… }|d d d… }||fS |rttdt| ƒj	› d�ƒ‚t
ƒ j|d�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.)rÛ  )rŽ   r½   Zaranger­   Zintpr”   r§   ÚNotImplementedErrorrå   ræ   rÅ   Ú	factorize)r   rÛ  rÜ  ÚcodesZuniquesrÉ   rr   rs   rß  	  s    
ÿzTimelikeOps.factorizer   zSequence[Self]r)   )Ú	to_concatr�  rv   c                   sŒ   t ƒ  ||¡}|d ‰ |dkrˆdd„ |D ƒ}ˆ jd urˆt‡ fdd„|D ƒƒrˆt|d d… |dd … ƒ}t‡ fdd„|D ƒƒrˆˆ j}||_|S )	Nr   c                 S  s   g | ]}t |ƒr|‘qS rr   )r­   rd  rr   rr   rs   re  C	  r©   z1TimelikeOps._concat_same_type.<locals>.<listcomp>c                 3  s   | ]}|j ˆ j kV  qd S rp   r¸  rd  ©ru  rr   rs   r¨   E	  r©   z0TimelikeOps._concat_same_type.<locals>.<genexpr>rÝ  r¥   c                 3  s,   | ]$}|d  d ˆ j  |d d  kV  qdS )r   rÝ  r¥   Nr¸  )r¦   Úpairrâ  rr   rs   r¨   G	  r©   )rÅ   Ú_concat_same_typerŽ   r›  ÚziprÈ   )rè   rá  r�  Únew_objÚpairsrG  rÉ   râ  rs   rä  6	  s     zTimelikeOps._concat_same_typeÚC)Úorderrv   c                   s   t ƒ j|d�}| j|_|S )N)ré  )rÅ   r”   rŽ   rÈ   )r   ré  ræ  rÉ   rr   rs   r”   L	  s    zTimelikeOps.copyr.   rj   )rÈ  r�  r¿  r”   rv   c          
   	   K  s^   |dkrt ‚|s| j}	n
| j ¡ }	tj|	f||||||dœ|¤Ž |sJ| S t| ƒj|	| jd�S )z2
        See NDFrame.interpolate.__doc__.
        Zlinear)rÈ  r�  r¿  ÚlimitÚlimit_directionÚ
limit_arear¹   )rÞ  rŒ   r”   rQ   Zinterpolate_2d_inplacerå   rC  rz   )
r   rÈ  r�  r¿  rê  rë  rì  r”   r�   Zout_datarr   rr   rs   ÚinterpolateQ	  s(    
ÿùø
zTimelikeOps.interpolatec                 C  sP   t  | j¡sdS | j}|tk}t| jƒ}t|ƒ}t ||| dk¡ 	¡ 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   rA  rz   r®   r   r   r!   r½   Úlogical_andr–  )r   Z
values_intZconsider_valuesrÖ   ZppdZ	even_daysrr   rr   rs   Ú_is_dates_onlyz	  s    
zTimelikeOps._is_dates_only)T)rÓ  rÓ  )rÓ  rÓ  )rÓ  rÓ  )TF)r   )rè  ),ræ   rŸ  r   r¡  r¢  r   r°  r—   Úclassmethodr²  r£  rŽ   Úsetterr   r·  r³  r¾  r>   rÜ   rý   rü   rD  rÌ  rÑ  r<   Ú
_round_docÚ_round_examplerµ   rÒ  Ú_floor_examplerÕ  Ú_ceil_examplerÖ  r  r›  rÐ   rÙ  rÚ  rß  rä  r”   rí  rï  r¤  rr   rr   rÉ   rs   r'  ¯  sh   
ÿ\

 *  ü  ü  ü   ý ý)r'  r�   ztuple[ArrayLike, bool])r”   Úcls_namerv   c                 C  sþ   t | dƒs<t| ttfƒs.t | ¡dkr.t| ƒ} t| ƒ} d}n(t| tƒrXtd|› d�ƒ‚nt	| dd�} t| t
ƒs„t| tƒr˜| jjdv r˜| jd	td
�} d}n^t| tƒr¸|  ¡ } |  ¡ } d}n>t| tjtfƒsÔt | ¡} n"t| tƒrö| jj| jtd�j} d}| |fS )Nrz   r   FzCannot create a z from a MultiIndex.Trû   rØ   rã   r¨  rÐ  )rø   ry   r¾   Útupler½   r«   r@   rM   rä   r`   r]   r[   rz   rÛ   r  r   Z_maybe_convert_datelike_arrayrr  r\   rç   rL   r   Ztakerà  r   Z_values)r–   r”   rö  rr   rr   rs   Ú!ensure_arraylike_for_datetimelike”	  s2    


ÿ
ÿ

rø  r“   rÁ  c                 C  s   d S rp   rr   ©r»  rr   rr   rs   Úvalidate_periods»	  s    rú  zint | floatr�  c                 C  s   d S rp   rr   rù  rr   rr   rs   rú  À	  s    zint | float | NonerÀ  c                 C  sJ   | durFt  | ¡r.tjdttƒ d� t| ƒ} nt  | ¡sFt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
    Nz•Non-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   Zis_floatrº   r»   r¼   r?   r�  rn  rä   rù  rr   rr   rs   rú  Å	  s    
ú

r�   )rŽ   r  rv   c                 C  s>   |dur:| dur.| |kr.t d|› d| j› �ƒ‚| du r:|} | 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
    Nr¼  r½  )rî   r  )rŽ   r  rr   rr   rs   r±  ç	  s    þÿr±  z'DatetimeTZDtype | np.dtype | ArrowDtyperê   c                 C  sJ   t | tƒr| jS t | tƒr<| jdvr4td| ›d�ƒ‚| jjS t | ¡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Ù   r«  z does not have a resolution.r   )	ry   rI   rý   rG   rÛ   rî   Zpyarrow_dtyper½   Zdatetime_datar¹   rr   rr   rs   rÂ  
  s    


rÂ  )¨Ú
__future__r   r   r   Ú	functoolsr   r%  Útypingr   r   r   r	   r
   r   r   r   rº   Únumpyr½   Zpandas._configr   Zpandas._libsr   r   Zpandas._libs.arraysr   Zpandas._libs.tslibsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   Zpandas._libs.tslibs.fieldsr#   r$   Zpandas._libs.tslibs.np_datetimer%   Zpandas._libs.tslibs.timedeltasr&   Zpandas._libs.tslibs.timestampsr'   Zpandas._typingr(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   Zpandas.compat.numpyr8   rƒ  Zpandas.errorsr9   r:   r;   Zpandas.util._decoratorsr<   r=   r>   Zpandas.util._exceptionsr?   Zpandas.core.dtypes.castr@   Zpandas.core.dtypes.commonrA   rB   rC   rD   rE   rF   Zpandas.core.dtypes.dtypesrG   rH   rI   rJ   rK   Zpandas.core.dtypes.genericrL   rM   Zpandas.core.dtypes.missingrN   rO   Zpandas.corerP   rQ   rR   rS   Zpandas.core.algorithmsrT   rU   rV   Zpandas.core.array_algosrW   Zpandas.core.arraylikerX   Zpandas.core.arrays._mixinsrY   rZ   Zpandas.core.arrays.arrow.arrayr[   Zpandas.core.arrays.baser\   Zpandas.core.arrays.integerr]   Zpandas.core.commonÚcoreÚcommonrÎ   Zpandas.core.constructionr^   rÿ   r_   r`   Zpandas.core.indexersra   rb   Zpandas.core.ops.commonrc   Zpandas.core.ops.invalidrd   re   Zpandas.tseriesrf   Úcollections.abcrg   rh   r  rj   rB  rk   rl   rm   r™   rt   r†   r‡   r¥  rò  ró  rô  rõ  r'  rø  rú  r±  rÂ  rr   rr   rr   rs   Ú<module>   sš   (
LH 
ÿ            &>?   h'"