o
    ŀg                  
   @  s  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	 d dl
mZmZmZmZmZmZ d dlZd dlZd dlmZmZ d d	lmZ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'm(Z(m)Z) d dl*m+Z+ d dl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 d dl3m4Z4m5Z5 d dl6m7Z7m8Z8 d dl9m:Z:m;Z;m<Z< d dl=m>Z> d dl?m@Z@ d dlAmBZB d dlCmDZDmEZEmFZF d dlGmHZH d dlImJZJ d dlKmLZL erd dlMmNZN d dlOmPZP d dlQmRZR d dlSmTZTmUZU eeVeWe'f ZXeeYeZf Z[ee[eej\f Z]ee]eXf Z^eeVe[ eWe[df e'f Z_G dd  d ed!d"Z`G d#d$ d$e`d%d"Zaeead&f Zbd'Zcddd,d-Zd	ddd6d7Zedd=d>Zf	dddEdFZg	dddIdJZh		%		K			!dddQdRZiddUdVZjddWdXZkdYdZ Zle										ddd^d_Zme										dddad_Zme										ddddd_ZmdKd%d%d%dejndejnded!f
ddkd_Zmi dldldmdldndndodndpdpdqdpdrdsdtdsdudvdwdvdxdydzdyd{d{d|d{d}d{d~d~dd~d~ddddZodddZpg dZqdS )    )annotations)abc)date)partial)islice)TYPE_CHECKINGCallable	TypedDictUnioncastoverloadN)libtslib)OutOfBoundsDatetime	Timedelta	Timestampastype_overflowsafeis_supported_dtype	timezones)cast_from_unit_vectorized)DateParseErrorguess_datetime_format)array_strptime)AnyArrayLike	ArrayLikeDateTimeErrorChoices)find_stack_level)ensure_objectis_float
is_integeris_integer_dtypeis_list_likeis_numeric_dtype)
ArrowDtypeDatetimeTZDtype)ABCDataFrame	ABCSeries)DatetimeArrayIntegerArrayNumpyExtensionArray)unique)ArrowExtensionArray)ExtensionArray)maybe_convert_dtypeobjects_to_datetime64tz_to_dtype)extract_array)Index)DatetimeIndex)Hashable)NaTType)UnitChoices)	DataFrameSeries.c                   @  s&   e Zd ZU ded< ded< ded< dS )YearMonthDayDictDatetimeDictArgyearmonthdayN__name__
__module____qualname____annotations__ rB   rB   O/var/www/html/myenv/lib/python3.10/site-packages/pandas/core/tools/datetimes.pyr8   e   s   
 r8   T)totalc                   @  sV   e Zd ZU ded< ded< ded< ded< ded< ded< ded< ded	< ded
< dS )FulldatetimeDictr9   hourhoursminuteminutessecondsecondsmsusnsNr=   rB   rB   rB   rC   rE   k   s   
 rE   Fr6   2   dayfirstbool | Nonereturn
str | Nonec                 C  sn   t |  }dkr5t| |  }tu r5t||d}|d ur|S t | |d d  dkr5tjdtt d d S )NrP      zCould not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format.
stacklevel)	r   first_non_nulltypestrr   warningswarnUserWarningr   )arrrP   rY   first_non_nan_elementguessed_formatrB   rB   rC    _guess_datetime_format_for_array~   s   rb   ffffff?argArrayConvertibleunique_sharefloatcheck_count
int | Noneboolc                 C  s   d}|du rt | tkrdS t | dkrt | d }nd}nd|  kr-t | ks2J d J d|dkr8dS d|  k rEd	k sJJ d
 J d
z	tt| |}W n
 ty]   Y dS w t ||| krhd}|S )a  
    Decides whether to do caching.

    If the percent of unique elements among `check_count` elements less
    than `unique_share * 100` then we can do caching.

    Parameters
    ----------
    arg: listlike, tuple, 1-d array, Series
    unique_share: float, default=0.7, optional
        0 < unique_share < 1
    check_count: int, optional
        0 <= check_count <= len(arg)

    Returns
    -------
    do_caching: bool

    Notes
    -----
    By default for a sequence of less than 50 items in size, we don't do
    caching; for the number of elements less than 5000, we take ten percent of
    all elements to check for a uniqueness share; if the sequence size is more
    than 5000, then we check only the first 500 elements.
    All constants were chosen empirically by.
    TNFi  
   i  r   z1check_count must be in next bounds: [0; len(arg)]rV   z+unique_share must be in next bounds: (0; 1))lenstart_caching_atsetr   	TypeError)rd   rf   rh   
