o
    ôT·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šdTd*d+„Z›dUd/d0„ZœG d1d2„ d2etevƒZ�G d3d4„ d4e�ƒZžd5ZŸd6Z d7Z¡d8Z¢G d9d:„ d:e�ƒZ£dVd?d@„Z¤edWdCdD„ƒZ¥edXdGdD„ƒZ¥dYdJdD„Z¥dZdNdO„Z¦d[dRdS„Z§dS )\é    )Ú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Úop_nameÚstrc                 C  s   t | ƒ}t| ƒ|ƒS ©N)re   rc   )rn   Úop© rr   úb/home/dinkstrade/pdmp-scanner/venv/lib/python3.10/site-packages/pandas/core/arrays/datetimelike.pyÚ_make_unpacked_invalid_op¦   s   rt   Úmethr-   Ú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 r'tS t |tƒr2|  |j¡S | d¡}|  |¡S )NúM8[ns]Úi8)	Ú
isinstanceÚdtyperK   Úviewr   r   Ú	_box_funcÚ_valueÚ_from_backing_data)ÚselfÚargsÚkwargsÚarrÚresultÚ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„ƒZ	d÷dødd„Zedùdd„ƒZ	dúdd„Z
dûd!d"„Zdüd$d%„Zd&d'„ Zdýd(d)„Zdþd+d,„Zedÿd.d/„ƒZd0dd1œ�d d5d6„Z�d�dd8d9„Z	�d�dd<d=„Ze�dd@dA„ƒZe�ddDdA„ƒZ�d‡ fdHdA„Z�ddIdJ„Z�d	‡ fdMdN„Z�d
dOdP„Z�d�d‡ fdRdS„Ze�ddTdU„ƒZe�ddXdU„ƒZe�dd[dU„ƒZe�d�dd^dU„ƒZ�d�d‡ fd_dU„Zd`da„ ZddQdbœ�ddedf„Z�d�ddgdh„Z�d�ddjdk„Zdldm„ Ze �ddodp„ƒZ!e"�ddqdr„ƒZ#�ddudv„Z$�ddwdx„Z%e�ddydz„ƒZ&edöd{d|„ƒZ'e(df�dd~d„Z)e�dd�d‚„ƒZ*e�ddƒd„„ƒZ+e�dd†d‡„ƒZ,e�ddˆd‰„ƒZ-edödŠd‹„ƒZ.edödŒd�„ƒZ/e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 „ƒZ?e �dd¡d¢„ƒZ@e �dd£d¤„ƒZAe �dd¥d¦„ƒZBe �d d¨d©„ƒZCe �d!dªd«„ƒZDe �d"d­d®„ƒZEe �d#d±d²„ƒZFd³d´„ ZGdµd¶„ ZH�d$d·d¸„ZIe �d%dºd»„ƒZJe d¼d½„ ƒZKe d¾d¿„ ƒZLe �d&dÁdÂ„ƒZMe �d'dÃdÄ„ƒZNdQdÅœ�d(dÈdÉ„ZOePdÊƒdËdÌ„ ƒZQdÍdÎ„ ZRePdÏƒdÐdÑ„ ƒZSdÒdÓ„ ZT�ddÔdÕ„ZU�ddÖd×„ZVeW�d)‡ fdÛdÜ„ƒZXeWddQdÝœ�d*dàdá„ƒZYeWddQdÝœ�d*dâdã„ƒZZdQdädåœ�d+dædç„Z[eWddQdÝœ�d*dèdé„ƒZ\�d�d,dëdì„Z]�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Úfreqrv   Úboolc                 C  s   dS )NTrr   ©r   rr   rr   rs   Ú_can_hold_naÚ   ó   z#DatetimeLikeArrayMixin._can_hold_naNFrz   úDtype | NoneÚcopyÚNonec                 C  ó   t | ƒ‚rp   ©r9   )r   Údatarz   r�   r•   rr   rr   rs   Ú__init__Þ   s   zDatetimeLikeArrayMixin.__init__útype[DatetimeLikeScalar]c                 C  r—   )z£
        The scalar associated with this datelike

        * PeriodArray : Period
        * DatetimeArray : Timestamp
        * TimedeltaArray : Timedelta
        r˜   r‘   rr   rr   rs   Ú_scalar_typeã   s   	z#DatetimeLikeArrayMixin._scalar_typeÚvaluero   ÚDTScalarOrNaTc                 C  r—   )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   r�   rr   rr   rs   Ú_scalar_from_stringî   ó   z*DatetimeLikeArrayMixin._scalar_from_stringú)np.int64 | np.datetime64 | np.timedelta64c                 C  r—   )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Ÿ   rr   rr   rs   Ú_unbox_scalar  s   z$DatetimeLikeArrayMixin._unbox_scalarÚotherc                 C  r—   )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   r¤   rr   rr   rs   Ú_check_compatible_with  r¡   z-DatetimeLikeArrayMixin._check_compatible_withc                 C  r—   )zI
        box function to get object from internal representation
        r˜   )r   Úxrr   rr   rs   r|   /  ó   z DatetimeLikeArrayMixin._box_funcc                 C  s   t j|| jdd�S )z1
        apply box func to passed values
        F)Úconvert)r   Ú	map_inferr|   )r   Úvaluesrr   rr   rs   Ú_box_values5  s   z"DatetimeLikeArrayMixin._box_valuesrg   c                   s8   ˆ j dkr‡ fdd„ttˆ ƒƒD ƒS ‡ fdd„ˆ jD ƒS )Né   c                 3  s   � | ]}ˆ | V  qd S rp   rr   )Ú.0Únr‘   rr   rs   Ú	<genexpr>=  s   € z2DatetimeLikeArrayMixin.__iter__.<locals>.<genexpr>c                 3  s   � | ]}ˆ   |¡V  qd S rp   )r|   )r®   Úvr‘   rr   rs   r°   ?  s   € )ÚndimÚrangeÚlenÚasi8r‘   rr   r‘   rs   Ú__iter__;  s   
zDatetimeLikeArrayMixin.__iter__ú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_formatr¸   ústr | floatúnpt.NDArray[np.object_]c                C  r—   )z|
        Helper method for astype when converting to strings.

        Returns
        -------
        ndarray[str]
        r˜   )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._formatterúNpDtype | Noneúbool | Nonec                 C  sR   t |ƒr|du rtjdttƒ d� tjt| ƒtd�S |du r&t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__Úitemr2   c                 C  ó   d S rp   rr   ©r   rÌ   rr   rr   rs   Ú__getitem__{  r“   z"DatetimeLikeArrayMixin.__getitem__ú(SequenceIndexer | PositionalIndexerTupler3   c                 C  rÍ   rp   rr   rÎ   rr   rr   rs   rÏ     s   Úkeyr0   úSelf | DTScalarOrNaTc                   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}|S | jdkrd}|S t| |ƒ}d}t |tƒr9| jdur4|jdur4|j| j }|S | j}|S |tu rB| j}|S t	 
|¡rZt | tj¡¡}t |tƒrZ|  |¡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_keyrr   rr   rs   rÕ   —  s.   
î
ñ
÷	ø
ü

z(DatetimeLikeArrayMixin._get_getitem_freqú,int | Sequence[int] | Sequence[bool] | sliceúNaTType | Any | Sequence[Any]c                   s.   t ||| ƒ}tƒ  ||¡ |rd S |  ¡  d S rp   )rb   rÓ   Ú__setitem__Ú_maybe_clear_freq)r   rÑ   r�   Úno_opr×   rr   rs   rä   µ  s
   z"DatetimeLikeArrayMixin.__setitem__c                 C  rÍ   rp   rr   r‘   rr   rr   rs   rå   Ë  s   z(DatetimeLikeArrayMixin._maybe_clear_freqTc           	        s\  t |ƒ}|tkr;| jjdkr"t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ƒrW| j|jd�}| ¡ }|j||d	d
�S |  ¡ S t|tƒrhtƒ j||d�S |jdv r‰| j}|tjkr�td| j› d|› d�ƒ‚|r‡| ¡ }|S |jdv r“| j|ks˜|jdkr§dt| ƒj› d|› �}t|ƒ‚tj| |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_valueÚconstruct_array_typeÚ_from_sequencerÓ   ÚastyperÈ   Úint64Ú	TypeErrorr•   ÚtypeÚ__name__Úasarray)	r   rz   r•   Úi8dataÚ	convertedÚ
arr_objectÚclsr«   Úmsgr×   rr   rs   rù   Ð  sH   
ü



ÿzDatetimeLikeArrayMixin.astypec                 C  rÍ   rp   rr   r‘   rr   rr   rs   r{   	  r“   zDatetimeLikeArrayMixin.viewúLiteral['M8[ns]']rk   c                 C  rÍ   rp   rr   ©r   rz   rr   rr   rs   r{     r“   úLiteral['m8[ns]']rm   c                 C  rÍ   rp   rr   r  rr   rr   rs   r{     r“   .r(   c                 C  rÍ   rp   rr   r  rr   rr   rs   r{     r“   c                   s   t ƒ  |¡S rp   )rÓ   r{   r  r×   rr   rs   r{     s   c              
   C  s  t |tƒrz|  |¡}W n ttfy   t|ƒ‚w t || jƒs$|tu rE|  |¡}z|  	|¡ W |S  t
tfyD } zt|ƒ|‚d }~ww t|ƒsMt|ƒ‚t|ƒt| ƒkrYtdƒ‚z| j|dd�}|  	|¡ W |S  t
tfy‹ } ztt|dd ƒƒr{nt|ƒ|‚W Y d }~|S d }~ww )NzLengths must matchT)Úallow_objectrz   )ry   ro   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Úunboxr  r  c             
   C  sÂ   t || jƒrnQt |tƒr+z|  |¡}W nD ty* } z|  ||¡}t|ƒ|‚d}~ww t|| jƒr4t	}n$t
|ƒrB|  ||¡}t|ƒ‚t || jƒrN|  |¡}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œ   ro   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_scalarc                 C  sr   t |dƒrt|ddƒdk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  rr   rr   rs   r  „  s   ÿÿ	ýÿÿz0DatetimeLikeArrayMixin._validation_error_messager  c              	   C  s   t |t| ƒƒr| 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ƒrc|jt
krct |¡| jv rcz	t| ƒ |¡}W n ttfyb   |rX| Y S |  |d¡}t|ƒ‚w t|dd�}t|ƒ}t|dd�}t|ƒr�zt| ƒj|| jd�}W n	 tyŒ   Y nw t |jtƒr¤|jj| jkr¤| ¡ }t|dd�}|r¬t|jƒr¬nt| ƒ |j¡s¾|  |d¡}t|ƒ‚| jjdv rÎ|sÎ|j| jdd�}|S )	Nrï   F©Úround_okr   rÄ   rz   T©Úextract_numpy)ry   rü   rz   rñ   Úas_unitÚunitrÉ   r´   rø   r  rÊ   r   Úinfer_dtyper‰   r  rû   r  r`   Úpd_arrayrA   rH   Ú
categoriesÚ_internal_get_valuesrD   rŠ   )r   r�   r  r  rr   rr   rs   r	  £  sJ   ü	ÿ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_valueú6np.int64 | np.datetime64 | np.timedelta64 | np.ndarrayc                 C  s,   t  |¡r|  |¡}|S |  |¡ |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ƒr| ¡ S |jS )Nr   ri   )Ú	na_action)Úpandasrj   rU   ry   rM   Úto_numpyr^   )r   Úmapperr!  rj   rƒ   rr   rr   rs   Úmap÷  s   
zDatetimeLikeArrayMixin.mapr«   únpt.NDArray[np.bool_]c              	   C  sj  |j jdv rtj| jtd�S t|ƒ}t|t| ƒƒs‚g d¢}|j t	krYt
j|d| j d�}|j t	kr5|  |¡S t
j|dd�}||vrY|dkrEnd	|v rQt|  t	¡|ƒS tj| jtd�S z	t| ƒ |¡}W n tys   t|  t	¡|ƒ Y S w 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 w 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]
        ÚfiucrÄ   )r   Útimedelta64r   Ú
