o
    ŀgh                    @  s  d dl mZ d dlmZmZmZ d dlmZmZmZ d dl	Z	d dl
Zd dlmZmZ d dlmZ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!m"Z" d dl#m$Z$ d dl%m&Z& d d	l'm(Z( d d
l)m*Z* d dl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 d dl2m3Z3m4Z4m5Z5 d dl6m7Z7 d dl8m9Z: d dl;m<Z< d dl=m>  m?Z@ d dlAmBZB d dlCmDZDmEZE erd dlFmGZG d dlHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZP d dlQmRZR d dl8mSZS dZTedcddddZUedcded"dZU	#dfdgd&dZUdhdid+d,ZVG d-d. d.e:jWe:jXZYd/dd/d/d0dd1djd;d<ZZdkd?d@Z[	/	0	/	#dldmdEdFZ\dhdndGdHZ]dodJdKZ^dLdM Z_	/dpdqdOdPZ`drdTdUZadsdXdYZbdtd[d\ZcdudadbZddS )v    )annotations)datetime	timedeltatzinfo)TYPE_CHECKINGcastoverloadN)libtslib)
BaseOffsetNaTNaTType
Resolution	Timestampastype_overflowsafefieldsget_resolutionget_supported_dtypeget_unit_from_dtypeints_to_pydatetimeis_date_array_normalizedis_supported_dtypeis_unitlessnormalize_i8_timestamps	timezones	to_offsettz_convert_from_utctzconversion)abbrev_to_npy_unit)PerformanceWarning)find_stack_level)validate_inclusive)DT64NS_DTYPEINT64_DTYPEis_bool_dtypeis_float_dtypeis_string_dtypepandas_dtype)DatetimeTZDtypeExtensionDtypePeriodDtype)isna)datetimelike)generate_regular_range)get_period_alias)DayTick)Iterator)	ArrayLikeDateTimeErrorChoicesDtypeObjIntervalClosedTypeSelfTimeAmbiguousTimeNonexistentnpt	DataFramePeriodArrayi'  .tzr   unitstrreturnr(   c                 C     d S N r>   r?   rD   rD   P/var/www/html/myenv/lib/python3.10/site-packages/pandas/core/arrays/datetimes.pytz_to_dtype]      rG   Nonenp.dtype[np.datetime64]c                 C  rB   rC   rD   rE   rD   rD   rF   rG   b   rH   nstzinfo | None)np.dtype[np.datetime64] | DatetimeTZDtypec                 C  s&   | du rt d| dS t| |dS )z
    Return a datetime64[ns] dtype appropriate for the given timezone.

    Parameters
    ----------
    tz : tzinfo or None
    unit : str, default "ns"

    Returns
    -------
    np.dtype or Datetime64TZDType
    NM8[]rE   )npdtyper(   rE   rD   rD   rF   rG   g   s   namefield	docstring
str | Nonec                   s     fdd}| |_ ||_t|S )Nc                   s   |   } | jv r; dr0| j}d}|r"|j}|d|dd}tj| | j|| j	d}|S tj
| | j	d}|S  | jv rRtj| | j	d}| j|d d}|S tj
| | j	d}| j|d dd}|S )	N)startend   startingMonthmonthreso
fill_valuefloat64)r^   convert)_local_timestamps	_bool_opsendswithfreqkwdsgetr   get_start_end_fieldfreqstr_cresoget_date_field_object_opsget_date_name_field_maybe_mask_results)selfvaluesrd   month_kwre   resultrS   rD   rF   f}   s.   


z_field_accessor.<locals>.f)__name____doc__property)rR   rS   rT   rs   rD   rr   rF   _field_accessor|   s   "rw   c                	      s  e Zd ZU dZdZeddZeejfZ	dd Z
dZedd
dZg dZded< ddgZded< g dZded< g dZded< ee e e dg Zded< g dZded< dZded< dZded< eZedd#d$Zed%d& ZedefdЇ fd)d*Zedd+d,dd/d0Zedd+ejejd+d+d1d2dd8d9Z e		+	1	1	:ddd;ddDdEZ!ddGdHZ"ddJdKZ#ddMdNZ$ddPdQZ%eddRdSZ&eddUdVZ'e'j(dWdV Z'eddXdYZ)eddZd[Z*edd]d^Z+ddއ fd`daZ,ddcddZ-ddч fdfdgZ.dddhddldmZ/ddndoZ0ddpdqZ1ddtduZ2ddwdxZ3ddydzZ4e5j6	1	1ddd{d|Z7dd}d~Z8dddZ9ddddZ:ddddZ;ddddZ<edddZ=edddZ>edddZ?dddZ@eAdddZBeAdddZCeAdddZDeAdddZEeAdddZFeAdddZGeAdddZHeAdddZIdZJeAddeJZKeKZLeKZMeAdddZNeNZOeAdddZPeAdddZQeQZRdZSeAddeSjTddZUeAddeSjTddZVeAdddZWeAdddZXeAdddZYeAdddZZeAdddÃZ[dddƄZ\					+	edddd̈́Z]  Z^S )DatetimeArraya{  
    Pandas ExtensionArray for tz-naive or tz-aware datetime data.

    .. warning::

       DatetimeArray is currently experimental, and its API may change
       without warning. In particular, :attr:`DatetimeArray.dtype` is
       expected to change to always be an instance of an ``ExtensionDtype``
       subclass.

    Parameters
    ----------
    values : Series, Index, DatetimeArray, ndarray
        The datetime data.

        For DatetimeArray `values` (or a Series or Index boxing one),
        `dtype` and `freq` will be extracted from `values`.

    dtype : numpy.dtype or DatetimeTZDtype
        Note that the only NumPy dtype allowed is 'datetime64[ns]'.
    freq : str or Offset, optional
        The frequency.
    copy : bool, default False
        Whether to copy the underlying array of values.

    Attributes
    ----------
    None

    Methods
    -------
    None

    Examples
    --------
    >>> pd.arrays.DatetimeArray._from_sequence(
    ...    pd.DatetimeIndex(['2023-01-01', '2023-01-02'], freq='D'))
    <DatetimeArray>
    ['2023-01-01 00:00:00', '2023-01-02 00:00:00']
    Length: 2, dtype: datetime64[ns]
    datetimearrayr   rK   c                 C  s   t | dp
t| tS NM)r	   is_np_dtype
isinstancer(   )xrD   rD   rF   <lambda>   s    zDatetimeArray.<lambda>)r   
datetime64daterA   type[Timestamp]c                 C  s   t S rC   )r   rn   rD   rD   rF   _scalar_type   rH   zDatetimeArray._scalar_type)is_month_startis_month_endis_quarter_startis_quarter_endis_year_startis_year_endis_leap_yearz	list[str]rb   rd   r>   rk   )yearrZ   dayhourminutesecondweekday	dayofweekday_of_week	dayofyearday_of_yearquarterdays_in_monthdaysinmonthmicrosecond
nanosecond
_field_ops)r   timetimetz
_other_opsr?   _datetimelike_ops)	to_periodtz_localize
tz_convert	normalizestrftimeroundfloorceil
month_nameday_nameas_unit_datetimelike_methodsi  rM   _dtypeNBaseOffset | None_freqrQ   r4   r6   c                C  s$   t j|dddvrt| j||dS )NTskipna)r   r   rQ   )r	   infer_dtype
ValueError_from_sequence)clsscalarsrQ   rD   rD   rF   _from_scalars  s   zDatetimeArray._from_scalarsc                 C  sZ   t |}t |j t|tjr|j|krtd|S t|jd }||jkr+td|S )Nz'Values resolution does not match dtype.r   )_validate_dt64_dtyperQ   r}   rP   r   datetime_datar?   )r   ro   rQ   vunitrD   rD   rF   _validate_dtype!  s   