do_cachingunique_elementsrB   rB   rC   should_cache   s.   $rr   formatcacheconvert_listliker   r7   c                 C  s   ddl m} |td}|rTt| s|S t| tjttt	fs"t
| } t| }t|t| k rT|||}z	|||dd}W n tyG   | Y S w |jjsT||j   }|S )a  
    Create a cache of unique dates from an array of dates

    Parameters
    ----------
    arg : listlike, tuple, 1-d array, Series
    format : string
        Strftime format to parse time
    cache : bool
        True attempts to create a cache of converted values
    convert_listlike : function
        Conversion function to apply on dates

    Returns
    -------
    cache_array : Series
        Cache of converted, unique dates. Can be empty
    r   r7   dtypeF)indexcopy)pandasr7   objectrr   
isinstancenpndarrayr,   r1   r&   arrayr*   rl   r   ry   	is_unique
duplicated)rd   rs   rt   ru   r7   cache_arrayunique_datescache_datesrB   rB   rC   _maybe_cache   s$   


r   dt_arrayr   utcnameHashable | Noner1   c                 C  s8   t | jdr|rdnd}t| ||dS t| || jdS )a  
    Properly boxes the ndarray of datetimes to DatetimeIndex
    if it is possible or to generic Index instead

    Parameters
    ----------
    dt_array: 1-d array
        Array of datetimes to be wrapped in an Index.
    utc : bool
        Whether to convert/localize timestamps to UTC.
    name : string, default None
        Name for a resulting index

    Returns
    -------
    result : datetime of converted dates
        - DatetimeIndex if convertible to sole datetime64 type
        - general Index otherwise
    Mr   Ntzr   )r   rx   )r   is_np_dtyperx   r2   r1   )r   r   r   r   rB   rB   rC   _box_as_indexlike  s   r    DatetimeScalarOrArrayConvertibler   c                 C  s2   ddl m} || |jjd|}t|jd|dS )a  
    Convert array of dates with a cache and wrap the result in an Index.

    Parameters
    ----------
    arg : integer, float, string, datetime, list, tuple, 1-d array, Series
    cache_array : Series
        Cache of converted, unique dates
    name : string, default None
        Name for a DatetimeIndex

    Returns
    -------
    result : Index-like of converted dates
    r   rv   rw   Fr   r   )r{   r7   ry   rx   mapr   _values)rd   r   r   r7   resultrB   rB   rC   _convert_and_box_cache   s   r   raiseuniterrorsr   	yearfirstexactc	                 C  s  t | ttfrtj| dd} n
t | trt| } t| dd}	|r#dnd}
t |	trDt | tt	fs8t	| |
|dS |rB| 
dd} | S t |	tr|	jtu r|rt | trrtt| j}|	jjdurg|d}n|d}t|} | S |	jjdur| d} | S | d} | S t|	drt|	stt| td	|d
kd} t | tt	fst	| |
|dS |r| dS | S |dur|durtdt| ||||S t| dddkrtdzt| dt !|
d\} }W n2 ty   |d
krtjdgdd"t#| }t	||d Y S |dkrt| |d}| Y S  w t$| } |du r&t%| |d}|dur9|dkr9t&| |||||S t'| ||||dd\}}|durrt(|jd }ttt)||}|*d|j+ d}tj,||d}t	j,||dS t-|||dS )a  
    Helper function for to_datetime. Performs the conversions of 1D listlike
    of dates

    Parameters
    ----------
    arg : list, tuple, ndarray, Series, Index
        date to be parsed
    name : object
        None or string for the Index name
    utc : bool
        Whether to convert/localize timestamps to UTC.
    unit : str
        None or string of the frequency of the passed data
    errors : str
        error handing behaviors from to_datetime, 'raise', 'coerce', 'ignore'
    dayfirst : bool
        dayfirst parsing behavior from to_datetime
    yearfirst : bool
        yearfirst parsing behavior from to_datetime
    exact : bool, default True
        exact format matching behavior from to_datetime

    Returns
    -------
    Index-like of parsed dates
    Orw   rx   Nr   r   UTCr   zM8[s]coerce)	is_coercez#cannot specify both format and unitndimrV   zAarg must be a string, datetime, list, tuple, 1-d array, or SeriesF)rz   r   NaTzdatetime64[ns]r   ignorerU   mixedT)rP   r   r   r   allow_objectr   M8[]r   ).r}   listtupler~   r   r)   getattrr$   r'   r2   
