o
    5cI                    @  s  d dl mZ d dlmZ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" d dl#m$Z$ d dl%m&Z&m'Z' d d	l(m)Z) d d
l*m+Z+ d dl,m-Z- d dl.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> d dl?m@Z@ d dlAmBZB d dlCmDZE d dlFmGZG d dlHmI  mJZK d dlLmMZM d dlNmOZOmPZPmQZQ erd dlRmSZS d dlCmTZTmUZU ed d ZVdKdLddZWdMdNddZXG d d! d!eEjYeEjZZ[dOdPd&d'Z\		"		"	"	(dQd"d"d)dRd.d/Z]	"	(	"	"	"dSdTd3d4Z^dMdUd5d6Z_dVd8d9Z`d:d; ZadWd<d=ZbdXdAdBZcdYdEdFZddGdH ZedddeO fdIdJZfdS )Z    )annotations)datetimetime	timedeltatzinfo)TYPE_CHECKINGLiteralcastN)libtslib)
BaseOffsetNaTNaTType
Resolution	Timestampastype_overflowsafefieldsget_resolutionget_unit_from_dtypeints_to_pydatetimeis_date_array_normalizedis_supported_unitis_unitlessnormalize_i8_timestamps	timezones	to_offsettz_convert_from_utctzconversion)npt)OutOfBoundsDatetimePerformanceWarning)find_stack_level)validate_inclusive)astype_dt64_to_dt64tz)DT64NS_DTYPEINT64_DTYPEis_bool_dtypeis_datetime64_any_dtypeis_datetime64_dtypeis_datetime64_ns_dtypeis_datetime64tz_dtypeis_dtype_equalis_extension_array_dtypeis_float_dtypeis_object_dtypeis_period_dtype	is_sparseis_string_dtypeis_timedelta64_dtypepandas_dtype)DatetimeTZDtype)isna)datetimelike)generate_regular_range)get_period_alias)BDayDayTick	DataFrame)PeriodArrayTimedeltaArraynstztzinfo | Noneunitstrc                 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[]rA   rC   )npdtyper4   rG    rJ   R/var/www/html/gps/gps/lib/python3.10/site-packages/pandas/core/arrays/datetimes.pytz_to_dtype^   s   rL   namefieldc                   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)rW   convert)_local_timestamps	_bool_opsendswithfreqkwdsgetr   get_start_end_fieldfreqstr_resoget_date_field_object_opsget_date_name_field_maybe_mask_results)selfvaluesr]   month_kwr^   resultrN   rJ   rK   fr   s.   


z_field_accessor.<locals>.f)__name____doc__property)rM   rN   	docstringrl   rJ   rk   rK   _field_accessorq   s   "rq   c                      s  e Zd ZU dZdZeddZeejfZ	e
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 Zded< g dZded< dZded< dZded< eZedd Zedefd fd!d"Zedd#d$dd'd(Zedd#dejd#d#d)fdd-d.Z e		#	)	)	/dd0d1Z!ddd4d5Z"dd7d8Z#ddd9d:Z$dd<d=Z%edd>d?Z&eddAdBZ'e'j(dCdB Z'eddDdEZ)eddFdGZ*eddIdJZ+ddɇ fdKdLZ,dMdN Z-dddPdQZ.dddRddTdUZ/ddVdWZ0ddYdZZ1dd[d\Z2dd^d_Z3dd`daZ4e5j6dddbdcZ7ddddeZ8ddfdgZ9dddidjZ:ddldmZ;dddndoZ<dddpdqZ=eddrdsZ>eddtduZ?eddvdwZ@ddydzZAed{d| ZBeBZCeDd}d~dZEeDdddZFeDdddZGeDdddZHeDdddZIeDdddZJeDdddZKeDdddZLdZMeDddeMZNeNZOeNZPeDdddZQeQZReDdddZSeDdddZTeTZUdZVeDddeVjWddZXeDddeVjWddZYeDdddZZeDdddZ[eDdddZ\eDdddZ]eDdddZ^dddZ_					#	OddddZ`  ZaS )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
    datetimearrayr   r@   )r   