datetime64ÚdateÚperiodT)Úconvert_non_numericÚdtype_if_all_natF©ÚskipnaÚstringÚmixedz"The behavior of 'isin' with dtype=z¼ and castable values (e.g. strings) is deprecated. In a future version, these will not be considered matching by isin. Explicitly cast to the appropriate dtype before calling isin instead.rÂ   rï   úDatetimeArray | TimedeltaArray)rz   rñ   rÈ   Úzerosrõ   r�   r_   ry   rü   rÊ   r   Úmaybe_convert_objectsrT   r  rù   rø   r  rÅ   rÆ   rÇ   r?   r   r  r  r¦   rû   rµ   )r   r«   Ú	inferableÚinferredrr   rr   rs   rT     sN   
ý

ÿø
þzDatetimeLikeArrayMixin.isinc                 C  ó   | 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   r8  [  ó   
zDatetimeLikeArrayMixin._isnanc                 C  s   t | j ¡ ƒS )zJ
        return if I have any nans; enables various perf speedups
        )r�   r8  Úanyr‘   rr   rr   rs   Ú_hasnab  s   zDatetimeLikeArrayMixin._hasnarƒ   c                 C  s6   | j r|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Úputmaskr8  )r   rƒ   Ú
fill_valuer©   rr   rr   rs   Ú_maybe_mask_resultsi  s   
z*DatetimeLikeArrayMixin._maybe_mask_resultsú
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   rA  ‡  s   
zDatetimeLikeArrayMixin.freqstrc                 C  s0   | j dkrdS zt | ¡W S  ty   Y dS 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‘   rr   rr   rs   Úinferred_freq¥  s   
ÿz$DatetimeLikeArrayMixin.inferred_freqúResolution | Nonec                 C  s4   | j }|d u r	d S zt |¡W S  ty   Y d S w rp   )rA  r   Úget_reso_from_freqstrÚKeyError)r   rA  rr   rr   rs   Ú_resolution_objÄ  s   ÿz&DatetimeLikeArrayMixin._resolution_objc                 C  s   | j jS )zO
        Returns day, hour, minute, second, millisecond or microsecond
        )rG  Úattrnamer‘   rr   rr   rs   Ú