tz_converttz_localizer#   rZ   r   r1   r   r+   pyarrow_dtyper   _dt_tz_convert_dt_tz_localizer   r   r   r   asarrayrx   
ValueError_to_datetime_with_unitro   r-   libtimezonesmaybe_get_tzrepeatrl   r   rb   _array_strptime_with_fallbackr.   datetime_datar/   viewr   _simple_newr   )rd   rs   r   r   r   r   rP   r   r   	arg_dtyper   	arg_array_npvaluesidxr   	tz_parsedout_unitrx   dt64_valuesdtarB   rB   rC   _convert_listlike_datetimes:  s   &









	


	r   fmtr[   c                 C  s   t | ||||d\}}|dur1t|jd }t||d}	tj||	d}
|r+|
d}
t|
|dS |jt	krM|rMt|jd }t|d| d	|d
}|S t||j|d
S )zL
    Call array_strptime, with fallback behavior depending on 'errors'.
    )r   r   r   Nr   )r   r   rw   r   r   r   z, UTC])rx   r   )
r   r~   r   rx   r$   r'   r   r   r1   r|   )rd   r   r   r   r   r   r   tz_outr   rx   r   resrB   rB   rC   r     s   
r   c              
   C  s  t | dd} t| tr| d| d}d}nt| } | jjdv rX| jd| ddd}zt|td	dd}W n t	yT   |d