datetime64datereturntype[Timestamp]c                 C  s   t S N)r   rg   rJ   rJ   rK   _scalar_type   s   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]r[   r]   rA   rd   )yearrS   dayhourminutesecond
weekofyearweekweekday	dayofweekday_of_week	dayofyearday_of_yearquarterdays_in_monthdaysinmonthmicrosecond
nanosecond
_field_ops)ru   r   timetz
_other_ops_datetimelike_ops)
	to_periodtz_localize
tz_convert	normalizestrftimeroundfloorceil
month_nameday_name_datetimelike_methodsi  np.dtype | DatetimeTZDtype_dtypeNBaseOffset | None_freqc                 C  s   t |j t |}|S rx   )_validate_dt64_dtyperI   )clsrh   rI   rJ   rJ   rK   _validate_dtype  s   
zDatetimeArray._validate_dtyperh   
np.ndarrayc                   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 )NM)
isinstancerH   ndarraykindrI   r   rb   r   super_simple_newr   )r   rh   r]   rI   rj   	__class__rJ   rK   r   	  s   zDatetimeArray._simple_newFrI   copyr   boolc                C  s   | j |||dS )Nr   )_from_sequence_not_strict)r   scalarsrI   r   rJ   rJ   rK   _from_sequence  s   zDatetimeArray._from_sequenceraise'str | BaseOffset | lib.NoDefault | Nonedayfirst	yearfirstc	              	   C  s   |d u }	|t jur|nd }t|\}}
t|||||||d\}}}t|||
\}}
|	r/d }t|}| j|||d}|d u rM|d urM| j|||d |S |
rUt	|j
|_|S )N)rI   r   rA   r   r   	ambiguousr]   rI   r   )r
   
no_defaultdtlmaybe_infer_freq_sequence_to_dt64nsvalidate_inferred_freqrL   r   _validate_frequencyr   inferred_freqr   )r   datarI   r   rA   r]   r   r   r   explicit_none
freq_infersubarrr   rj   rJ   rJ   rK   r   "  s.   
z'DatetimeArray._from_sequence_not_strictbothc
                 C  s  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t	|	\}
}t
|||\}}}t|||}|d ur|d u rfd n|j}|d u rod n|j}t|||||||}t|||||||}|d urt|tr|d ur|d }|d ur|d }t|trt||||}nt||||d}tjdd	 |D tjd
}|d ur|jn|j}|d ur|d u rt|stj||||d}|d ur||||}|d ur||||}ntjd|j|j |dd
|j }|jdkr|d}||kr'|
s&|s&|dd }n:t|j}t|j}|
r7|sa|
sLt|rL|d |krL|dd  }|sat|ra|d |kra|d d }| d}t!|}| j"|||dS )Nc                 s  s    | ]}|d u V  qd S rx   rJ   .0xrJ   rJ   rK   	<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)rO   rP   periodsoffsetc                 S  s   g | ]}|j qS rJ   )valuer   rJ   rJ   rK   
<listcomp>  s    z1DatetimeArray._generate_range.<locals>.<listcomp>rI   )r   nonexistentr   int64i8   zdatetime64[ns]r   )#r   validate_periodsany
ValueErrorcomcount_not_noner   r   r   r"   _maybe_normalize_endpoints_infer_tz_from_endpointsrA   _maybe_localize_pointr   r:   r   r;   r7   generate_rangerH   arrayr   r   is_utcr   tz_localize_to_utclinspacer   rI   astypelenviewrL   r   )r   rO   rP   r   r]   rA   r   r   r   	inclusiveleft_inclusiveright_inclusive_normalizedstart_tzend_tzi8valuesxdrendpoint_tzstart_i8end_i8dt64_valuesrI   rJ   rJ   rK   _generate_rangeO  s   
 