resolutionÎ  s   z!DatetimeLikeArrayMixin.resolutionc                 C  ó   t j| jdd�d S )NT©Útimeliker   ©r   Úis_monotonicrµ   r‘   rr   rr   rs   Ú_is_monotonic_increasingÙ  ó   z/DatetimeLikeArrayMixin._is_monotonic_increasingc                 C  rJ  )NTrK  r­   rM  r‘   rr   rr   rs   Ú_is_monotonic_decreasingÝ  rP  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rt|dd ƒ| jkr||  ¡ | ¡ ƒ | j¡S z|  |¡}W n ty1   t| ||ƒ Y S w t|dd ƒ}t|ƒrKt	 
|t |  t¡¡|¡}|S |tu rh|tju r^tj| jtd�}|S tj| jtd�}|S t| jtƒs«tt| ƒ} | j|jkr«t|t| ƒƒs¡z
|j| jdd�}W n  ty    t |j ¡}t!| j"||ƒ Y S w |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   Úcomp_method_OBJECT_ARRAYrÈ   rþ   rù   rÊ   r   ÚoperatorÚneÚonesr�   r3  ry   rz   rK   r   ÚTimelikeOpsrò   rü   r  r  r  r^   Úasm8r%   r�   r  r{   rO   r8  r:  r=  )
r   r¤   rq   rz   rƒ   Ú	other_arrÚ
other_valsÚo_maskÚmaskÚ
nat_resultrr   rr   rs   Ú_cmp_methodè  sR   ÿÿ
ÿ
ÿþ