krE | t
} t| |||| Y S w d}ne| jjdkrtjd
d8 zt| |d}W n' t	y   |d
krt| t
|||| Y W  d   S t	d| dw W d   n1 sw   Y  |d	}d}n| jt
dd} tj| ||d\}}|dkrtj||d}nt||d}t|ts|S |d|}|r|jdu r|d}|S |d}|S )zF
    to_datetime specalized to the case where a 'unit' is passed.
    T)extract_numpyzdatetime64[r   NiuFrz   zM8[ns]r   f)overr   z cannot convert input with unit ''r   r   r   r   r   )r0   r}   r(   astyper~   r   rx   kindr   r   r|   r   errstater   r   r   array_with_unit_to_datetimer1   _with_inferr2   r   r   r   )rd   r   r   r   r   r_   r   r   rB   rB   rC   r     s`   








r   c              
   C  s  |dkrQ| }t d }|dkrtdz| | } W n ty+ } ztd|d}~ww t j | }t j | }t| |ksHt| |k rOt| d| S t	| skt
| sktt| sktd|  d	| d
zt ||d}W n) ty } z	td| d|d}~w ty } z	td| d|d}~ww |jdurtd| d|t d }	|	td|d }
t| rt| tttjfst| } | |
 } | S )a  
    Helper function for to_datetime.
    Adjust input argument to the specified origin

    Parameters
    ----------
    arg : list, tuple, ndarray, Series, Index
        date to be adjusted
    origin : 'julian' or Timestamp
        origin offset for the arg
    unit : str
        passed unit from to_datetime, must be 'D'

    Returns
    -------
    ndarray or scalar of adjusted date(s)
    julianr   Dz$unit must be 'D' for origin='julian'z3incompatible 'arg' type for given 'origin'='julian'Nz% is Out of Bounds for origin='julian'r   z!' is not compatible with origin='z+'; it must be numeric with a unit specifiedr   zorigin z is Out of Boundsz# cannot be converted to a Timestampzorigin offset z must be tz-naiverV   )r   to_julian_dater   ro   maxminr~   anyr   r   r   r"   r   r   r   r!   r}   r&   r1   r   )rd   originr   originalj0errj_maxj_minoffset	td_offsetioffsetrB   rB   rC   _adjust_to_origin&  sh   #


r   DatetimeScalarinfer_datetime_formatr   c                 C     d S NrB   rd   r   rP   r   r   rs   r   r   r   r   rt   rB   rB   rC   to_datetimen     r   Series | DictConvertiblec                 C  r   r   rB   r   rB   rB   rC   r     r    list | tuple | Index | ArrayLiker2   c                 C  r   r   rB   r   rB   rB   rC   r     r   unix2DatetimeScalarOrArrayConvertible | DictConvertiblebool | lib.NoDefaultlib.NoDefault | boolr   8DatetimeIndex | Series | DatetimeScalar | NaTType | Nonec              	   C  s>  |t jur|dv rtd|t jurtjdt d |dkr'tjdtt d | du r-dS |	dkr7t| |	|} tt	||||||d	}t
| tr^| }|r\| jdurW| d
}|S | d
}|S t
| trt| ||
|}|jst| |}|S || j|}| j|| j| jd}|S t
| ttjfrt| ||}|S t
| trt| ||
|}|jst| || jd}|S || || jd}|S t| rzttt t!t"t#j$dtf | }t|||
|}W n t%y   |dkr ddl&m'} |g t(d}Y nw |jst||}|S |||}|S |t#)| g|d }t
| t*rt
|t#j+rt*|}|S )a7:  
    Convert argument to datetime.

    This function converts a scalar, array-like, :class:`Series` or
    :class:`DataFrame`/dict-like to a pandas datetime object.

    Parameters
    ----------
    arg : int, float, str, datetime, list, tuple, 1-d array, Series, DataFrame/dict-like
        The object to convert to a datetime. If a :class:`DataFrame` is provided, the
        method expects minimally the following columns: :const:`"year"`,
        :const:`"month"`, :const:`"day"`. The column "year"
        must be specified in 4-digit format.
    errors : {'ignore', 'raise', 'coerce'}, default 'raise'
        - If :const:`'raise'`, then invalid parsing will raise an exception.
        - If :const:`'coerce'`, then invalid parsing will be set as :const:`NaT`.
        - If :const:`'ignore'`, then invalid parsing will return the input.
    dayfirst : bool, default False
        Specify a date parse order if `arg` is str or is list-like.
        If :const:`True`, parses dates with the day first, e.g. :const:`"10/11/12"`
        is parsed as :const:`2012-11-10`.

        .. warning::

            ``dayfirst=True`` is not strict, but will prefer to parse
            with day first.

    yearfirst : bool, default False
        Specify a date parse order if `arg` is str or is list-like.

        - If :const:`True` parses dates with the year first, e.g.
          :const:`"10/11/12"` is parsed as :const:`2010-11-12`.
        - If both `dayfirst` and `yearfirst` are :const:`True`, `yearfirst` is
          preceded (same as :mod:`dateutil`).

        .. warning::

            ``yearfirst=True`` is not strict, but will prefer to parse
            with year first.

    utc : bool, default False
        Control timezone-related parsing, localization and conversion.

        - If :const:`True`, the function *always* returns a timezone-aware
          UTC-localized :class:`Timestamp`, :class:`Series` or
          :class:`DatetimeIndex`. To do this, timezone-naive inputs are
          *localized* as UTC, while timezone-aware inputs are *converted* to UTC.

        - If :const:`False` (default), inputs will not be coerced to UTC.
          Timezone-naive inputs will remain naive, while timezone-aware ones
          will keep their time offsets. Limitations exist for mixed
          offsets (typically, daylight savings), see :ref:`Examples
          <to_datetime_tz_examples>` section for details.

        .. warning::

            In a future version of pandas, parsing datetimes with mixed time
            zones will raise an error unless `utc=True`.
            Please specify `utc=True` to opt in to the new behaviour
            and silence this warning. To create a `Series` with mixed offsets and
            `object` dtype, please use `apply` and `datetime.datetime.strptime`.

        See also: pandas general documentation about `timezone conversion and
        localization
        <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html
        #time-zone-handling>`_.

    format : str, default None
        The strftime to parse time, e.g. :const:`"%d/%m/%Y"`. See
        `strftime documentation
        <https://docs.python.org/3/library/datetime.html
        #strftime-and-strptime-behavior>`_ for more information on choices, though
        note that :const:`"%f"` will parse all the way up to nanoseconds.
        You can also pass:

        - "ISO8601", to parse any `ISO8601 <https://en.wikipedia.org/wiki/ISO_8601>`_
          time string (not necessarily in exactly the same format);
        - "mixed", to infer the format for each element individually. This is risky,
          and you should probably use it along with `dayfirst`.

        .. note::

            If a :class:`DataFrame` is passed, then `format` has no effect.

    exact : bool, default True
        Control how `format` is used:

        - If :const:`True`, require an exact `format` match.
        - If :const:`False`, allow the `format` to match anywhere in the target
          string.

        Cannot be used alongside ``format='ISO8601'`` or ``format='mixed'``.
    unit : str, default 'ns'
        The unit of the arg (D,s,ms,us,ns) denote the unit, which is an
        integer or float number. This will be based off the origin.
        Example, with ``unit='ms'`` and ``origin='unix'``, this would calculate
        the number of milliseconds to the unix epoch start.
    infer_datetime_format : bool, default False
        If :const:`True` and no `format` is given, attempt to infer the format
        of the datetime strings based on the first non-NaN element,
        and if it can be inferred, switch to a faster method of parsing them.
        In some cases this can increase the parsing speed by ~5-10x.

        .. deprecated:: 2.0.0
            A strict version of this argument is now the default, passing it has
            no effect.

    origin : scalar, default 'unix'
        Define the reference date. The numeric values would be parsed as number
        of units (defined by `unit`) since this reference date.

        - If :const:`'unix'` (or POSIX) time; origin is set to 1970-01-01.
        - If :const:`'julian'`, unit must be :const:`'D'`, and origin is set to
          beginning of Julian Calendar. Julian day number :const:`0` is assigned
          to the day starting at noon on January 1, 4713 BC.
        - If Timestamp convertible (Timestamp, dt.datetime, np.datetimt64 or date
          string), origin is set to Timestamp identified by origin.
        - If a float or integer, origin is the difference
          (in units determined by the ``unit`` argument) relative to 1970-01-01.
    cache : bool, default True
        If :const:`True`, use a cache of unique, converted dates to apply the
        datetime conversion. May produce significant speed-up when parsing
        duplicate date strings, especially ones with timezone offsets. The cache
        is only used when there are at least 50 values. The presence of
        out-of-bounds values will render the cache unusable and may slow down
        parsing.

    Returns
    -------
    datetime
        If parsing succeeded.
        Return type depends on input (types in parenthesis correspond to
        fallback in case of unsuccessful timezone or out-of-range timestamp
        parsing):

        - scalar: :class:`Timestamp` (or :class:`datetime.datetime`)
        - array-like: :class:`DatetimeIndex` (or :class:`Series` with
          :class:`object` dtype containing :class:`datetime.datetime`)
        - Series: :class:`Series` of :class:`datetime64` dtype (or
          :class:`Series` of :class:`object` dtype containing
          :class:`datetime.datetime`)
        - DataFrame: :class:`Series` of :class:`datetime64` dtype (or
          :class:`Series` of :class:`object` dtype containing
          :class:`datetime.datetime`)

    Raises
    ------
    ParserError
        When parsing a date from string fails.
    ValueError
        When another datetime conversion error happens. For example when one
        of 'year', 'month', day' columns is missing in a :class:`DataFrame`, or
        when a Timezone-aware :class:`datetime.datetime` is found in an array-like
        of mixed time offsets, and ``utc=False``.

    See Also
    --------
    DataFrame.astype : Cast argument to a specified dtype.
    to_timedelta : Convert argument to timedelta.
    convert_dtypes : Convert dtypes.

    Notes
    -----

    Many input types are supported, and lead to different output types:

    - **scalars** can be int, float, str, datetime object (from stdlib :mod:`datetime`
      module or :mod:`numpy`). They are converted to :class:`Timestamp` when
      possible, otherwise they are converted to :class:`datetime.datetime`.
      None/NaN/null scalars are converted to :const:`NaT`.

    - **array-like** can contain int, float, str, datetime objects. They are
      converted to :class:`DatetimeIndex` when possible, otherwise they are
      converted to :class:`Index` with :class:`object` dtype, containing
      :class:`datetime.datetime`. None/NaN/null entries are converted to
      :const:`NaT` in both cases.

    - **Series** are converted to :class:`Series` with :class:`datetime64`
      dtype when possible, otherwise they are converted to :class:`Series` with
      :class:`object` dtype, containing :class:`datetime.datetime`. None/NaN/null
      entries are converted to :const:`NaT` in both cases.

    - **DataFrame/dict-like** are converted to :class:`Series` with
      :class:`datetime64` dtype. For each row a datetime is created from assembling
      the various dataframe columns. Column keys can be common abbreviations
      like ['year', 'month', 'day', 'minute', 'second', 'ms', 'us', 'ns']) or
      plurals of the same.

    The following causes are responsible for :class:`datetime.datetime` objects
    being returned (possibly inside an :class:`Index` or a :class:`Series` with
    :class:`object` dtype) instead of a proper pandas designated type
    (:class:`Timestamp`, :class:`DatetimeIndex` or :class:`Series`
    with :class:`datetime64` dtype):

    - when any input element is before :const:`Timestamp.min` or after
      :const:`Timestamp.max`, see `timestamp limitations
      <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html
      #timeseries-timestamp-limits>`_.

    - when ``utc=False`` (default) and the input is an array-like or
      :class:`Series` containing mixed naive/aware datetime, or aware with mixed
      time offsets. Note that this happens in the (quite frequent) situation when
      the timezone has a daylight savings policy. In that case you may wish to
      use ``utc=True``.

    Examples
    --------

    **Handling various input formats**

    Assembling a datetime from multiple columns of a :class:`DataFrame`. The keys
    can be common abbreviations like ['year', 'month', 'day', 'minute', 'second',
    'ms', 'us', 'ns']) or plurals of the same

    >>> df = pd.DataFrame({'year': [2015, 2016],
    ...                    'month': [2, 3],
    ...                    'day': [4, 5]})
    >>> pd.to_datetime(df)
    0   2015-02-04
    1   2016-03-05
    dtype: datetime64[ns]

    Using a unix epoch time

    >>> pd.to_datetime(1490195805, unit='s')
    Timestamp('2017-03-22 15:16:45')
    >>> pd.to_datetime(1490195805433502912, unit='ns')
    Timestamp('2017-03-22 15:16:45.433502912')

    .. warning:: For float arg, precision rounding might happen. To prevent
        unexpected behavior use a fixed-width exact type.

    Using a non-unix epoch origin

    >>> pd.to_datetime([1, 2, 3], unit='D',
    ...                origin=pd.Timestamp('1960-01-01'))
    DatetimeIndex(['1960-01-02', '1960-01-03', '1960-01-04'],
                  dtype='datetime64[ns]', freq=None)

    **Differences with strptime behavior**

    :const:`"%f"` will parse all the way up to nanoseconds.

    >>> pd.to_datetime('2018-10-26 12:00:00.0000000011',
    ...                format='%Y-%m-%d %H:%M:%S.%f')
    Timestamp('2018-10-26 12:00:00.000000001')

    **Non-convertible date/times**

    Passing ``errors='coerce'`` will force an out-of-bounds date to :const:`NaT`,
    in addition to forcing non-dates (or non-parseable dates) to :const:`NaT`.

    >>> pd.to_datetime('13000101', format='%Y%m%d', errors='coerce')
    NaT

    .. _to_datetime_tz_examples:

    **Timezones and time offsets**

    The default behaviour (``utc=False``) is as follows:

    - Timezone-naive inputs are converted to timezone-naive :class:`DatetimeIndex`:

    >>> pd.to_datetime(['2018-10-26 12:00:00', '2018-10-26 13:00:15'])
    DatetimeIndex(['2018-10-26 12:00:00', '2018-10-26 13:00:15'],
                  dtype='datetime64[ns]', freq=None)

    - Timezone-aware inputs *with constant time offset* are converted to
      timezone-aware :class:`DatetimeIndex`:

    >>> pd.to_datetime(['2018-10-26 12:00 -0500', '2018-10-26 13:00 -0500'])
    DatetimeIndex(['2018-10-26 12:00:00-05:00', '2018-10-26 13:00:00-05:00'],
                  dtype='datetime64[ns, UTC-05:00]', freq=None)

    - However, timezone-aware inputs *with mixed time offsets* (for example
      issued from a timezone with daylight savings, such as Europe/Paris)
      are **not successfully converted** to a :class:`DatetimeIndex`.
      Parsing datetimes with mixed time zones will show a warning unless
      `utc=True`. If you specify `utc=False` the warning below will be shown
      and a simple :class:`Index` containing :class:`datetime.datetime`
      objects will be returned:

    >>> pd.to_datetime(['2020-10-25 02:00 +0200',
    ...                 '2020-10-25 04:00 +0100'])  # doctest: +SKIP
    FutureWarning: In a future version of pandas, parsing datetimes with mixed
    time zones will raise an error unless `utc=True`. Please specify `utc=True`
    to opt in to the new behaviour and silence this warning. To create a `Series`
    with mixed offsets and `object` dtype, please use `apply` and
    `datetime.datetime.strptime`.
    Index([2020-10-25 02:00:00+02:00, 2020-10-25 04:00:00+01:00],
          dtype='object')

    - A mix of timezone-aware and timezone-naive inputs is also converted to
      a simple :class:`Index` containing :class:`datetime.datetime` objects:

    >>> from datetime import datetime
    >>> pd.to_datetime(["2020-01-01 01:00:00-01:00",
    ...                 datetime(2020, 1, 1, 3, 0)])  # doctest: +SKIP
    FutureWarning: In a future version of pandas, parsing datetimes with mixed
    time zones will raise an error unless `utc=True`. Please specify `utc=True`
    to opt in to the new behaviour and silence this warning. To create a `Series`
    with mixed offsets and `object` dtype, please use `apply` and
    `datetime.datetime.strptime`.
    Index([2020-01-01 01:00:00-01:00, 2020-01-01 03:00:00], dtype='object')

    |

    Setting ``utc=True`` solves most of the above issues:

    - Timezone-naive inputs are *localized* as UTC

    >>> pd.to_datetime(['2018-10-26 12:00', '2018-10-26 13:00'], utc=True)
    DatetimeIndex(['2018-10-26 12:00:00+00:00', '2018-10-26 13:00:00+00:00'],
                  dtype='datetime64[ns, UTC]', freq=None)

    - Timezone-aware inputs are *converted* to UTC (the output represents the
      exact same datetime, but viewed from the UTC time offset `+00:00`).

    >>> pd.to_datetime(['2018-10-26 12:00 -0530', '2018-10-26 12:00 -0500'],
    ...                utc=True)
    DatetimeIndex(['2018-10-26 17:30:00+00:00', '2018-10-26 17:00:00+00:00'],
                  dtype='datetime64[ns, UTC]', freq=None)

    - Inputs can contain both string or datetime, the above
      rules still apply

    >>> pd.to_datetime(['2018-10-26 12:00', datetime(2020, 1, 1, 18)], utc=True)
    DatetimeIndex(['2018-10-26 12:00:00+00:00', '2020-01-01 18:00:00+00:00'],
                  dtype='datetime64[ns, UTC]', freq=None)
    >   r   ISO8601z8Cannot use 'exact' when 'format' is 'mixed' or 'ISO8601'zThe argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.rW   r   zerrors='ignore' is deprecated and will raise in a future version. Use to_datetime without passing `errors` and catch exceptions explicitly insteadNr   )r   r   rP   r   r   r   r   )ry   r   r   r7   r   r   rv   rw   ),r   