zDatetimeArray._generate_rangesetitemnp.datetime64c                 C  s0   t || js|turtd| j||d |jS )Nz'value' should be a Timestamp.)r   )r   rz   r   r   _check_compatible_withasm8)rg   r   r   rJ   rJ   rK   _unbox_scalar  s   zDatetimeArray._unbox_scalarTimestamp | NaTTypec                 C  s   t || jdS )NrA   )r   rA   rg   r   rJ   rJ   rK   _scalar_from_string  s   z!DatetimeArray._scalar_from_stringc                 C  sl   |t u rd S | | |r0| jd ur2t| j|js4tjdtt d t	d| j d|j dd S d S d S )Na  Setitem-like behavior with mismatched timezones is deprecated and will change in a future version. Instead of raising (or for Index, Series, and DataFrame methods, coercing to object dtype), the value being set (or passed as a fill_value, or inserted) will be cast to the existing DatetimeArray/DatetimeIndex/Series/DataFrame column's timezone. To retain the old behavior, explicitly cast to object dtype before the operation.
stacklevelzTimezones don't match. 'z' != '')
r   _assert_tzawareness_compatrA   r   
tz_comparewarningswarnFutureWarningr!   r   )rg   otherr   rJ   rJ   rK   r     s   
z$DatetimeArray._check_compatible_withr   c                 C  s6   | d}tj|| j| jd}|tur|| j |S )Nr   )rU   rA   )r   r   _from_value_and_resorb   rA   r   	_set_freqr]   )rg   r   r   tsrJ   rJ   rK   	_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   ry   rJ   rJ   rK   rI     s   zDatetimeArray.dtyperB   c                 C  s   t | jddS )z
        Return the timezone.

        Returns
        -------
        datetime.tzinfo, pytz.tzinfo.BaseTZInfo, dateutil.tz.tz.tzfile, or None
            Returns None when the array is tz-naive.
        rA   N)getattrrI   ry   rJ   rJ   rK   rA     s   zDatetimeArray.tzc                 C  s   t d)NzNCannot directly set timezone. Use tz_localize() or tz_convert() as appropriate)AttributeErrorr   rJ   rJ   rK   rA     s   c                 C  r  )z(
        Alias for tz attribute
        r   ry   rJ   rJ   rK   r     s   zDatetimeArray.tzinfoc                 C     t | j| j| jdS )zN
        Returns True if all of the dates are at midnight ("no time")
        rT   )r   asi8rA   rb   ry   rJ   rJ   rK   is_normalized$  s   zDatetimeArray.is_normalizedr   c                 C  r  )NrT   )r   r  rA   rb   ry   rJ   rJ   rK   _resolution_obj+  s   zDatetimeArray._resolution_objc                   s    |d u r	| j r	t}t j|dS )Nr   )rA   objectr   	__array__)rg   rI   r   rJ   rK   r  2  s   zDatetimeArray.__array__c           	      c  s    | j dkrtt| D ]}| | V  qdS | j}t| }d}|| d }t|D ]$}|| }t|d | |}t||| | j| jd| jd}|E dH  q)dS )zt
        Return an iterator over the boxed values

        Yields
        ------
        tstamp : Timestamp
        r   i'  	timestamp)rA   r]   boxrU   N)	ndimranger   r  minr   rA   r]   rb   )	rg   ir   length	chunksizechunksstart_iend_i	convertedrJ   rJ   rK   __iter__9  s*   