zDatetimeArray._validate_dtypero   npt.NDArray[np.datetime64]c                   sr   t |tjsJ |jdksJ t |tjr#||jksJ t|r"J n
|jt|jks-J t 	||}||_
|S rz   )r}   rP   ndarraykindrQ   r   ri   r   super_simple_newr   )r   ro   rd   rQ   rq   	__class__rD   rF   r   0  s   zDatetimeArray._simple_newFrQ   copyr   boolc                C  s   | j |||dS Nr   )_from_sequence_not_strict)r   r   rQ   r   rD   rD   rF   r   E  s   zDatetimeArray._from_sequenceraise)rQ   r   r>   rd   dayfirst	yearfirst	ambiguous'str | BaseOffset | lib.NoDefault | Noner   r   r   r7   c             	   C  s  |du }	|t ju rd}nt|}t|}t|||	}d}
|dur&t|}
tj||dd\}}d}t	|t
r:|j}t|||||||
d\}}t|||	 |durW|	rWtdt|jd }t||}| j|||d}|
durz|
|jkrz||
}d|i}||| |S )	z\
        A non-strict version of _from_sequence, called from DatetimeIndex.__new__.
        Nrx   )cls_namer   r>   r   r   r   out_unitz^Passed data is timezone-aware, incompatible with 'tz=None'. Use obj.tz_localize(None) instead.r   rd   rQ   r   )r	   
no_defaultr   maybe_get_tzr   _validate_tz_from_dtypedtldtype_to_unit!ensure_arraylike_for_datetimeliker}   rx   rd   _sequence_to_dt64r   rP   r   rQ   rG   r   r?   r   _maybe_pin_freq)r   datarQ   r   r>   rd   r   r   r   explicit_tz_noner?   inferred_freqsubarr	data_unit
data_dtyperq   validate_kwdsrD   rD   rF   r   I  sJ   








z'DatetimeArray._from_sequence_not_strictbothr?   periods
int | Noner   nonexistentr8   	inclusiver5   rU   c
                C  s0  t |}|d u rtdd |||fD rtdt||||dkr'tdt|}|d ur3t|}|d ur;t|}|tu sC|tu rGtd|
d urT|
dvrStdnd	}
|d ura|j	|
d
d}|d url|j	|
d
d}t
|	\}}t|||\}}t|||}|d urt|||||}t|||||}|d urt|tr|d ur|d }|d ur|d }t|trt|||||
d}nt|||||
d}tjdd |D tjd}|d ur|jn|j}|d ur|d u rt|st|
}tj|||||d}|d ur||||}|d ur||||}n tt|}tjd|j |j  |dd|j  }|j!dkr5|"d}||krG|sF|sF|dd }n:t|j }t|j }|rW|s|slt#|rl|d |krl|dd  }|st#|r|d |kr|d d }|$d|
 d}t%||
d}| j&|||dS )Nc                 s  s    | ]}|d u V  qd S rC   rD   .0r~   rD   rD   rF   	<genexpr>  s    z0DatetimeArray._generate_range.<locals>.<genexpr>z1Must provide freq argument if no data is supplied   zVOf the four parameters: start, end, periods, and freq, exactly three must be specifiedz$Neither `start` nor `end` can be NaT)smsusrK   z+'unit' must be one of 's', 'ms', 'us', 'ns'rK   F)round_okr   )rV   rW   r   offsetr?   c                 S  s   g | ]}|j qS rD   )_valuer   rD   rD   rF   
<listcomp>  s    z1DatetimeArray._generate_range.<locals>.<listcomp>r   r   r   cresor   int64i8   zdatetime64[rO   r   )'r   validate_periodsanyr   comcount_not_noner   r   r   r   r!   _maybe_normalize_endpoints_infer_tz_from_endpoints_maybe_localize_pointr}   r/   r   r0   r-   _generate_rangerP   arrayr   r>   r   is_utcr   r   tz_localize_to_utcr   intlinspacer   rQ   astypelenviewrG   r   )r   rV   rW   r   rd   r>   r   r   r   r   r?   left_inclusiveright_inclusivei8valuesxdrendpoint_tzr   start_i8end_i8dt64_valuesrQ   rD   rD   rF   r     s   
 














zDatetimeArray._generate_rangenp.datetime64c                 C  sL   t || js|turtd| | |tu rt|j| jS |	| jj
S )Nz'value' should be a Timestamp.)r}   r   r   r   _check_compatible_withrP   r   r   r?   r   asm8rn   valuerD   rD   rF   _unbox_scalar  s   
zDatetimeArray._unbox_scalarTimestamp | NaTTypec                 C  s   t || jdS )Nr>   )r   r>   r  rD   rD   rF   _scalar_from_string  s   z!DatetimeArray._scalar_from_stringrI   c                 C  s   |t u rd S | | d S rC   )r   _assert_tzawareness_compat)rn   otherrD   rD   rF   r    s   z$DatetimeArray._check_compatible_withr~   c                 C  s"   | d}tj|| j| jd}|S )Nr   )r\   r>   )r  r   _from_value_and_resori   r>   )rn   r~   r  tsrD   rD   rF   	_box_func!  s   
zDatetimeArray._box_funcc                 C     | j S )a%  
        The dtype for the DatetimeArray.

        .. warning::

           A future version of pandas will change dtype to never be a
           ``numpy.dtype``. Instead, :attr:`DatetimeArray.dtype` will
           always be an instance of an ``ExtensionDtype`` subclass.

        Returns
        -------
        numpy.dtype or DatetimeTZDtype
            If the values are tz-naive, then ``np.dtype('datetime64[ns]')``
            is returned.

            If the values are tz-aware, then the ``DatetimeTZDtype``
            is returned.
        )r   r   rD   rD   rF   rQ   '  s   zDatetimeArray.dtyperL   c                 C  s   t | jddS )a  
        Return the timezone.

        Returns
        -------
        datetime.tzinfo, pytz.tzinfo.BaseTZInfo, dateutil.tz.tz.tzfile, or None
            Returns None when the array is tz-naive.

        Examples
        --------
        For Series:

        >>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
        >>> s = pd.to_datetime(s)
        >>> s
        0   2020-01-01 10:00:00+00:00
        1   2020-02-01 11:00:00+00:00
        dtype: datetime64[ns, UTC]
        >>> s.dt.tz
        datetime.timezone.utc

        For DatetimeIndex:

        >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
        ...                         "2/1/2020 11:00:00+00:00"])
        >>> idx.tz
        datetime.timezone.utc
        r>   N)getattrrQ   r   rD   rD   rF   r>   @  s   zDatetimeArray.tzc                 C  s   t d)NzNCannot directly set timezone. Use tz_localize() or tz_convert() as appropriate)AttributeErrorr  rD   rD   rF   r>   a  s   c                 C  r  )z(
        Alias for tz attribute
        r  r   rD   rD   rF   r   i  s   zDatetimeArray.tzinfoc                 C     t | j| j| jdS )zN
        Returns True if all of the dates are at midnight ("no time")
        r[   )r   asi8r>   ri   r   rD   rD   rF   is_normalizedp  s   zDatetimeArray.is_normalizedr   c                 C  r   )Nr[   )r   r!  r>   ri   r   rD   rD   rF   _resolution_objw  s   zDatetimeArray._resolution_obj
np.ndarrayc                   s"   |d u r	| j r	t}t j||dS r   )r>   objectr   	__array__)rn   rQ   r   r   rD   rF   r&  ~  s   zDatetimeArray.__array__r1   c           	      c  s    | j dkrtt| D ]}| | V  qdS | j}t| }t}|| d }t|D ]"}|| }t|d | |}t||| | jd| jd}|E dH  q)dS )zt
        Return an iterator over the boxed values

        Yields
        ------
        tstamp : Timestamp
        r   	timestamp)r>   boxr\   N)	ndimranger  r!  _ITER_CHUNKSIZEminr   r>   ri   )	rn   ir   length	chunksizechunksstart_iend_i	convertedrD   rD   rF   __iter__  s(   

zDatetimeArray.__iter__Tc                   sJ  t |}|| jkr|r|  S | S t|trEt|ts#t j||dS | jd u r,t	dt
|j}t| j||d}t| j||| jdS | jd u rjt|drjt|sjt|rjt| j|dd}t| j||jdS | jd uryt|dryt	d| jd u rt|dr|| jkrt|rt	dt|tr| j|jd	S tj| ||S )
Nr   zCannot use .astype to convert from timezone-naive dtype to timezone-aware dtype. Use obj.tz_localize instead or series.dt.tz_localize insteadrQ   rd   r{   Tr   zCannot use .astype to convert from timezone-aware dtype to timezone-naive dtype. Use obj.tz_localize(None) or obj.tz_convert('UTC').tz_localize(None) instead.z]Casting to unit-less dtype 'datetime64' is not supported. Pass e.g. 'datetime64[ns]' instead.)rd   )r'   rQ   r   r}   r)   r(   r   r  r>   	TypeErrorrP   r@   r   _ndarraytyper   rd   r	   r|   r   r   r*   r   r   DatetimeLikeArrayMixin)rn   rQ   r   np_dtype
res_valuesr   rD   rF   r    sP   