no_defaultr   r\   r]   r   FutureWarningr   r   r   r}   r   r   r   r   r&   r   emptyr   r   _constructorry   r   r%   r   MutableMapping_assemble_from_unit_mappingsr1   r   r!   r   r
   r   r   r,   r~   r   r   r{   r7   r|   r   rj   bool_)rd   r   rP   r   r   rs   r   r   r   r   rt   ru   r   r   valuesargcr7   rB   rB   rC   r     s     Y



1
/

+(&
" 
	

	r:   yearsr;   monthsr<   daysrF   hrG   rH   mrI   rJ   srK   rL   millisecondmillisecondsrM   microsecondrN   )microsecondsrN   
nanosecondnanosecondsc                   s  ddl m}mm} || } | jjstddd fdd|  D }dd | D }g d	}t	t
|t
|  }t|rOd
|}	td|	 dt	t
| t
t  }
t|
rnd
|
}td| d fdd}|| |d  d || |d  d  || |d   }z
t|d |d}W n ttfy } ztd| |d}~ww g d}|D ]8}||}|dur|| v rz|||| | | d7 }W q ttfy } ztd| d| |d}~ww q|S )a.  
    assemble the unit specified fields from the arg (DataFrame)
    Return a Series for actual parsing

    Parameters
    ----------
    arg : DataFrame
    errors : {'ignore', 'raise', 'coerce'}, default 'raise'

        - If :const:`'raise'`, then invalid parsing will raise an exception
        - If :const:`'coerce'`, then invalid parsing will be set as :const:`NaT`
        - If :const:`'ignore'`, then invalid parsing will return the input
    utc : bool
        Whether to convert/localize timestamps to UTC.

    Returns
    -------
    Series
    r   )r6   