zDatetimeArray.__iter__Tc                 C  s0  t |}t|| jr|r|  S | S | jd u r7t|r7t|s7tt|r7t	| j
|dd}t| j||jdS t|rCt| ||ddS | jd urdt|trdt|j}t	| j
||d}t| j||dS | jd u rt|r|| jkrt|rtjdtt d | j
|S t|r| j|jdS tj| ||S )	NTr   r   F)via_utcz}Passing unit-less datetime64 dtype to .astype is deprecated and will raise in a future version. Pass 'datetime64[ns]' insteadr   )r]   )r3   r+   rI   r   rA   r(   r   r   r   r   _ndarraytyper   r)   r#   r   r4   rH   rD   r  r  r  r!   r   r/   r   r]   r   DatetimeLikeArrayMixin)rg   rI   r   
res_valuesnp_dtyperJ   rJ   rK   r   W  sL   
zDatetimeArray.astype)na_repdate_formatnpt.NDArray[np.object_]c                K  s0   ddl m} || |}tj| j| j||| jdS )Nr   )!get_format_datetime64_from_values)rA   formatr*  rU   )pandas.io.formats.formatr-  r   format_array_from_datetimer  rA   rb   )rg   r*  r+  kwargsr-  fmtrJ   rJ   rK   _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   rH   rt   r   hasattrr   r   r  )rg   r  other_tzrJ   rJ   rK   _has_same_tz  s   
zDatetimeArray._has_same_tzNonec                 C  sf   t |dd }t |dd }t|r|jj}|tu rd S | jd u r)|d ur'tdd S |d u r1tdd S )Nr   rI   z;Cannot compare tz-naive and tz-aware datetime-like objects.z:Cannot compare tz-naive and tz-aware datetime-like objects)r  r*   rI   rA   r   	TypeError)rg   r  r5  other_dtyperJ   rJ   rK   r    s"   
z(DatetimeArray._assert_tzawareness_compatc                 C  s   t |trJ | jd ur| d }n| }z|||j}W n- tyL   tj	dt
t d | d| }t| |}t| sI|| j Y S Y |S w tj||jd}| jd ur`|| j}|S )NzCNon-vectorized DateOffset being applied to Series or DatetimeIndex.r   Or   )r   r;   rA   r   _apply_arrayr   rI   NotImplementedErrorr  r  r    r!   r   r&  r   r   rr   r   )rg   r   rh   rj   rJ   rJ   rK   _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.
        NrT   )rA   r   r   r  r   rb   ry   rJ   rJ   rK   rZ     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 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 localizerC   rI   r]   )	r   maybe_get_tzrA   r8  rL   _unitr   r%  r]   )rg   rA   rI   rJ   rJ   rK   r     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}ntdt|}t	j
| j|||| jd}|d| j d}t|| jd}d}t|sYt| d	kr]t|d
 s]| j}n|du ri| jdu ri| 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 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 objectNz,Already tz-aware, use tz_convert to convert.)r   r   rU   rE   rF   r?  r   r   r@  )r   r   r   rA   r   r  r8  r   rA  r   r   rb   r   rB  rL   r   r   r5   r]   r   )rg   rA   r   r   nonexistent_options	new_datesrI   r]   rJ   rJ   rK   r   ;  s8    


"zDatetimeArray.tz_localizec                 C  r  )z
        Return an ndarray of datetime.datetime objects.

        Returns
        -------
        datetimes : ndarray[object]
        )rA   rU   r   r  rA   rb   ry   rJ   rJ   rK   to_pydatetime  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)
        rT   r   inferN)r   r  rA   rb   r   r%  rI   r&  r   
_with_freqr   )rg   
new_valuesr   dtarJ   rJ   rK   r     s   &

zDatetimeArray.normalizer>   c                 C  sx   ddl m} | jdurtjdtt d |du r2| jp| j}|du r&t	dt
|}|du r0|}|}|j| j|| jdS )ax  
        Cast to PeriodArray/Index at a particular frequency.

        Converts DatetimeArray/Index to PeriodArray/Index.

        Parameters
        ----------
        freq : str or Offset, optional
            One of pandas' :ref:`offset strings <timeseries.offset_aliases>`
            or an Offset object. Will be inferred by default.

        Returns
        -------
        PeriodArray/Index

        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.r   z8You must pass a freq argument as current index has none.r   )pandas.core.arraysr>   rA   r  r  UserWarningr!   ra   r   r   r8   _from_datetime64r%  )rg   r]   r>   resrJ   rJ   rK   r   +  s$   ,
zDatetimeArray.to_periodr?   c                 C  sZ   t jdtt d ddlm} | jjdkrtd| j	| 
| j	 }|d}||S )a
  
        Calculate deltas between self values and self converted to Periods at a freq.

        Used for vectorized offsets.

        Parameters
        ----------
        freq : Period frequency

        Returns
        -------
        TimedeltaArray/Index
        zto_perioddelta is deprecated and will be removed in a future version. Use `dtindex - dtindex.to_period(freq).to_timestamp()` instead.r   r   r?   M8[ns]z)Only supported for nanosecond resolution.zm8[ns])r  r  r  r!   pandas.core.arrays.timedeltasr?   r%  rI   r<  r  r   to_timestampr   )rg   r]   r?   i8deltam8deltarJ   rJ   rK   to_perioddeltas  s   
zDatetimeArray.to_perioddeltac                 C  .   |   }tj|d|| jd}| j|dd}|S )a  
        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.

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

        Examples
        --------
        >>> s = pd.Series(pd.date_range(start='2018-01', freq='M', 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='M', periods=3)
        >>> idx
        DatetimeIndex(['2018-01-31', '2018-02-28', '2018-03-31'],
                      dtype='datetime64[ns]', freq='M')
        >>> idx.month_name()
        Index(['January', 'February', 'March'], dtype='object')
        r   localerU   NrV   rZ   r   re   rb   rf   rg   rZ  rh   rj   rJ   rJ   rK   r        $
zDatetimeArray.month_namec                 C  rX  )a  
        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.

        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')
        r   rY  NrV   r[  r\  rJ   rJ   rK   r     r]  zDatetimeArray.day_namec                 C     |   }t|d| jdS )zr
        Returns numpy array of :class:`datetime.time` objects.

        The time part of the Timestamps.
        r   r  rU   rZ   r   rb   rg   
timestampsrJ   rJ   rK   r     s   
zDatetimeArray.timec                 C  s   t | j| jd| jdS )z
        Returns numpy array of :class:`datetime.time` objects with timezones.

        The time part of the Timestamps.
        r   r_  rG  ry   rJ   rJ   rK   r     s   zDatetimeArray.timetzc                 C  r^  )z
        Returns numpy array of python :class:`datetime.date` objects.

        Namely, the date part of Timestamps without time and
        timezone information.
        ru   r_  r`  ra  rJ   rJ   rK   ru     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.

        .. versionadded:: 1.1.0

        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<   rT   )r   r   r   UInt32)columnsrI   N)	pandasr=   rZ   r   build_isocalendar_sarrayrb   _hasnailoc_isnan)rg   r=   rh   sarrayiso_calendar_dfrJ   rJ   rK   isocalendar  s   "