zDatetimeArray.astype)na_repdate_formatr=  str | floatnpt.NDArray[np.object_]c                K  s,   |d u r	| j r	d}tj| j| j||| jdS )Nz%Y-%m-%d)r>   formatr=  r\   )_is_dates_onlyr
   format_array_from_datetimer!  r>   ri   )rn   r=  r>  kwargsrD   rD   rF   _format_native_types  s
   z"DatetimeArray._format_native_typesc                 C  s6   t |tjr
t|}t|dsdS |j}t| j|S )Nr   F)r}   rP   r   r   hasattrr   r   
tz_compare)rn   r  other_tzrD   rD   rF   _has_same_tz  s   
zDatetimeArray._has_same_tzc                 C  sh   t |dd }t |dd }t|tr|jj}|tu rd S | jd u r*|d ur(tdd S |d u r2tdd S )Nr   rQ   z;Cannot compare tz-naive and tz-aware datetime-like objects.z:Cannot compare tz-naive and tz-aware datetime-like objects)r  r}   r(   rQ   r>   r   r7  )rn   r  rH  other_dtyperD   rD   rF   r    s"   

z(DatetimeArray._assert_tzawareness_compatr   r   c                 C  s   t |trJ | jd ur| d }n| }z||j}|jjdkr'||j}W n1 t	yY   t
jdtt d | d| }t| || j}t| sV|| j Y S Y |S w t| j||jd}|jrn| }d |_| jd ury|| j}|S )Nr-  zCNon-vectorized DateOffset being applied to Series or DatetimeIndex.
stacklevelOr   )r}   r0   r>   r   _apply_arrayr8  rQ   r   r  NotImplementedErrorwarningswarnr   r    r  r9  r   r   r?   r  r   r   r   )rn   r   ro   r<  rq   rD   rD   rF   _add_offset  s:   

zDatetimeArray._add_offsetnpt.NDArray[np.int64]c                 C  s0   | j du st| j r| jS t| j| j | jdS )z
        Convert to an i8 (unix-like nanosecond timestamp) representation
        while keeping the local timezone and not using UTC.
        This is used to calculate time-of-day information as if the timestamps
        were timezone-naive.
        Nr[   )r>   r   r   r!  r   ri   r   rD   rD   rF   ra   C  s   zDatetimeArray._local_timestampsc                 C  s>   t |}| jdu rtdt|| jd}| j| j|| jdS )a	  
        Convert tz-aware Datetime Array/Index from one time zone to another.

        Parameters
        ----------
        tz : str, pytz.timezone, dateutil.tz.tzfile, datetime.tzinfo or None
            Time zone for time. Corresponding timestamps would be converted
            to this time zone of the Datetime Array/Index. A `tz` of None will
            convert to UTC and remove the timezone information.

        Returns
        -------
        Array or Index

        Raises
        ------
        TypeError
            If Datetime Array/Index is tz-naive.

        See Also
        --------
        DatetimeIndex.tz : A timezone that has a variable offset from UTC.
        DatetimeIndex.tz_localize : Localize tz-naive DatetimeIndex to a
            given time zone, or remove timezone from a tz-aware DatetimeIndex.

        Examples
        --------
        With the `tz` parameter, we can change the DatetimeIndex
        to other time zones:

        >>> dti = pd.date_range(start='2014-08-01 09:00',
        ...                     freq='h', periods=3, tz='Europe/Berlin')

        >>> dti
        DatetimeIndex(['2014-08-01 09:00:00+02:00',
                       '2014-08-01 10:00:00+02:00',
                       '2014-08-01 11:00:00+02:00'],
                      dtype='datetime64[ns, Europe/Berlin]', freq='h')

        >>> dti.tz_convert('US/Central')
        DatetimeIndex(['2014-08-01 02:00:00-05:00',
                       '2014-08-01 03:00:00-05:00',
                       '2014-08-01 04:00:00-05:00'],
                      dtype='datetime64[ns, US/Central]', freq='h')

        With the ``tz=None``, we can remove the timezone (after converting
        to UTC if necessary):

        >>> dti = pd.date_range(start='2014-08-01 09:00', freq='h',
        ...                     periods=3, tz='Europe/Berlin')

        >>> dti
        DatetimeIndex(['2014-08-01 09:00:00+02:00',
                       '2014-08-01 10:00:00+02:00',
                       '2014-08-01 11:00:00+02:00'],
                        dtype='datetime64[ns, Europe/Berlin]', freq='h')

        >>> dti.tz_convert(None)
        DatetimeIndex(['2014-08-01 07:00:00',
                       '2014-08-01 08:00:00',
                       '2014-08-01 09:00:00'],
                        dtype='datetime64[ns]', freq='h')
        Nz?Cannot convert tz-naive timestamps, use tz_localize to localizer   r6  )	r   r   r>   r7  rG   r?   r   r8  rd   )rn   r>   rQ   rD   rD   rF   r   O  s   
@
zDatetimeArray.tz_convertc           	      C  s   d}||vrt |tstd| jdur'|du r#t| j| j| jd}ntdt	|}t
j| j|||| jd}|d| j d}t|| jd	}d}t|s\t| d
kr`t|d s`| j}n|du rl| jdu rl| j}| j|||dS )a  
        Localize tz-naive Datetime Array/Index to tz-aware Datetime Array/Index.

        This method takes a time zone (tz) naive Datetime Array/Index object
        and makes this time zone aware. It does not move the time to another
        time zone.

        This method can also be used to do the inverse -- to create a time
        zone unaware object from an aware object. To that end, pass `tz=None`.

        Parameters
        ----------
        tz : str, pytz.timezone, dateutil.tz.tzfile, datetime.tzinfo or None
            Time zone to convert timestamps to. Passing ``None`` will
            remove the time zone information preserving local time.
        ambiguous : 'infer', 'NaT', bool array, default 'raise'
            When clocks moved backward due to DST, ambiguous times may arise.
            For example in Central European Time (UTC+01), when going from
            03:00 DST to 02:00 non-DST, 02:30:00 local time occurs both at
            00:30:00 UTC and at 01:30:00 UTC. In such a situation, the
            `ambiguous` parameter dictates how ambiguous times should be
            handled.

            - 'infer' will attempt to infer fall dst-transition hours based on
              order
            - bool-ndarray where True signifies a DST time, False signifies 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
        -------
        Same type as self
            Array/Index converted to the specified time zone.

        Raises
        ------
        TypeError
            If the Datetime Array/Index is tz-aware and tz is not None.

        See Also
        --------
        DatetimeIndex.tz_convert : Convert tz-aware DatetimeIndex from
            one time zone to another.

        Examples
        --------
        >>> tz_naive = pd.date_range('2018-03-01 09:00', periods=3)
        >>> tz_naive
        DatetimeIndex(['2018-03-01 09:00:00', '2018-03-02 09:00:00',
                       '2018-03-03 09:00:00'],
                      dtype='datetime64[ns]', freq='D')

        Localize DatetimeIndex in US/Eastern time zone:

        >>> tz_aware = tz_naive.tz_localize(tz='US/Eastern')
        >>> tz_aware
        DatetimeIndex(['2018-03-01 09:00:00-05:00',
                       '2018-03-02 09:00:00-05:00',
                       '2018-03-03 09:00:00-05:00'],
                      dtype='datetime64[ns, US/Eastern]', freq=None)

        With the ``tz=None``, we can remove the time zone information
        while keeping the local time (not converted to UTC):

        >>> tz_aware.tz_localize(None)
        DatetimeIndex(['2018-03-01 09:00:00', '2018-03-02 09:00:00',
                       '2018-03-03 09:00:00'],
                      dtype='datetime64[ns]', freq=None)

        Be careful with DST changes. When there is sequential data, pandas can
        infer the DST time:

        >>> s = pd.to_datetime(pd.Series(['2018-10-28 01:30:00',
        ...                               '2018-10-28 02:00:00',
        ...                               '2018-10-28 02:30:00',
        ...                               '2018-10-28 02:00:00',
        ...                               '2018-10-28 02:30:00',
        ...                               '2018-10-28 03:00:00',
        ...                               '2018-10-28 03:30:00']))
        >>> s.dt.tz_localize('CET', ambiguous='infer')
        0   2018-10-28 01:30:00+02:00
        1   2018-10-28 02:00:00+02:00
        2   2018-10-28 02:30:00+02:00
        3   2018-10-28 02:00:00+01:00
        4   2018-10-28 02:30:00+01:00
        5   2018-10-28 03:00:00+01:00
        6   2018-10-28 03:30:00+01:00
        dtype: datetime64[ns, CET]

        In some cases, inferring the DST is impossible. In such cases, you can
        pass an ndarray to the ambiguous parameter to set the DST explicitly

        >>> s = pd.to_datetime(pd.Series(['2018-10-28 01:20:00',
        ...                               '2018-10-28 02:36:00',
        ...                               '2018-10-28 03:46:00']))
        >>> s.dt.tz_localize('CET', ambiguous=np.array([True, True, False]))
        0   2018-10-28 01:20:00+02:00
        1   2018-10-28 02:36:00+02:00
        2   2018-10-28 03:46:00+01:00
        dtype: datetime64[ns, CET]

        If the DST transition causes nonexistent times, you can shift these
        dates forward or backwards with a timedelta object or `'shift_forward'`
        or `'shift_backwards'`.

        >>> s = pd.to_datetime(pd.Series(['2015-03-29 02:30:00',
        ...                               '2015-03-29 03:30:00']))
        >>> s.dt.tz_localize('Europe/Warsaw', nonexistent='shift_forward')
        0   2015-03-29 03:00:00+02:00
        1   2015-03-29 03:30:00+02:00
        dtype: datetime64[ns, Europe/Warsaw]

        >>> s.dt.tz_localize('Europe/Warsaw', nonexistent='shift_backward')
        0   2015-03-29 01:59:59.999999999+01:00
        1   2015-03-29 03:30:00+02:00
        dtype: datetime64[ns, Europe/Warsaw]

        >>> s.dt.tz_localize('Europe/Warsaw', nonexistent=pd.Timedelta('1h'))
        0   2015-03-29 03:30:00+02:00
        1   2015-03-29 03:30:00+02:00
        dtype: datetime64[ns, Europe/Warsaw]
        )r   r   shift_forwardshift_backwardzoThe nonexistent argument must be one of 'raise', 'NaT', 'shift_forward', 'shift_backward' or a timedelta objectNr[   z,Already tz-aware, use tz_convert to convert.r   rN   rO   r   r   r   r6  )r}   r   r   r>   r   r!  ri   r7  r   r   r   r  r  r?   rG   r   r  r+   rd   r   )	rn   r>   r   r   nonexistent_options	new_datesnew_dates_dt64rQ   rd   rD   rD   rF   r     s8    