z"DatetimeLikeArrayMixin._cmp_methodÚ__pow__Ú__rpow__Ú__mul__Ú__rmul__Ú__truediv__Ú__rtruediv__Ú__floordiv__Ú__rfloordiv__Ú__mod__Ú__rmod__Ú
__divmod__Ú__rdivmod__ú@tuple[int | npt.NDArray[np.int64], None | npt.NDArray[np.bool_]]c                 C  sP   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}   r8  rµ   )r   r¤   Ú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ƒr| 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|ƒrI| 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   Úpandas.core.arrays.datetimesru  r   rO   r�   Úto_datetime64rù   r  Ú_simple_newr   Ú_ensure_matching_resosrp  r   rµ   rÈ   rþ   r{   ré   rq  )
r   r¤   rk   ru  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ì   rr  rs  )r   ry  rz   rû   rü   rý   r¥   rr   rr   rs   Ú_add_datetime_arraylikes  s
   ÿz.DatetimeLikeArrayMixin._add_datetime_arraylikeú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   r~  Ú_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rtdƒ‚td| ƒ} |  |¡\} }|  	|¡S )Nrç   r…  ú$cannot add indices of unequal lengthrk   )
rz   rñ   rû   rü   rý   r´   r  r   r~  r†  r¥   rr   rr   rs   Ú_sub_datetime_arraylike�  s   

z.DatetimeLikeArrayMixin._sub_datetime_arraylikeúTimestamp | DatetimeArrayc           
   
   C  s¼   t d| ƒ} ddlm} z|  |¡ W n ty- } zt|ƒ dd¡}t|ƒ|ƒ|‚d }~ww |  |¡\}}t	| j
tj| dd�ƒ}| d| j› d	�¡}|  |¡}	t d
|	ƒ}	|j||j|	d�S )Nrk   r   ©rm   ÚcompareÚsubtractrx   rÄ   útimedelta64[rv  zTick | Nonerx  )r   rz  rm   Ú_assert_tzawareness_compatrû   ro   Úreplacerü   rp  r   rµ   rÈ   rþ   r{   r  rq  r}  rz   )
r   r¤   rm   r  Únew_messager  r]  r€  Úres_m8r�  rr   rr   rs   r†  �  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   ry  rz   rû   rü   rý   Úpandas.core.arrays.periodrl   rÈ   Úbroadcast_torn  rõ   rK   r�   )r   r¤   rl   Úi8valsrz   Úparrrr   rr   rs   Ú_add_period±  s   
z"DatetimeLikeArrayMixin._add_periodc                 C  r—   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Ä   r2  )rO   rÈ   Úemptyrõ   r{   r�   rz   Úfillr   rü   r}  r   r   r~  Ú_add_timedeltalike)r   r¤   Ú
new_valuesrr   rr   rs   Ú_add_timedeltalike_scalarÁ  s   


z0DatetimeLikeArrayMixin._add_timedeltalike_scalarc                 C  s:   t | ƒt |ƒkrtdƒ‚td| ƒ} |  |¡\} }|  |¡S )zl
        Add a delta of a TimedeltaIndex

        Returns
        -------
        Same type as self
        r‰  r2  )r´   r  r   r~  r�  r¥   rr   rr   rs   Ú_add_timedelta_arraylikeÕ  s
   


z/DatetimeLikeArrayMixin._add_timedelta_arraylikeúTimedelta | TimedeltaArrayc                 C  s\   t d| ƒ} |  |¡\}}t| jtj|dd�ƒ}| | jj¡}|  	|¡}t
| ƒj|| j|d�S )Nr2  rx   rÄ   rx  )r   rp  r   rµ   rÈ   rþ   r{   r�   rz   rq  rü   r}  )r   r¤   r  r]  rž  r€  r�  rr   rr   rs   r�  ç  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 rs  zTimedeltaArray | DatetimeArrayrÄ   Nrx  )ry   rz   rK   rû   rü   rý   r   r   rÈ   r›  rõ   rú   rœ  r   r{   r�   r}  ©r   rƒ   rr   rr   rs   Ú_add_natø  s   ÿ