zDatetimeArray.isocalendarc                 C  s>   t jdtt d |  j}|jr|jdtj	dS |jddS )z
        The week ordinal of the year.

        .. deprecated:: 1.1.0

        weekofyear and week have been deprecated.
        Please use DatetimeIndex.isocalendar().week instead.
        zweekofyear and week have been deprecated, please use DatetimeIndex.isocalendar().week instead, which returns a Series. To exactly reproduce the behavior of week and weekofyear and return an Index, you may call pd.Int64Index(idx.isocalendar().week)r   rX   )rI   na_valuer   r   )
r  r  r  r!   rl  r   hasnansto_numpyrH   nan)rg   week_seriesrJ   rJ   rK   r   A  s   

	zDatetimeArray.weekofyearr   Ya  
        The year of the datetime.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="Y")
        ... )
        >>> 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: int64
        rS   r   a  
        The month as January=1, December=12.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="M")
        ... )
        >>> 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: int64
        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: int64
        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: int64
        r   ma  
        The minutes of the datetime.

        Examples
        --------
        >>> datetime_series = pd.Series(
        ...     pd.date_range("2000-01-01", periods=3, freq="T")
        ... )
        >>> 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: int64
        r   sa  
        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: int64
        r   usa  
        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: int64
        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: int64
        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: int64
    r   dowr   doyz.
        The ordinal day of the year.
        r   qz*
        The quarter of the date.
        r   dimz2
        The number of days in the month.
        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 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_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="Y")
        >>> idx
        DatetimeIndex(['2012-12-31', '2013-12-31', '2014-12-31'],
                      dtype='datetime64[ns]', freq='A-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   rQ      i     im     d   i  g   C:A<   i  i@B i ʚ;   )rH   asarrayr   rS   r   fixr   r   r   r   r   r   )rg   r   rS   r   testarrrJ   rJ   rK   to_julian_dateZ  s@   zDatetimeArray.to_julian_dater   ddofintkeepdimsskipnac           
      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 the ddof argument

        Parameters
        ----------
        axis : int optional, default None
            Axis for the function to be applied on.
            For `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
        r   rQ  rt   timedelta64r   )axisoutr  r  r  )
rM  r?   r%  rI   rM   replacerH   r   r   std)
rg   r  rI   r  r  r  r  r?   	dtype_strtdarJ   rJ   rK   r  }  s
   !
zDatetimeArray.std)rv   rw   )rh   r   r]   r   rv   rr   )r   r   )r   r   r]   r   r   r   r   r   )NFr   r   r   F)r   r   rv   r   )rv   r   )r   r   )r   r   rv   r   )rv   r   )rv   rB   )rv   r   )rv   r   rx   )rv   r   )T)rv   r,  )rv   r7  )rv   rr   )rv   r>  )r   r   )rv   r>   )rv   r?   )rv   r=   )rv   r  )NNNr   FT)r  r  r  r   r  r   )brm   
__module____qualname__rn   _typrH   rt   _internal_fill_valuer   _recognized_scalarsr'   _is_recognized_dtype_infer_matchesro   rz   r[   __annotations__rd   r   r   r   r   __array_priority__r   r$   _default_dtypeclassmethodr   r   r   r
   r   r   r   r   r   r   r  rI   rA   setterr   r  r  r  r"  r   r3  r6  r  r=  rZ   r   r   ravel_compatr   rH  r   r   rW  r   r   r   r   ru   rl  r   r   rq   r   rS   r   r   r   r   r   r   _dayofweek_docr   r   r   r   r   r   r   r   _is_month_docr.  r{   r|   r}   r~   r   r   r   r  r  __classcell__rJ   rJ   r   rK   rr      sz  
 "
	
,q


9



"
L 
7

/
H#,,
-
",**,,
*%rr   Frequire_iso8601r   rv   c                 C  s0   t | d|d\}}}t|}tj|||d}|S )zV
    Parse/convert the passed data to either DatetimeArray or np.ndarray[object].
    Tallow_mixedr  r   )r   rL   rr   r   )r   r  rj   rA   r]   rI   rL  rJ   rJ   rK   sequence_to_datetimes  s   r  r   r  r   r   r   r  c                C  s0  d}	t |}t|}t||}tj| |dd\} }t| tr"| j}	t	| ||d\} }t
| dd}
t|
s=t|
s=t|
rd}tj| dddkrO| tj} n:t| ||d||d	\} }|r|r| jd
krl| t|dfS t|rw| d
}nt| d
|}|t} n|r|}| j}
t|
rt|| j}| j}nVt|
rt
| d| } | jtkrt| td} d}|durt|}tj | d
||d} | t} | jtksJ | j| }n|rt|}| jt!kr| jtjdd} | t}|r|" }t|tj#sJ t$||jdksJ |jt|| |||	fS )a  
    Parameters
    ----------
    data : list-like
    dtype : dtype, str, or None, default None
    copy : bool, default False
    tz : tzinfo, str, 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.
    allow_mixed : bool, default False
        Interpret integers as timestamps when datetime objects are also present.
    require_iso8601 : bool, default False
        Only consider ISO-8601 formats when parsing strings.

    Returns
    -------
    result : numpy.ndarray
        The sequence converted to a numpy array with dtype ``datetime64[ns]``.
    tz : tzinfo or None
        Either the user-provided tzinfo or one inferred from the data.
    inferred_freq : Tick or None
        The inferred frequency of the sequence.

    Raises
    ------
    TypeError : PeriodDType data is passed
    Nrr   )cls_namer   rI   F)r  integer)r   r   allow_objectr  r  r   r%  r   r   r#  rR  )%r   r   rA  validate_tz_from_dtyper   !ensure_arraylike_for_datetimeliker   rr   r]   maybe_convert_dtyper  r.   r1   r0   r
   infer_dtyper   rH   r   objects_to_datetime64nsrI   r   r$   r   r   r*   _maybe_infer_tzrA   r%  r(   r   r   r   r%   r   r   r&  )r   rI   r   rA   r   r   r   r  r  r   
data_dtypeinferred_tzutc_valsrj   rJ   rJ   rK   r     s   *














r   r   r   r  c              
   C  s   |dv sJ t j| dt jd} | j}|jrdnd}	ztj| d||||||d\}
}|
j| j	|	d}
W n t
yE } ztd	|d
}~ww |d
urQ|
d|fS t|
rY|
|fS t|
rg|rc|
|fS t|
t|
)a  
    Convert data to array of timestamps.

    Parameters
    ----------
    data : np.ndarray[object]
    dayfirst : bool
    yearfirst : bool
    utc : bool, default False
        Whether to convert timezone-aware timestamps to UTC.
    errors : {'raise', 'ignore', 'coerce'}
    require_iso8601 : bool, default False
    allow_object : bool
        Whether to return an object-dtype ndarray instead of raising if the
        data contains more than one timezone.
    allow_mixed : bool, default False
        Interpret integers as timestamps when datetime objects are also present.

    Returns
    -------
    result : ndarray
        np.int64 dtype if returned values represent UTC timestamps
        np.datetime64[ns] if returned values represent wall times
        object if mixed timezones
    inferred_tz : tzinfo or None

    Raises
    ------
    ValueError : if data cannot be converted to datetimes
    )r   ignorecoerceF)r   rI   FCK)errorsutcr   r   r  r  )orderz"Out of bounds nanosecond timestampNr   )rH   r   object_flagsf_contiguousr   array_to_datetimeravelreshapeshapeOverflowErrorr   r   r(   r.   r8  )r   r   r   r  r  r  r  r  r  r  rj   	tz_parsederrrJ   rJ   rK   r  Q  s8   (
	
r  c                 C  s   t | ds	| |fS t| jr4| t} d}|dur0t| dkr0tt|s0t	j
dtt d | |fS t| js>t| jrGtd| j dt| jrPtd	t| jrdt| jsdtj| tjd
} d}| |fS )at  
    Convert data based on dtype conventions, issuing deprecation warnings
    or 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
    rI   FNr   a  The behavior of DatetimeArray._from_sequence with a timezone-aware dtype and floating-dtype data is deprecated. In a future version, this data will be interpreted as nanosecond UTC timestamps instead of wall-times, matching the behavior with integer dtypes. To retain the old behavior, explicitly cast to 'datetime64[ns]' before passing the data to pandas. To get the future behavior, first cast to 'int64'.r   zdtype z& cannot be converted to datetime64[ns]zFPassing PeriodDtype data is invalid. Use `data.to_timestamp()` insteadr   )r4  r-   rI   r   r$   r   r   r   rA  r  r  r  r!   r2   r&   r8  r/   r,   r*   rH   r   r  )r   r   rA   rJ   rJ   rK   r    s6   




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   r  r8  )rA   r  rJ   rJ   rK   r    s   r  c                 C  s   | durDt | } t| tdrd}t|t| tjr | tks(t| tjtfs0td|  dt| ddrDt	t| } t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
    NM8zhPassing in 'datetime64' dtype with no precision is not allowed. Please pass in 'datetime64[ns]' instead.zUnexpected value for 'dtype': 'z0'. Must be 'datetime64[ns]' or DatetimeTZDtype'.rA   r   )r3   r+   rH   rI   r   r   r$   r4   r  r	   r   tz_standardizerA   )rI   msgrJ   rJ   rK   r   
	  s    


r   c                 C  s   | durJt | trzt| } W n	 ty   Y nw t| dd}|dur4|dur2t||s2td|}|durJt	| rJ|durJt||sJtd|S )aU  
    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

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

    Raises
    ------
    ValueError : on tzinfo mismatch
    NrA   z-cannot supply both a tz and a dtype with a tzzHcannot supply both a tz and a timezone-naive dtype (i.e. datetime64[ns]))
r   rD   r4   construct_from_stringr8  r  r   r  r   r(   )rI   rA   dtzrJ   rJ   rK   r  >	  s$   
r  rO   r   rP   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AssertionErrorr8  rA  r  )rO   rP   rA   r  r  rJ   rJ   rK   r   m	  s&   

r   Timestamp | Noner   c                 C  sb   d}| d ur|r|   } d}n|o|  tk}|d ur,|r$|  }d}n|o+| tk}| ||fS )NT)r   r   	_midnight)rO   rP   r   r   rJ   rJ   rK   r   	  s   
r   c                 C  sZ   |du r+|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
    is_none : argument that should be None
    is_not_none : argument that should not be None
    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
    NrI  F)r   r   rA   rA   rJ   )r   r;   r   )r  is_noneis_not_noner]   rA   r   r   localize_argsrJ   rJ   rK   r   	  s   r   c                 c  sl   t |}t| } | tur| nd} t|}|tur|nd}| r*|| s*|| } n|r6||s6||}|du rG|| k rG|jdkrGd}d}|du rS| |d |  }| du r_||d |  } | }|jdkr||kr|V  ||krsdS ||}||krtd| d|}||ksjd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 : datetime, (default None)
    end : datetime, (default None)
    periods : int, (default None)
    offset : DateOffset, (default BDay())

    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   is_on_offsetrollforwardrollbackn_applyr   )rO   rP   r   r   cur	next_daterJ   rJ   rK   r   	  sJ   



r   )r@   )rA   rB   rC   rD   rx   )rM   rD   rN   rD   r  )r  r   rv   rr   )NFNFFr   )
r   r   r   r   r   r   r  r   r  r   )Fr   FFF)r   r   r  r   r  r   r  r   )r   r   rA   rB   )rA   rB   r  rB   rv   rB   )rA   rB   rv   rB   )rO   r   rP   r   rA   rB   rv   rB   )rO   r  rP   r  r   r   )g
__future__r   r   r   r   r   typingr   r   r	   r  numpyrH   pandas._libsr
   r   pandas._libs.tslibsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   pandas._typingr   pandas.errorsr   r    pandas.util._exceptionsr!   pandas.util._validatorsr"   pandas.core.dtypes.astyper#   pandas.core.dtypes.commonr$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   pandas.core.dtypes.dtypesr4   pandas.core.dtypes.missingr5   rM  r6   r   pandas.core.arrays._rangesr7   pandas.core.commoncorecommonr   pandas.tseries.frequenciesr8   pandas.tseries.offsetsr9   r:   r;   re  r=   r>   r?   r  rL   rq   TimelikeOpsDatelikeOpsrr   r  r   r  r  r  r   r  r   r   r   r   rJ   rJ   rJ   rK   <module>   s    PH
(              "	 V
E
4
/
+!