"zDatetimeArray.tz_localizec                 C  r   )a  
        Return an ndarray of ``datetime.datetime`` objects.

        Returns
        -------
        numpy.ndarray

        Examples
        --------
        >>> idx = pd.date_range('2018-02-27', periods=3)
        >>> idx.to_pydatetime()
        array([datetime.datetime(2018, 2, 27, 0, 0),
               datetime.datetime(2018, 2, 28, 0, 0),
               datetime.datetime(2018, 3, 1, 0, 0)], dtype=object)
        )r>   r\   r   r!  r>   ri   r   rD   rD   rF   to_pydatetimeW  s   zDatetimeArray.to_pydatetimec                 C  sZ   t | j| j| jd}|| jj}t| j||jd}|	d}| jdur+|
| j}|S )a  
        Convert times to midnight.

        The time component of the date-time is converted to midnight i.e.
        00:00:00. This is useful in cases, when the time does not matter.
        Length is unaltered. The timezones are unaffected.

        This method is available on Series with datetime values under
        the ``.dt`` accessor, and directly on Datetime Array/Index.

        Returns
        -------
        DatetimeArray, DatetimeIndex or Series
            The same type as the original data. Series will have the same
            name and index. DatetimeIndex will have the same name.

        See Also
        --------
        floor : Floor the datetimes to the specified freq.
        ceil : Ceil the datetimes to the specified freq.
        round : Round the datetimes to the specified freq.

        Examples
        --------
        >>> idx = pd.date_range(start='2014-08-01 10:00', freq='h',
        ...                     periods=3, tz='Asia/Calcutta')
        >>> idx
        DatetimeIndex(['2014-08-01 10:00:00+05:30',
                       '2014-08-01 11:00:00+05:30',
                       '2014-08-01 12:00:00+05:30'],
                        dtype='datetime64[ns, Asia/Calcutta]', freq='h')
        >>> idx.normalize()
        DatetimeIndex(['2014-08-01 00:00:00+05:30',
                       '2014-08-01 00:00:00+05:30',
                       '2014-08-01 00:00:00+05:30'],
                       dtype='datetime64[ns, Asia/Calcutta]', freq=None)
        r[   r   inferN)r   r!  r>   ri   r  r8  rQ   r9  r   
_with_freqr   )rn   
new_valuesr  dtarD   rD   rF   r   i  s   &

zDatetimeArray.normalizer=   c                 C  s   ddl m} | jdurtjdtt d |du rD| jp| j}t	| j
tr0t| j
dr0t| j
j}|du r8tdt|}|du rB|}|}|j| j|| jdS )	a  
        Cast to PeriodArray/PeriodIndex at a particular frequency.

        Converts DatetimeArray/Index to PeriodArray/PeriodIndex.

        Parameters
        ----------
        freq : str or Period, optional
            One of pandas' :ref:`period aliases <timeseries.period_aliases>`
            or an Period object. Will be inferred by default.

        Returns
        -------
        PeriodArray/PeriodIndex

        Raises
        ------
        ValueError
            When converting a DatetimeArray/Index with non-regular values,
            so that a frequency cannot be inferred.

        See Also
        --------
        PeriodIndex: Immutable ndarray holding ordinal values.
        DatetimeIndex.to_pydatetime: Return DatetimeIndex as object.

        Examples
        --------
        >>> df = pd.DataFrame({"y": [1, 2, 3]},
        ...                   index=pd.to_datetime(["2000-03-31 00:00:00",
        ...                                         "2000-05-31 00:00:00",
        ...                                         "2000-08-31 00:00:00"]))
        >>> df.index.to_period("M")
        PeriodIndex(['2000-03', '2000-05', '2000-08'],
                    dtype='period[M]')

        Infer the daily frequency

        >>> idx = pd.date_range("2017-01-01", periods=2)
        >>> idx.to_period()
        PeriodIndex(['2017-01-01', '2017-01-02'],
                    dtype='period[D]')
        r   r<   NzNConverting to PeriodArray/Index representation will drop timezone information.rK  _period_dtype_codez8You must pass a freq argument as current index has none.r  )pandas.core.arraysr=   r>   rP  rQ  UserWarningr    rh   r   r}   rd   r   rF  r*   _freqstrr   r.   _from_datetime64r8  )rn   rd   r=   resrD   rD   rF   r     s,   ,
zDatetimeArray.to_periodc                 C  .   |   }tj|d|| jd}| j|dd}|S )u  
        Return the month names with specified locale.

        Parameters
        ----------
        locale : str, optional
            Locale determining the language in which to return the month name.
            Default is English locale (``'en_US.utf8'``). Use the command
            ``locale -a`` on your terminal on Unix systems to find your locale
            language code.

        Returns
        -------
        Series or Index
            Series or Index of month names.

        Examples
        --------
        >>> s = pd.Series(pd.date_range(start='2018-01', freq='ME', periods=3))
        >>> s
        0   2018-01-31
        1   2018-02-28
        2   2018-03-31
        dtype: datetime64[ns]
        >>> s.dt.month_name()
        0     January
        1    February
        2       March
        dtype: object

        >>> idx = pd.date_range(start='2018-01', freq='ME', periods=3)
        >>> idx
        DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
                      dtype='datetime64[ns]', freq='ME')
        >>> idx.month_name()
        Index(['January', 'February', 'March'], dtype='object')

        Using the ``locale`` parameter you can set a different locale language,
        for example: ``idx.month_name(locale='pt_BR.utf8')`` will return month
        names in Brazilian Portuguese language.

        >>> idx = pd.date_range(start='2018-01', freq='ME', periods=3)
        >>> idx
        DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
                      dtype='datetime64[ns]', freq='ME')
        >>> idx.month_name(locale='pt_BR.utf8')  # doctest: +SKIP
        Index(['Janeiro', 'Fevereiro', 'Março'], dtype='object')
        r   localer\   Nr]   ra   r   rl   ri   rm   rn   rg  ro   rq   rD   rD   rF   r        1