ÿzDatetimeLikeArrayMixin._add_natc                 C  sP   t j| jt jd�}| t¡ | jjdv r#td| ƒ} | 	d| j
› d�¡S | 	d¡S )z+
        Subtract pd.NaT from self
        rÄ   rï   zDatetimeArray| TimedeltaArrayr�  rv  ztimedelta64[ns])rÈ   r›  rõ   rú   rœ  r   rz   rñ   r   r{   r  r¢  rr   rr   rs   Ú_sub_nat  s   


zDatetimeLikeArrayMixin._sub_natú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 rGˆ 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  ó    z:DatetimeLikeArrayMixin._sub_periodlike.<locals>.<listcomp>)ry   rz   rK   rû   rü   rý   r   r¦   rp  r   rµ   rÈ   rþ   r^   r8  r   )r   r¤   r  r]  Únew_i8_dataÚ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r| jdkr|| |d ƒS tjdt| ƒj› d�t	t
ƒ d� | j|jks:J | 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)rV  ÚaddÚsubr´   r²   rÅ   rÆ   rü   rý   r;   r?   rõ   rù   rÈ   rþ   )r   r¤   rq   r€  rr   rr   rs   Ú_addsub_object_array<  s   ÿüz+DatetimeLikeArrayMixin._addsub_object_arrayr.  Únamer/  c                K  sV   |dvrt d|› dt| ƒ› �ƒ‚tt|ƒ}||  ¡ fd|i|¤Ž}t| ƒj|| jd�S )N>   ÚcummaxÚcumminzAccumulation z not supported for r/  rÄ   )rû   rü   r
  rW   r•   r}  rz   )r   r³  r/  r�   rq   rƒ   rr   rr   rs   Ú_accumulate`  s
   
z"DatetimeLikeArrayMixin._accumulateÚ__add__c                 C  s   t |dd ƒ}t|ƒ}|tu r|  ¡ }n£t|tttjfƒr"|  	|¡}n”t|t
ƒr-|  |¡}n‰t|ttjfƒr;|  |¡}n{t|tƒrMt | jd¡rM|  |¡}nit |¡rmt| jtƒs\t| ƒ‚td| ƒ}| ||jj tj¡}nIt |d¡ry|  |¡}n=t|ƒr…|  |tj¡}n1t |d¡s�t|tƒr•|   |¡S t!|ƒr´t| jtƒs£t| ƒ‚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   rŒ  )'r
  r_   r   r£  ry   r   r   rÈ   r(  rŸ  r   rš  r   r)  r‚  r   r   ry  rz   r˜  Ú
is_integerrK   r'   r   Ú_addsub_int_array_or_scalarÚ_nrV  r°  r   rD   r²  rI   rƒ  rB   ÚNotImplementedÚndarrayrz  rm   rø   ©r   r¤   Úother_dtyperƒ   Úobjrm   rr   rr   rs   r·  i  sF   



ÿ


zDatetimeLikeArrayMixin.__add__c                 C  s
   |   |¡S rp   )r·  r¥   rr   rr   rs   Ú__radd__¡  s   
zDatetimeLikeArrayMixin.__radd__Ú__sub__c                 C  s°  t |dd ƒ}t|ƒ}|tu r|  ¡ }n«t|tttjfƒr#|  	| ¡}n›t|t
ƒr/|  | ¡}n�t|ttjfƒr=|  |¡}n�t |¡r]t| jtƒsLt| ƒ‚td| ƒ}| ||jj tj¡}nat|tƒrh|  |¡}nVt |d¡ru|  | ¡}nIt|ƒr�|  |tj¡}n=t |d¡sŒt|tƒr’|   |¡}n,t|tƒr�|  |¡}n!t!|ƒr¼t| jtƒs«t| ƒ‚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   rŒ  )'r
  r_   r   r¤  ry   r   r   rÈ   r(  rŸ  r   rš  r   r)  rˆ  r   r¸  rz   rK   r'   r   r¹  rº  rV  r±  r   r®  ry  r   rD   r²  rI   rŠ  rB   r»  r¼  rz  rm   rø   r½  rr   rr   rs   rÁ  ¥  sJ   




ÿ


zDatetimeLikeArrayMixin.__sub__c                 C  s  t |dd ƒ}t |d¡pt|tƒ}|r9t | jd¡r9t |¡r%t|ƒ|  S t|tƒs5ddl	m
} | |¡}||  S | jjdkrVt|dƒrV|sVtdt| ƒj› dt|ƒj› �ƒ‚t| jtƒrpt |d¡rptdt| ƒj› d|j› �ƒ‚t | jd¡r�td| ƒ} |  | S | |  S )	Nrz   rç   rì   r   rt  r¦  r§  rm   )r
  r   ry  ry   rI   rz   rÔ   r   rˆ   rz  rk   rø   rñ   r  rû   rü   rý   rK   r   )r   r¤   r¾  Úother_is_dt64rk   rr   rr   rs   Ú__rsub__Ý  s*   ÿ


ÿ


zDatetimeLikeArrayMixin.__rsub__c                 C  s4   | | }|d d … | d d …< t | jtƒs|j| _| S rp   ©ry   rz   rK   r�   rÖ   ©r   r¤   rƒ   rr   rr   rs   Ú__iadd__ÿ  ó
   zDatetimeLikeArrayMixin.__iadd__c                 C  s4   | | }|d d … | d d …< t | jtƒs|j| _| S rp   rÄ  rÅ  rr   rr   rs   Ú__isub__  rÇ  zDatetimeLikeArrayMixin.__isub__Úqsúnpt.NDArray[np.float64]Úinterpolationc                   s   t ƒ j||d�S )N)rÉ  rË  )rÓ   Ú	_quantile)r   rÉ  rË  r×   rr   rs   rÌ    s   z DatetimeLikeArrayMixin._quantile©Úaxisr/  rÎ  úAxisInt | Nonec                K  ó8   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Í  )ÚnvÚvalidate_minÚvalidate_minmax_axisr²   rR   Únanminr�   Ú_wrap_reduction_result©r   rÎ  r/  r�   rƒ   rr   rr   rs   Úmin  ó   zDatetimeLikeArrayMixin.minc                K  rÐ  )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Ñ  Úvalidate_maxrÓ  r²   rR   Únanmaxr�   rÕ  rÖ  rr   rr   rs   Úmax.  rØ  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   Ú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Ñ  Úvalidate_medianÚabsr²   r  rR   Ú	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È   r¼  r~   )r   rã  r^  Úi8modesÚnpmodesrr   rr   rs   Ú_modeƒ  s   
zDatetimeLikeArrayMixin._modeÚhowÚhas_dropped_naÚ	min_countÚintÚngroupsÚidsúnpt.NDArray[np.intp]c                K  s’  | j }|jdkr)|dv rtd|› d�ƒ‚|dv r(tjd|› d|› d�ttƒ d	� n2t|tƒrO|dv r:td
|› d�ƒ‚|dv rNt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ƒr¤tdƒ‚td| ƒ} d| j› d�}| 
|¡}|j||j d�S | 
| j	j ¡}|  |¡S )Nrç   )ÚsumÚprodÚ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ì  Úcomp_idsr^  )ÚstdÚsemrŒ  z-'std' and 'sem' are not valid for PeriodDtyper2  zm8[rv  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_blocklistrz  rm   r   r  r}  r~   )r   rè  ré  rê  rì  rí  r�   rz   Únpvaluesrö  rñ   rq   r€  rm   Ú	new_dtyperr   rr   rs   Ú_groupby_op�  sl   

ÿü€
ÿü€
ÿûú	


z"DatetimeLikeArrayMixin._groupby_op©rv   r�   )NNF)rz   r”   r•   r�   rv   r–   )rv   r›   )r�   ro   rv   rž   )r�   rž   rv   r¢   )r¤   rž   rv   r–   ©rv   rŒ   )rv   rg   )rv   r·   )r¸   rº   rv   r»   )F)r½   r�   )NN)rz   rÀ   r•   rÁ   rv   rŒ   )rÌ   r2   rv   rž   )rÌ   rÐ   rv   r3   )rÑ   r0   rv   rÒ   )rv   rŽ   )rÑ   râ   r�   rã   rv   r–   ©rv   r–   ©T)r•   r�   ©rv   r3   )rz   r  rv   rk   )rz   r  rv   rm   ).)rz   r”   rv   r(   rp   )r  r�   r  r�   )r  r�   rv   ro   )r  r�   )rv   r   )r«   r(   rv   r&  )rv   r&  )rƒ   rŒ   rv   rŒ   )rv   r@  )rv   rD  ©rv   ro   )rv   rm  )rv   rk   )r¤   rk   rv   rk   )r¤   r„  rv   rm   )r¤   rk   rv   rm   )r¤   r‹  rv   rm   )r¤   r   rv   rl   )r¤   rm   )r¤   r¡  )r¤   r¥  rv   r»   )r¤   r»   )r³  ro   r/  r�   rv   r3   )rÉ  rÊ  rË  ro   rv   r3   )rÎ  rÏ  r/  r�   )r/  r�   rÎ  rÏ  )rã  r�   )
rè  ro   ré  r�   rê  rë  rì  rë  rí  rî  )`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   r8  r;  r   r?  rA  rC  rG  rI  rO  rQ  rT  r`  rt   ra  rb  rc  rd  re  rf  rg  rh  ri  rj  rk  rl  rp  rq  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__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	„ƒZd
S )ÚDatelikeOpszK
    Common ops for DatetimeIndex/PeriodIndex, but not TimedeltaIndex.
    zNhttps://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior)ÚURLr¹   ro   rv   r»   c                 C  sD   | j |tjd�}tƒ rd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¹   ro   rv   r»   )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                      sÒ  e Zd ZU dZded< dejdfded
d„Zedd„ ƒZ	e
dd„ ƒZejdfdd„ƒZedgdd„ƒZeedhdd„ƒƒZedidd„ƒZedjdd „ƒZedkd"d#„ƒZdldmd'd(„Zd)d*„ Zdn‡ fd.d/„Zd0d1„ Zeee jd2d3�ƒ	4	4dodpd9d:„ƒZeee jd;d3�ƒ	4	4dodpd<d=„ƒZeee jd>d3�ƒ	4	4dodpd?d@„ƒZ dd$dAœdqdEdF„Z!dd$dAœdqdGdH„Z"dfdIdJ„Z#drdKdL„Z$ds‡ fdNdO„Z%	$	dtdu‡ fdRdS„Z&e	Tdvdw‡ fdXdY„ƒZ'dxdy‡ fd\d]„Z(dzdadb„Z)e
d{dcdd„ƒZ*‡  Z+S )|rY  zK
    Common ops for TimedeltaIndex/DatetimeIndex, but not PeriodIndex.
    znp.dtypeÚ_default_dtypeNFr•   r�   rv   r–   c           	      C  sš  t jt| ƒj› d�ttƒ d� |d urt|ƒ}t|dd�}t|t	ƒr)|j
dtd�}t|dd ƒ}|d u }|tjur:|nd }t|t| ƒƒrx|rFn|d u rN|j}n|r]|jr]t|ƒ}t||jƒ}|d urq||jkrqtd|› d	|j› �ƒ‚|j}|j}n'|d u rŸt|tjƒrŒ|jjd
v rŒ|j}n| j}t|tjƒrŸ|jdkrŸ| |¡}t|tjƒs¶tdt|ƒj› dt| ƒj› d�ƒ‚|jdvr¿tdƒ‚|jdkrõ|d u rÒ| j}| | j¡}n#t |d¡rÞ| |¡}nt|tƒrõ| jj}|› d|j› d�}| |¡}|  ||¡}|dk�rtdt| ƒj› d�ƒ‚|�r|  ¡ }|�r*t|ƒ}|jjdk�r*t|t!ƒ�s*tdƒ‚t"j#| ||d� || _$|d u �rI|d u�rKt| ƒ %| |¡ d S d S 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 Ú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[rv  Ú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²   ry  rI   r  Ú_validate_dtyper•   r   r   rš   rÖ   Ú_validate_frequency)	r   r«   rz   r�   r•   rC  Úexplicit_nonerñ   rÿ  rr   rr   rs   rš   ¶  s†   û

ÿ
ÿÿ




ÿÿzTimelikeOps.__init__c                 C  r—   rp   r˜   )r  r«   rz   rr   rr   rs   r    s   zTimelikeOps._validate_dtypec                 C  r7  )zK
        Return the frequency object if it is set, otherwise None.
        ©rÖ   r‘   rr   rr   rs   r�     s   zTimelikeOps.freqc                 C  sV   |d ur&t |ƒ}|  | |¡ | jjdkrt|tƒstdƒ‚| jdkr&t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   

Úvalidate_kwdsÚdictc                 C  s’   |du r	d| _ dS |dkr| j du rt| jƒ| _ dS dS |tju r#dS | j du r=t|ƒ}t| ƒj| |fi |¤Ž || _ dS 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"   rC  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d|d dt|ƒ||jdœ|¤Ž}t |j|j¡s-t	‚W dS  t	yO } zdt
|ƒv r?|‚t	d|› d|j› �ƒ|‚d}~w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 rr   )rC  rS  rA  Ú_generate_ranger´   r  rÈ   Úarray_equalrµ   r  ro   )r  Úindexr�   r�   r6  Úon_freqr  rr   rr   rs   r  K  s8   ûúÿÿÿý€özTimelikeOps._validate_frequencyr$  ú
int | Noner3   c                 O  r—   rp   r˜   )r  r"  r#  r$  r�   r€   r�   rr   rr   rs   r'  w  r¨   zTimelikeOps._generate_rangerë  c                 C  s   t | jjƒS rp   )r   r�   rz   r‘   rr   rr   rs   rò     s   zTimelikeOps._cresoro   c                 C  s
   t | jƒS rp   )Údtype_to_unitrz   r‘   rr   rr   rs   r  ƒ  r9  zTimelikeOps.unitTr  r  c                 C  s~   |dvrt dƒ‚t | jj› d|› d�¡}t| j||d�}t| jtjƒr(|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  rv  r  rk   rw  rx  )r  rÈ   rz   rñ   r   r�   ry   r   ré   rI   rü   r}  r�   )r   r  r  rz   rž  rÿ  ré   rr   rr   rs   r  Š  s   ÿzTimelikeOps.as_unitc                 C  s@   | j |j kr| j |j k r|  |j¡} | |fS | | j¡}| |fS rp   )rò   r  r  r¥   rr   rr   rs   r~  Ÿ  s   ÿz"TimelikeOps._ensure_matching_resosÚufuncúnp.ufuncÚmethodc                   s`   |t jt jt jfv r"t|ƒdkr"|d | u r"t||ƒ| jfi |¤ŽS tƒ j||g|¢R i |¤ŽS )Nr­   r   )	rÈ   ÚisnanÚisinfÚisfiniter´   r
  r�   rÓ   Ú__array_ufunc__)r   r1  r3  Úinputsr�   r×   rr   rs   r7  ª  s
   zTimelikeOps.__array_ufunc__c           
      C  s¬   t | jtƒr!td| ƒ} |  d ¡}| ||||¡}|j| j||d�S |  d¡}ttj	|ƒ}t