to_numericto_timedeltaz#cannot assemble with duplicate keysc                 S  s,   | t v rt |  S |  t v rt |   S | S r   )	_unit_maplower)valuerB   rB   rC   r     s
   z'_assemble_from_unit_mappings.<locals>.fc                   s   i | ]}| |qS rB   rB   ).0k)r   rB   rC   
<dictcomp>      z0_assemble_from_unit_mappings.<locals>.<dictcomp>c                 S  s   i | ]\}}||qS rB   rB   )r  r  vrB   rB   rC   r    r  )r:   r;   r<   ,zNto assemble mappings requires at least that [year, month, day] be specified: [z] is missingz9extra keys have been passed to the datetime assemblage: [r   c                   s(   |  d} t | jr| jddd} | S )Nr   int64Fr   )r    rx   r   )r   )r   r  rB   rC   r     s   
z,_assemble_from_unit_mappings.<locals>.coercer:   i'  r;   d   r<   z%Y%m%d)rs   r   r   zcannot assemble the datetimes: N)r   r   r   rL   rM   rN   )r   r   zcannot assemble the datetimes [z]: )r{   r6   r  r  columnsr   r   keysitemssortedrn   rl   joinr	  r   r   ro   get)rd   r   r   r6   r  r   unit_revrequiredreq	_requiredexcess_excessr   r   r   unitsur  rB   )r   r   r  rC   r   q  sf   