zDatetimeArray.month_namec                 C  re  )u  
        Return the day names with specified locale.

        Parameters
        ----------
        locale : str, optional
            Locale determining the language in which to return the day name.
            Default is English locale (``'en_US.utf8'``). Use the command
            ``locale -a`` on your terminal on Unix systems to find your locale
            language code.

        Returns
        -------
        Series or Index
            Series or Index of day names.

        Examples
        --------
        >>> s = pd.Series(pd.date_range(start='2018-01-01', freq='D', periods=3))
        >>> s
        0   2018-01-01
        1   2018-01-02
        2   2018-01-03
        dtype: datetime64[ns]
        >>> s.dt.day_name()
        0       Monday
        1      Tuesday
        2    Wednesday
        dtype: object

        >>> idx = pd.date_range(start='2018-01-01', freq='D', periods=3)
        >>> idx
        DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
                      dtype='datetime64[ns]', freq='D')
        >>> idx.day_name()
        Index(['Monday', 'Tuesday', 'Wednesday'], dtype='object')

        Using the ``locale`` parameter you can set a different locale language,
        for example: ``idx.day_name(locale='pt_BR.utf8')`` will return day
        names in Brazilian Portuguese language.

        >>> idx = pd.date_range(start='2018-01-01', freq='D', periods=3)
        >>> idx
        DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
                      dtype='datetime64[ns]', freq='D')
        >>> idx.day_name(locale='pt_BR.utf8') # doctest: +SKIP
        Index(['Segunda', 'Terça', 'Quarta'], dtype='object')
        r   rf  Nr]   rh  ri  rD   rD   rF   r     rj  zDatetimeArray.day_namec                 C     |   }t|d| jdS )a  
        Returns numpy array of :class:`datetime.time` objects.

        The time part of the Timestamps.

        Examples
        --------
        For Series:

        >>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
        >>> s = pd.to_datetime(s)
        >>> s
        0   2020-01-01 10:00:00+00:00
        1   2020-02-01 11:00:00+00:00
        dtype: datetime64[ns, UTC]
        >>> s.dt.time
        0    10:00:00
        1    11:00:00
        dtype: object

        For DatetimeIndex:

        >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
        ...                         "2/1/2020 11:00:00+00:00"])
        >>> idx.time
        array([datetime.time(10, 0), datetime.time(11, 0)], dtype=object)
        r   r(  r\   ra   r   ri   rn   
timestampsrD   rD   rF   r   X  s    zDatetimeArray.timec                 C  s   t | j| jd| jdS )aQ  
        Returns numpy array of :class:`datetime.time` objects with timezones.

        The time part of the Timestamps.

        Examples
        --------
        For Series:

        >>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
        >>> s = pd.to_datetime(s)
        >>> s
        0   2020-01-01 10:00:00+00:00
        1   2020-02-01 11:00:00+00:00
        dtype: datetime64[ns, UTC]
        >>> s.dt.timetz
        0    10:00:00+00:00
        1    11:00:00+00:00
        dtype: object

        For DatetimeIndex:

        >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
        ...                         "2/1/2020 11:00:00+00:00"])
        >>> idx.timetz
        array([datetime.time(10, 0, tzinfo=datetime.timezone.utc),
        datetime.time(11, 0, tzinfo=datetime.timezone.utc)], dtype=object)
        r   rl  rY  r   rD   rD   rF   r   |  s   zDatetimeArray.timetzc                 C  rk  )a5  
        Returns numpy array of python :class:`datetime.date` objects.

        Namely, the date part of Timestamps without time and
        timezone information.

        Examples
        --------
        For Series:

        >>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
        >>> s = pd.to_datetime(s)
        >>> s
        0   2020-01-01 10:00:00+00:00
        1   2020-02-01 11:00:00+00:00
        dtype: datetime64[ns, UTC]
        >>> s.dt.date
        0    2020-01-01
        1    2020-02-01
        dtype: object

        For DatetimeIndex:

        >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
        ...                         "2/1/2020 11:00:00+00:00"])
        >>> idx.date
        array([datetime.date(2020, 1, 1), datetime.date(2020, 2, 1)], dtype=object)
        r   rl  rm  rn  rD   rD   rF   r     s   !zDatetimeArray.dater;   c                 C  sL   ddl m} |  }tj|| jd}||g ddd}| jr$d|j| j< |S )a  
        Calculate year, week, and day according to the ISO 8601 standard.

        Returns
        -------
        DataFrame
            With columns year, week and day.

        See Also
        --------
        Timestamp.isocalendar : Function return a 3-tuple containing ISO year,
            week number, and weekday for the given Timestamp object.
        datetime.date.isocalendar : Return a named tuple object with
            three components: year, week and weekday.

        Examples
        --------
        >>> idx = pd.date_range(start='2019-12-29', freq='D', periods=4)
        >>> idx.isocalendar()
                    year  week  day
        2019-12-29  2019    52    7
        2019-12-30  2020     1    1
        2019-12-31  2020     1    2
        2020-01-01  2020     1    3
        >>> idx.isocalendar().week
        2019-12-29    52
        2019-12-30     1
        2019-12-31     1
        2020-01-01     1
        Freq: D, Name: week, dtype: UInt32
        r   r:   r[   )r   weekr   UInt32)columnsrQ   N)	pandasr;   ra   r   build_isocalendar_sarrayri   _hasnailoc_isnan)rn   r;   ro   sarrayiso_calendar_dfrD   rD   rF   isocalendar  s    