|| jƒ}|dkr:|  ¡ S t|||ƒ}	| j|	td�}| | jj¡}| j|| jd�S )Nrk   )Ú	ambiguousÚnonexistentrx   r   ©r>  rÄ   )ry   rz   rI   r   Útz_localizeÚ_roundré   r{   rÈ   r¼  r&   rò   r•   r$   r?  r   r�   r}  )
r   r�   rä  r9  r:  Únaiverƒ   r«   ÚnanosÚ	result_i8rr   rr   rs   r=  µ  s    

ÿ
zTimelikeOps._roundÚround)rq   Úraiser9  r5   r:  r6   c                 C  ó   |   |tj||¡S rp   )r=  r#   ÚNEAREST_HALF_EVEN©r   r�   r9  r:  rr   rr   rs   rA  Ë  ó   zTimelikeOps.roundÚfloorc                 C  rC  rp   )r=  r#   ÚMINUS_INFTYrE  rr   rr   rs   rG  Ô  rF  zTimelikeOps.floorÚceilc                 C  rC  rp   )r=  r#   Ú
PLUS_INFTYrE  rr   rr   rs   rI  Ý  rF  zTimelikeOps.ceilrÍ  rÎ  rÏ  r/  c                C  ó   t j| j|||  ¡ d�S ©NrÜ  )rR   Únananyr�   rO   ©r   rÎ  r/  rr   rr   rs   r:  é  s   zTimelikeOps.anyc                C  rK  rL  )rR   Únanallr�   rO   rN  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n&t | ƒdkr t|tƒr | jjdkrt|tƒstdƒ‚n|dks&J ‚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"   rC  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   rQ  	  s   
zTimelikeOps._values_for_jsonÚuse_na_sentinelÚsortc                   s‚   | j d ur-tjt| ƒtjd�}|  ¡ }|r)| j jdk r)|d d d… }|d d d… }||fS |r:t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.)rR  )r�   rÈ   Úaranger´   Úintpr•   r¯   ÚNotImplementedErrorrü   rý   rÓ   Ú	factorize)r   rR  rS  ÚcodesÚuniquesr×   rr   rs   rX  	  s   
ÿzTimelikeOps.factorizer   Ú	to_concatúSequence[Self]r)   c                   sŒ   t ƒ  ||¡}|d ‰ |dkrDdd„ |D ƒ}ˆ jd urDt‡ fdd„|D ƒƒrDt|d d… |dd … ƒ}t‡ fdd„|D ƒƒrDˆ j}||_|S )	Nr   c                 S  s   g | ]}t |ƒr|‘qS rr   )r´   r©  rr   rr   rs   rª  C	  r«  z1TimelikeOps._concat_same_type.<locals>.<listcomp>c                 3  s   � | ]	}|j ˆ j kV  qd S rp   ©r�   r©  ©r¿  rr   rs   r°   E	  s   € z0TimelikeOps._concat_same_type.<locals>.<genexpr>rT  r­   c                 3  s.   � | ]}|d  d ˆ j  |d d  kV  qdS )r   rT  r­   Nr]  )r®   Úpairr^  rr   rs   r°   G	  s   €, )rÓ   Ú_concat_same_typer�   rõ  ÚziprÖ   )r  r[  rÎ  Únew_objÚpairsr�  r×   r^  rs   r`  6	  s    zTimelikeOps._concat_same_typeÚCÚorderc                   s   t ƒ j|d�}| j|_|S )N)re  )rÓ   r•   r�   rÖ   )r   re  rb  r×   rr   rs   r•   L	  s   zTimelikeOps.copyr.   r)  rj   c          
   	   K  s^   |dkrt ‚|s| j}	n| j ¡ }	tj|	f||||||dœ|¤Ž |s%| S t| ƒj|	| jd�S )z2
        See NDFrame.interpolate.__doc__.
        Úlinear)r3  rÎ  r)  ÚlimitÚlimit_directionÚ
limit_arearÄ   )rW  r�   r•   rQ   Úinterpolate_2d_inplacerü   r}  rz   )
r   r3  rÎ  r)  rg  rh  ri  r•   r�   Ú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   ry  rz   rµ   r   r   r!   rÈ   Úlogical_andrï  )r   Ú
values_intÚconsider_valuesrë   ÚppdÚ	even_daysrr   rr   rs   Ú_is_dates_onlyz	  s   
zTimelikeOps._is_dates_only)r•   r�   rv   r–   r  )r  r   )r�   r   )r$  r+  rv   r3   )rv   rë  r  r  )r  ro   r  r�   rv   r3   )r1  r2  r3  ro   )rB  rB  )r9  r5   r:  r6   rv   r3   )rÎ  rÏ  r/  r�   rv   r�   r  r  )TF)rR  r�   rS  r�   )r   )r[  r\  rÎ  r)   rv   r3   )rd  )re  ro   rv   r3   )
r3  r.   rÎ  rë  r)  rj   r•   r�   rv   r3   r  ),rý   r  r  r	  r
  r   r  rš   Úclassmethodr  r  r�   Úsetterr   r!  r  r'  r>   rò   r  r  r~  r7  r=  r<   Ú
_round_docÚ_round_exampler¾   rA  Ú_floor_examplerG  Ú_ceil_examplerI  r:  rõ  rå   rP  rQ  rX  r`  r•   rl  rr  r  rr   rr   r×   rs   rY  ¯  sj   
 ÿ\

 *üüü

 ýý
)rY  r•   r�   Úcls_nameútuple[ArrayLike, bool]c                 C  s  t | dƒst| ttfƒst | ¡dkrt| ƒ} t| ƒ} d}nt| tƒr+td|› d�ƒ‚t	| dd�} t| t
ƒsAt| tƒrN| jjdv rN| jd	td
�} d}| |fS t| tƒra|  ¡ } |  ¡ } d}| |fS t| tjtfƒsrt | ¡} | |fS 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   Ú_maybe_convert_datelike_arrayr¼  r\   rþ   rL   r  ÚtakerY  r   Ú_values)r™   r•   ry  rr   rr   rs   Ú!ensure_arraylike_for_datetimelike”	  s6   