r   )r   rr   r   )F)rP   rQ   rR   rS   )rc   N)rd   re   rf   rg   rh   ri   rR   rj   )
rd   re   rs   rS   rt   rj   ru   r   rR   r7   )FN)r   r   r   rj   r   r   rR   r1   r   )rd   r   r   r7   r   r   rR   r1   )NFNr   NNT)rs   rS   r   r   r   rj   r   rS   r   r   rP   rQ   r   rQ   r   rj   )
r   rj   r   r[   r   rj   r   r[   rR   r1   )r   rj   r   r[   rR   r1   )
..........)rd   r   r   r   rP   rj   r   rj   r   rj   rs   rS   r   rj   r   rS   r   rj   rt   rj   rR   r   )rd   r   r   r   rP   rj   r   rj   r   rj   rs   rS   r   rj   r   rS   r   rj   rt   rj   rR   r7   )rd   r   r   r   rP   rj   r   rj   r   rj   rs   rS   r   rj   r   rS   r   rj   rt   rj   rR   r2   )rd   r   r   r   rP   rj   r   rj   r   rj   rs   rS   r   r   r   rS   r   r   r   r[   rt   rj   rR   r   )r   r   r   rj   )r
__future__r   collectionsr   datetimer   	functoolsr   	itertoolsr   typingr   r   r	   r
   r   r   r\   numpyr~   pandas._libsr   r   pandas._libs.tslibsr   r   r   r   r   r   r   pandas._libs.tslibs.conversionr   pandas._libs.tslibs.parsingr   r   pandas._libs.tslibs.strptimer   pandas._typingr   r   r   pandas.util._exceptionsr   pandas.core.dtypes.commonr   r   r   r    r!   r"   pandas.core.dtypes.dtypesr#   r$   pandas.core.dtypes.genericr%   r&   pandas.arraysr'   r(   r)   pandas.core.algorithmsr*   pandas.core.arraysr+   pandas.core.arrays.baser,   pandas.core.arrays.datetimesr-   r.   r/   pandas.core.constructionr0   pandas.core.indexes.baser1   pandas.core.indexes.datetimesr2   collections.abcr3   pandas._libs.tslibs.nattyper4   pandas._libs.tslibs.timedeltasr5   r{   r6   r7   r   r   re   rg   r[   Scalar
datetime64r   r   r9   r8   rE   DictConvertiblerm   rb   rr   r   r   r   r   r   r   r   r   r   r	  r   __all__rB   rB   rB   rC   <module>   s0      
<3  

DH   :	

^