zDatetimeArray.isocalendarr   Ya  
        The year of the datetime.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="YE")
        ... )
        >>> datetime_series
        0   2000-12-31
        1   2001-12-31
        2   2002-12-31
        dtype: datetime64[ns]
        >>> datetime_series.dt.year
        0    2000
        1    2001
        2    2002
        dtype: int32
        rZ   r{   a  
        The month as January=1, December=12.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="ME")
        ... )
        >>> datetime_series
        0   2000-01-31
        1   2000-02-29
        2   2000-03-31
        dtype: datetime64[ns]
        >>> datetime_series.dt.month
        0    1
        1    2
        2    3
        dtype: int32
        r   Da  
        The day of the datetime.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="D")
        ... )
        >>> datetime_series
        0   2000-01-01
        1   2000-01-02
        2   2000-01-03
        dtype: datetime64[ns]
        >>> datetime_series.dt.day
        0    1
        1    2
        2    3
        dtype: int32
        r   ha  
        The hours of the datetime.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="h")
        ... )
        >>> datetime_series
        0   2000-01-01 00:00:00
        1   2000-01-01 01:00:00
        2   2000-01-01 02:00:00
        dtype: datetime64[ns]
        >>> datetime_series.dt.hour
        0    0
        1    1
        2    2
        dtype: int32
        r   ma  
        The minutes of the datetime.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="min")
        ... )
        >>> datetime_series
        0   2000-01-01 00:00:00
        1   2000-01-01 00:01:00
        2   2000-01-01 00:02:00
        dtype: datetime64[ns]
        >>> datetime_series.dt.minute
        0    0
        1    1
        2    2
        dtype: int32
        r   r   a  
        The seconds of the datetime.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="s")
        ... )
        >>> datetime_series
        0   2000-01-01 00:00:00
        1   2000-01-01 00:00:01
        2   2000-01-01 00:00:02
        dtype: datetime64[ns]
        >>> datetime_series.dt.second
        0    0
        1    1
        2    2
        dtype: int32
        r   r   a  
        The microseconds of the datetime.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="us")
        ... )
        >>> datetime_series
        0   2000-01-01 00:00:00.000000
        1   2000-01-01 00:00:00.000001
        2   2000-01-01 00:00:00.000002
        dtype: datetime64[ns]
        >>> datetime_series.dt.microsecond
        0       0
        1       1
        2       2
        dtype: int32
        r   a  
        The nanoseconds of the datetime.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="ns")
        ... )
        >>> datetime_series
        0   2000-01-01 00:00:00.000000000
        1   2000-01-01 00:00:00.000000001
        2   2000-01-01 00:00:00.000000002
        dtype: datetime64[ns]
        >>> datetime_series.dt.nanosecond
        0       0
        1       1
        2       2
        dtype: int32
        a  
    The day of the week with Monday=0, Sunday=6.

    Return the day of the week. It is assumed the week starts on
    Monday, which is denoted by 0 and ends on Sunday which is denoted
    by 6. This method is available on both Series with datetime
    values (using the `dt` accessor) or DatetimeIndex.

    Returns
    -------
    Series or Index
        Containing integers indicating the day number.

    See Also
    --------
    Series.dt.dayofweek : Alias.
    Series.dt.weekday : Alias.
    Series.dt.day_name : Returns the name of the day of the week.

    Examples
    --------
    >>> s = pd.date_range('2016-12-31', '2017-01-08', freq='D').to_series()
    >>> s.dt.dayofweek
    2016-12-31    5
    2017-01-01    6
    2017-01-02    0
    2017-01-03    1
    2017-01-04    2
    2017-01-05    3
    2017-01-06    4
    2017-01-07    5
    2017-01-08    6
    Freq: D, dtype: int32
    r   dowr   doya  
        The ordinal day of the year.

        Examples
        --------
        For Series:

        >>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
        >>> s = pd.to_datetime(s)
        >>> s
        0   2020-01-01 10:00:00+00:00
        1   2020-02-01 11:00:00+00:00
        dtype: datetime64[ns, UTC]
        >>> s.dt.dayofyear
        0    1
        1   32
        dtype: int32

        For DatetimeIndex:

        >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
        ...                         "2/1/2020 11:00:00+00:00"])
        >>> idx.dayofyear
        Index([1, 32], dtype='int32')
        r   qax  
        The quarter of the date.

        Examples
        --------
        For Series:

        >>> s = pd.Series(["1/1/2020 10:00:00+00:00", "4/1/2020 11:00:00+00:00"])
        >>> s = pd.to_datetime(s)
        >>> s
        0   2020-01-01 10:00:00+00:00
        1   2020-04-01 11:00:00+00:00
        dtype: datetime64[ns, UTC]
        >>> s.dt.quarter
        0    1
        1    2
        dtype: int32

        For DatetimeIndex:

        >>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00",
        ...                         "2/1/2020 11:00:00+00:00"])
        >>> idx.quarter
        Index([1, 1], dtype='int32')
        r   dima  
        The number of days in the month.

        Examples
        --------
        >>> s = pd.Series(["1/1/2020 10:00:00+00:00", "2/1/2020 11:00:00+00:00"])
        >>> s = pd.to_datetime(s)
        >>> s
        0   2020-01-01 10:00:00+00:00
        1   2020-02-01 11:00:00+00:00
        dtype: datetime64[ns, UTC]
        >>> s.dt.daysinmonth
        0    31
        1    29
        dtype: int32
        a  
        Indicates whether the date is the {first_or_last} day of the month.

        Returns
        -------
        Series or array
            For Series, returns a Series with boolean values.
            For DatetimeIndex, returns a boolean array.

        See Also
        --------
        is_month_start : Return a boolean indicating whether the date
            is the first day of the month.
        is_month_end : Return a boolean indicating whether the date
            is the last day of the month.

        Examples
        --------
        This method is available on Series with datetime values under
        the ``.dt`` accessor, and directly on DatetimeIndex.

        >>> s = pd.Series(pd.date_range("2018-02-27", periods=3))
        >>> s
        0   2018-02-27
        1   2018-02-28
        2   2018-03-01
        dtype: datetime64[ns]
        >>> s.dt.is_month_start
        0    False
        1    False
        2    True
        dtype: bool
        >>> s.dt.is_month_end
        0    False
        1    True
        2    False
        dtype: bool

        >>> idx = pd.date_range("2018-02-27", periods=3)
        >>> idx.is_month_start
        array([False, False, True])
        >>> idx.is_month_end
        array([False, True, False])
    r   first)first_or_lastr   lastr   a  
        Indicator for whether the date is the first day of a quarter.

        Returns
        -------
        is_quarter_start : Series or DatetimeIndex
            The same type as the original data with boolean values. Series will
            have the same name and index. DatetimeIndex will have the same
            name.

        See Also
        --------
        quarter : Return the quarter of the date.
        is_quarter_end : Similar property for indicating the quarter end.

        Examples
        --------
        This method is available on Series with datetime values under
        the ``.dt`` accessor, and directly on DatetimeIndex.

        >>> df = pd.DataFrame({'dates': pd.date_range("2017-03-30",
        ...                   periods=4)})
        >>> df.assign(quarter=df.dates.dt.quarter,
        ...           is_quarter_start=df.dates.dt.is_quarter_start)
               dates  quarter  is_quarter_start
        0 2017-03-30        1             False
        1 2017-03-31        1             False
        2 2017-04-01        2              True
        3 2017-04-02        2             False

        >>> idx = pd.date_range('2017-03-30', periods=4)
        >>> idx
        DatetimeIndex(['2017-03-30', '2017-03-31', '2017-04-01', '2017-04-02'],
                      dtype='datetime64[ns]', freq='D')

        >>> idx.is_quarter_start
        array([False, False,  True, False])
        r   a  
        Indicator for whether the date is the last day of a quarter.

        Returns
        -------
        is_quarter_end : Series or DatetimeIndex
            The same type as the original data with boolean values. Series will
            have the same name and index. DatetimeIndex will have the same
            name.

        See Also
        --------
        quarter : Return the quarter of the date.
        is_quarter_start : Similar property indicating the quarter start.

        Examples
        --------
        This method is available on Series with datetime values under
        the ``.dt`` accessor, and directly on DatetimeIndex.

        >>> df = pd.DataFrame({'dates': pd.date_range("2017-03-30",
        ...                    periods=4)})
        >>> df.assign(quarter=df.dates.dt.quarter,
        ...           is_quarter_end=df.dates.dt.is_quarter_end)
               dates  quarter    is_quarter_end
        0 2017-03-30        1             False
        1 2017-03-31        1              True
        2 2017-04-01        2             False
        3 2017-04-02        2             False

        >>> idx = pd.date_range('2017-03-30', periods=4)
        >>> idx
        DatetimeIndex(['2017-03-30', '2017-03-31', '2017-04-01', '2017-04-02'],
                      dtype='datetime64[ns]', freq='D')

        >>> idx.is_quarter_end
        array([False,  True, False, False])
        r   a~  
        Indicate whether the date is the first day of a year.

        Returns
        -------
        Series or DatetimeIndex
            The same type as the original data with boolean values. Series will
            have the same name and index. DatetimeIndex will have the same
            name.

        See Also
        --------
        is_year_end : Similar property indicating the last day of the year.

        Examples
        --------
        This method is available on Series with datetime values under
        the ``.dt`` accessor, and directly on DatetimeIndex.

        >>> dates = pd.Series(pd.date_range("2017-12-30", periods=3))
        >>> dates
        0   2017-12-30
        1   2017-12-31
        2   2018-01-01
        dtype: datetime64[ns]

        >>> dates.dt.is_year_start
        0    False
        1    False
        2    True
        dtype: bool

        >>> idx = pd.date_range("2017-12-30", periods=3)
        >>> idx
        DatetimeIndex(['2017-12-30', '2017-12-31', '2018-01-01'],
                      dtype='datetime64[ns]', freq='D')

        >>> idx.is_year_start
        array([False, False,  True])
        r   a{  
        Indicate whether the date is the last day of the year.

        Returns
        -------
        Series or DatetimeIndex
            The same type as the original data with boolean values. Series will
            have the same name and index. DatetimeIndex will have the same
            name.

        See Also
        --------
        is_year_start : Similar property indicating the start of the year.

        Examples
        --------
        This method is available on Series with datetime values under
        the ``.dt`` accessor, and directly on DatetimeIndex.

        >>> dates = pd.Series(pd.date_range("2017-12-30", periods=3))
        >>> dates
        0   2017-12-30
        1   2017-12-31
        2   2018-01-01
        dtype: datetime64[ns]

        >>> dates.dt.is_year_end
        0    False
        1     True
        2    False
        dtype: bool

        >>> idx = pd.date_range("2017-12-30", periods=3)
        >>> idx
        DatetimeIndex(['2017-12-30', '2017-12-31', '2018-01-01'],
                      dtype='datetime64[ns]', freq='D')

        >>> idx.is_year_end
        array([False,  True, False])
        r   a  
        Boolean indicator if the date belongs to a leap year.

        A leap year is a year, which has 366 days (instead of 365) including
        29th of February as an intercalary day.
        Leap years are years which are multiples of four with the exception
        of years divisible by 100 but not by 400.

        Returns
        -------
        Series or ndarray
             Booleans indicating if dates belong to a leap year.

        Examples
        --------
        This method is available on Series with datetime values under
        the ``.dt`` accessor, and directly on DatetimeIndex.

        >>> idx = pd.date_range("2012-01-01", "2015-01-01", freq="YE")
        >>> idx
        DatetimeIndex(['2012-12-31', '2013-12-31', '2014-12-31'],
                      dtype='datetime64[ns]', freq='YE-DEC')
        >>> idx.is_leap_year
        array([ True, False, False])

        >>> dates_series = pd.Series(idx)
        >>> dates_series
        0   2012-12-31
        1   2013-12-31
        2   2014-12-31
        dtype: datetime64[ns]
        >>> dates_series.dt.is_leap_year
        0     True
        1    False
        2    False
        dtype: bool
        npt.NDArray[np.float64]c                 C  s   t | j}t | j}t | j}|dk }||  d8  < ||  d7  < |t d| d d  d|  t |d  t |d	  t |d
  d | j| jd  | j	d  | j