ÿ
ñõ
	
ùr  r$  r–   c                 C  rÍ   rp   rr   ©r$  rr   rr   rs   Úvalidate_periods»	  r“   r�  úint | floatrë  c                 C  rÍ   rp   rr   r€  rr   rr   rs   r�  À	  r“   úint | float | Noner+  c                 C  sL   | dur$t  | ¡rtjdttƒ d� t| ƒ} | S t  | ¡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
    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   Úis_floatrÅ   rÆ   rÇ   r?   rë  r¸  rû   r€  rr   rr   rs   r�  Å	  s   
ú
þr�   rŽ   rC  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  rA  )r�   rC  rr   rr   rs   r  ç	  s   þÿr  rz   ú'DatetimeTZDtype | np.dtype | ArrowDtypec                 C  sJ   t | tƒr| jS t | tƒr| jdvrt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  Úpyarrow_dtyperÈ   Údatetime_datarÄ   rr   rr   rs   r,  
  s   


r,  )rn   ro   )ru   r-   rv   r-   )r•   r�   ry  ro   rv   rz  )r$  r–   rv   r–   )r$  r‚  rv   rë  )r$  rƒ  rv   r+  )r�   rŽ   rC  rŽ   rv   rŽ   )rz   r…  rv   ro   )¨Ú
__future__r   r   r   Ú	functoolsr   rV  Útypingr   r   r   r	   r
   r   r   r   rÅ   ÚnumpyrÈ   Úpandas._configr   Úpandas._libsr   r   Úpandas._libs.arraysr   Úpandas._libs.tslibsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   Úpandas._libs.tslibs.fieldsr#   r$   Úpandas._libs.tslibs.np_datetimer%   Úpandas._libs.tslibs.timedeltasr&   Úpandas._libs.tslibs.timestampsr'   Úpandas._typingr(   r)   r*   r+   r,   r-   r.   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   rz  rk   rl   rm   rž   rt   r‡   rˆ   r  ru  rv  rw  rx  rY  r  r�  r  r,  rr   rr   rr   rs   Ú<module>   sœ    (
LH 


ÿ            &>?   
h'

"