d d  | jd d  d  S )z
        Convert Datetime Array to float64 ndarray of Julian Dates.
        0 Julian date is noon January 1, 4713 BC.
        https://en.wikipedia.org/wiki/Julian_day
        r   r   rX      i     im     d   i  g   C:A<   i  i@B i ʚ;   )rP   asarrayr   rZ   r   fixr   r   r   r   r   r   )rn   r   rZ   r   testarrrD   rD   rF   to_julian_date$  s@   zDatetimeArray.to_julian_dater   ddofr  keepdimsr   c           
      C  sR   ddl m} | jjjdd}t|}|j| j||d}	|	j	|||||dS )a  
        Return sample standard deviation over requested axis.

        Normalized by `N-1` by default. This can be changed using ``ddof``.

        Parameters
        ----------
        axis : int, optional
            Axis for the function to be applied on. For :class:`pandas.Series`
            this parameter is unused and defaults to ``None``.
        ddof : int, default 1
            Degrees of Freedom. The divisor used in calculations is `N - ddof`,
            where `N` represents the number of elements.
        skipna : bool, default True
            Exclude NA/null values. If an entire row/column is ``NA``, the result
            will be ``NA``.

        Returns
        -------
        Timedelta

        See Also
        --------
        numpy.ndarray.std : Returns the standard deviation of the array elements
            along given axis.
        Series.std : Return sample standard deviation over requested axis.

        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.std()
        Timedelta('1 days 00:00:00')
        r   )TimedeltaArrayr   timedelta64r   )axisoutr  r  r   )
r`  r  r8  rQ   rR   replacerP   r   r  std)
rn   r  rQ   r  r  r  r   r  	dtype_strtdarD   rD   rF   r  G  s
   2
zDatetimeArray.std)rA   r   )rQ   r4   rA   r6   )ro   r   rd   r   rQ   rM   rA   r6   )r   r   )r   r   rd   r   r   r   r   r   r   r7   rA   r6   )NFr   r   r   )r   r   r   r   r   r7   r   r8   r   r5   r?   rU   rA   r6   )rA   r  )rA   r  )rA   rI   )r~   r  rA   r  )rA   rM   )rA   rL   )rA   r   )rA   r   )NN)rA   r$  )rA   r1   )T)r=  r?  rA   r@  )r   r   rA   r6   )rA   rS  )rA   r6   )r   r   )r   r7   r   r8   rA   r6   )rA   r@  rC   )rA   r=   )rA   r;   )rA   r  )NNNr   FT)r  r  r  r   r   r   )_rt   
__module____qualname__ru   _typrP   r   _internal_fill_valuer   _recognized_scalars_is_recognized_dtype_infer_matchesrv   r   rb   __annotations__rk   r   r   r   r   __array_priority__r   r"   _default_dtypeclassmethodr   r   r   r   r	   r   r   r   r  r  r  r  rQ   r>   setterr   r"  r#  r&  r4  r  rE  rI  r  rR  ra   r   r   ravel_compatr   rZ  r   r   r   r   r   r   r   rz  rw   r   rZ   r   r   r   r   r   r   _dayofweek_docr   r   r   r   r   r   r   r   _is_month_docrA  r   r   r   r   r   r   r   r  r  __classcell__rD   rD   r   rF   rx      s  
 *
	

C

	

 

G



*
L 
<
/N99#
$+",**,,
*%rx   Fr   r   r   r2   r   r   r   r   r   r7   r   c                C  s  t | ||d\} }t| dd}|du rd}td| d}|tks&t|rttj| } d}tj	| ddd	kr>| 
tj} nP|dur]|d
kr]tj| td}	tj|	|||t|d}
|
|fS t| ||d|pedd\}}d}|rv|rv|}
|
|fS |r|}|}
|
|fS t||||d\}
}|
|fS | j}t|trtt| } t|| j}| j}
n9t|drt| tr| j} ttj| } t| |||d\}
}n| jtkr| j
tjdd} d}ttj| } | |}
|r|
 }
t|
tjsJ t|
|
jjdksJ |
jdksJ t|
jsJ |
|fS )aQ  
    Parameters
    ----------
    data : np.ndarray or ExtensionArray
        dtl.ensure_arraylike_for_datetimelike has already been called.
    copy : bool, default False
    tz : tzinfo or None, default None
    dayfirst : bool, default False
    yearfirst : bool, default False
    ambiguous : str, bool, or arraylike, default 'raise'
        See pandas._libs.tslibs.tzconversion.tz_localize_to_utc.
    out_unit : str or None, default None
        Desired output resolution.

    Returns
    -------
    result : numpy.ndarray
        The sequence converted to a numpy array with dtype ``datetime64[unit]``.
        Where `unit` is "ns" unless specified otherwise by `out_unit`.
    tz : tzinfo or None
        Either the user-provided tzinfo or one inferred from the data.

    Raises
    ------
    TypeError : PeriodDType data is passed
    r  rQ   NrK   rN   rO   Fr   integerr   r   )r>   r   r   r   )r   r   allow_objectr   )r>   r   r   r{   r5  M8)maybe_convert_dtyper  rP   rQ   r%  r&   r   r   r	   r   r  r   r  r
   array_to_datetime_with_tzr   objects_to_datetime64_construct_from_dt64_naiver}   r(   rx   _maybe_infer_tzr>   r8  r|   r#   r  r   r9  r   r   )r   r   r>   r   r   r   r   r   	out_dtypeobj_datarq   r3  inferred_tz_rD   rD   rF   r     s~   &







r   r$  tuple[np.ndarray, bool]c                C  s   | j }t|st|}t| |dd} d}| j jdkr(| | j d} | j }d}|durR| j}| jdkr8| 	 } t
|}tj| d|||d} | |} | |} | j |ks\J | j | }||fS )	zP
    Convert datetime64 data to a supported dtype, localizing if necessary.
    Fr   ><Nr   r   )r   r   )rQ   r   r   r   	byteorderr  newbyteordershaper)  ravelr   r   r  r  reshape)r   r>   r   r   	new_dtyper  r   rq   rD   rD   rF   r  	  s,   	


r  utcerrorsr3   r  c           	      C  s   |dv sJ t j| t jd} tj| ||||t|d\}}|dur%||fS |jjdkr/||fS |jtkr>|r:||fS t	dt	|)a|  
    Convert data to array of timestamps.

    Parameters
    ----------
    data : np.ndarray[object]
    dayfirst : bool
    yearfirst : bool
    utc : bool, default False
        Whether to convert/localize timestamps to UTC.
    errors : {'raise', 'ignore', 'coerce'}
    allow_object : bool
        Whether to return an object-dtype ndarray instead of raising if the
        data contains more than one timezone.
    out_unit : str, default "ns"

    Returns
    -------
    result : ndarray
        np.datetime64[out_unit] if returned values represent wall times or UTC
        timestamps.
        object if mixed timezones
    inferred_tz : tzinfo or None
        If not None, then the datetime64 values in `result` denote UTC timestamps.

    Raises
    ------
    ValueError : if data cannot be converted to datetimes
    TypeError  : When a type cannot be converted to datetime
    )r   ignorecoercer   )r  r  r   r   r   Nr{   z!DatetimeIndex has mixed timezones)
rP   r  object_r
   array_to_datetimer   rQ   r   r%  r7  )	r   r   r   r  r  r  r   rq   	tz_parsedrD   rD   rF   r  2	  s&   '
	
r  c                 C  s   t | ds	| |fS t| jr| td} d}| |fS t| jds(t| jr1t	d| j dt
| jtr;t	dt
| jtrQt
| jtsQtj| tjd} d}| |fS )	a\  
    Convert data based on dtype conventions, issuing
    errors where appropriate.

    Parameters
    ----------
    data : np.ndarray or pd.Index
    copy : bool
    tz : tzinfo or None, default None

    Returns
    -------
    data : np.ndarray or pd.Index
    copy : bool

    Raises
    ------
    TypeError : PeriodDType data is passed
    rQ   r   Fr~  zdtype z& cannot be converted to datetime64[ns]zFPassing PeriodDtype data is invalid. Use `data.to_timestamp()` insteadr   )rF  r%   rQ   r  r"   r  r	   r|   r$   r7  r}   r*   r)   r(   rP   r   r  )r   r   r>   rD   rD   rF   r  |	  s$   

r  r  c                 C  sB   | du r|} | S |du r	 | S t | |std| d|  | S )aV  
    If a timezone is inferred from data, check that it is compatible with
    the user-provided timezone, if any.

    Parameters
    ----------
    tz : tzinfo or None
    inferred_tz : tzinfo or None

    Returns
    -------
    tz : tzinfo or None

    Raises
    ------
    TypeError : if both timezones are present but do not match
    Nzdata is already tz-aware z, unable to set specified tz: )r   rG  r7  )r>   r  rD   rD   rF   r  	  s   r  c                 C  s   | durJt | } | tdkrd}t|t| tjr$| jdks,t| r,t| tjtfs4td|  dt| ddrJt	t| } t| j
t| jd} | S )	a  
    Check that a dtype, if passed, represents either a numpy datetime64[ns]
    dtype or a pandas DatetimeTZDtype.

    Parameters
    ----------
    dtype : object

    Returns
    -------
    dtype : None, numpy.dtype, or DatetimeTZDtype

    Raises
    ------
    ValueError : invalid dtype

    Notes
    -----
    Unlike _validate_tz_from_dtype, this does _not_ allow non-existent
    tz errors to go through
    Nr  zhPassing in 'datetime64' dtype with no precision is not allowed. Please pass in 'datetime64[ns]' instead.r{   zUnexpected value for 'dtype': 'ze'. Must be 'datetime64[s]', 'datetime64[ms]', 'datetime64[us]', 'datetime64[ns]' or DatetimeTZDtype'.r>   )r?   r>   )r'   rP   rQ   r   r}   r   r   r(   r  r   r?   r   tz_standardizer>   )rQ   msgrD   rD   rF   r   	  s(   


r   r   c                 C  s   | durRt | trzt| } W n	 ty   Y nw t| dd}|dur:|dur2t||s2td|r8td|}|durRt	
| drR|durRt||sRtd|S )a  
    If the given dtype is a DatetimeTZDtype, extract the implied
    tzinfo object from it and check that it does not conflict with the given
    tz.

    Parameters
    ----------
    dtype : dtype, str
    tz : None, tzinfo
    explicit_tz_none : bool, default False
        Whether tz=None was passed explicitly, as opposed to lib.no_default.

    Returns
    -------
    tz : consensus tzinfo

    Raises
    ------
    ValueError : on tzinfo mismatch
    Nr>   z-cannot supply both a tz and a dtype with a tzz3Cannot pass both a timezone-aware dtype and tz=Noner{   zHcannot supply both a tz and a timezone-naive dtype (i.e. datetime64[ns]))r}   r@   r(   construct_from_stringr7  r  r   rG  r   r	   r|   )rQ   r>   r   dtzrD   rD   rF   r   

  s(   
r   rV   r   rW   c              
   C  s   zt | |}W n ty } ztd|d}~ww t |}t |}|dur8|dur8t ||s6td|S |dur>|}|S )a  
    If a timezone is not explicitly given via `tz`, see if one can
    be inferred from the `start` and `end` endpoints.  If more than one
    of these inputs provides a timezone, require that they all agree.

    Parameters
    ----------
    start : Timestamp
    end : Timestamp
    tz : tzinfo or None

    Returns
    -------
    tz : tzinfo or None

    Raises
    ------
    TypeError : if start and end timezones do not agree
    z>Start and end cannot both be tz-aware with different timezonesNz0Inferred time zone not equal to passed time zone)r   infer_tzinfoAssertionErrorr7  r   rG  )rV   rW   r>   r  errrD   rD   rF   r   ?
  s&   

r   Timestamp | Noner   c                 C  s,   |r| d ur
|   } |d ur|  }| |fS rC   )r   )rV   rW   r   rD   rD   rF   r   j
  s   r   r  c                 C  s\   | dur,| j du r,|dkr|nd}||dd}t|ts |du r$||d< | jdi |} | S )a  
    Localize a start or end Timestamp to the timezone of the corresponding
    start or end Timestamp

    Parameters
    ----------
    ts : start or end Timestamp to potentially localize
    freq : Tick, DateOffset, or None
    tz : str, timezone object or None
    ambiguous: str, localization behavior for ambiguous times
    nonexistent: str, localization behavior for nonexistent times

    Returns
    -------
    ts : Timestamp
    Nr[  F)r   r   r>   r>   rD   )r   r}   r0   r   )r  rd   r>   r   r   localize_argsrD   rD   rF   r   w
  s   r   r   r   r   r   c                c  s   t |}t| } | tur| |} nd} t|}|tur#||}nd}| r2|| s2|| } n|r>||s>||}|du rO|| k rO|jdkrOd}d}|du r[| |d |  }| du rg||d |  } tt| } tt|}| }|jdkr||kr|V  ||krdS |	|}||}||krt
d| d|}||ks|dS dS ||kr|V  ||krdS |	|}||}||krt
d| d|}||ksdS dS )a  
    Generates a sequence of dates corresponding to the specified time
    offset. Similar to dateutil.rrule except uses pandas DateOffset
    objects to represent time increments.

    Parameters
    ----------
    start : Timestamp or None
    end : Timestamp or None
    periods : int or None
    offset : DateOffset
    unit : str

    Notes
    -----
    * This method is faster for generating weekdays than dateutil.rrule
    * At least two of (start, end, periods) must be specified.
    * If both start and end are specified, the returned dates will
    satisfy start <= date <= end.

    Returns
    -------
    dates : generator object
    Nr   r   zOffset z did not increment datez did not decrement date)r   r   r   r   is_on_offsetrollforwardrollbacknr   _applyr   )rV   rW   r   r   r?   cur	next_daterD   rD   rF   r   
  sZ    







r   ).)r>   r   r?   r@   rA   r(   )r>   rI   r?   r@   rA   rJ   )rK   )r>   rL   r?   r@   rA   rM   rC   )rR   r@   rS   r@   rT   rU   )r   r2   r   r   r>   rL   r   r   r   r   r   r7   r   rU   )
r   r$  r>   rL   r   r   r   r7   rA   r  )Fr   FrK   )
r   r$  r  r   r  r3   r  r   r   r@   )r   r   r>   rL   )r>   rL   r  rL   rA   rL   )F)r>   rL   r   r   rA   rL   )rV   r   rW   r   r>   rL   rA   rL   )rV   r  rW   r  r   r   )r  r  rA   r  )
rV   r  rW   r  r   r   r   r   r?   r@   )e
__future__r   r   r   r   typingr   r   r   rP  numpyrP   pandas._libsr	   r
   pandas._libs.tslibsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   pandas._libs.tslibs.dtypesr   pandas.errorsr   pandas.util._exceptionsr    pandas.util._validatorsr!   pandas.core.dtypes.commonr"   r#   r$   r%   r&   r'   pandas.core.dtypes.dtypesr(   r)   r*   pandas.core.dtypes.missingr+   r`  r,   r   pandas.core.arrays._rangesr-   pandas.core.commoncorecommonr   pandas.tseries.frequenciesr.   pandas.tseries.offsetsr/   r0   collections.abcr1   pandas._typingr2   r3   r4   r5   r6   r7   r8   r9   rs  r;   r=   r+  rG   rw   TimelikeOpsDatelikeOpsrx   r   r  r  r  r  r   r   r   r   r   r   rD   rD   rD   rF   <module>   s    T (*               t
~0J
89
5
+
!