
    Mh              
      v   S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
JrJrJrJrJrJr  S SKrS SKrS SKJrJr  S S	KJrJrJrJrJrJr  S S
KJ r   S SK!J"r"J#r#  S SK$J%r%  S SK&J'r'J(r(J)r)  S SK*J+r+  S SK,J-r-J.r.J/r/J0r0J1r1J2r2  S SK3J4r4J5r5  S SK6J7r7J8r8  S SK9J:r:J;r;J<r<  S SK=J>r>  S SK?J@r@  S SKAJBrB  S SKCJDrDJErEJFrF  S SKGJHrH  S SKIJJrJ  S SKKJLrL  \(       a  S SKMJNrN  S SKOJPrP  S SKQJRrR  S SKSJTrTJUrU  \\V\W\'4   rX\\Y\Z4   r[\\[\\R                  4   r]\\]\X4   r^\\V\[   \W\[S4   \'4   r_ " S S \S!S"9r` " S# S$\`S%S"9ra\\aS&4   rbS'rcSOSPS( jjrd SQ       SRS) jjre          SSS* jrf ST       SUS+ jjrg SV       SWS, jjrh       SX               SYS. jjri          SZS/ jrjS[S0 jrkS1 rl\          S\                     S]S2 jj5       rm\          S\                     S^S3 jj5       rm\          S\                     S_S4 jj5       rmS-S%S%S%S\R                  S\R                  S5S!4
                       S`S6 jjrm0 S7S7_S8S7_S9S9_S:S9_S;S;_S<S;_S=S>_S?S>_S@SA_SBSA_SCSD_SESD_SFSF_SGSF_SHSF_SISI_SJSI_SISKSKSKSL.EroSaSM jrp/ SNQrqg)b    )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                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg)YearMonthDayDicte   DatetimeDictArgyearmonthday N__name__
__module____qualname____firstlineno____annotations____static_attributes__r@       M/var/www/html/env/lib/python3.13/site-packages/pandas/core/tools/datetimes.pyr:   r:   e   s    
	rH   r:   T)totalc                  p    \ rS rSr% S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S	'   S\S
'   S\S'   Srg)FulldatetimeDictk   r<   hourhoursminuteminutessecondsecondsmsusnsr@   NrA   r@   rH   rI   rL   rL   k   s8    
rH   rL   Fr7   2   c                   [         R                  " U 5      =nS:w  ae  [        X   =n5      [        L aO  [	        X1S9nUb  U$ [         R                  " XS-   S  5      S:w  a"  [
        R                  " S[        [        5       S9  g )Ndayfirst   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   )arrr[   r_   first_non_nan_elementguessed_formats        rI    _guess_datetime_format_for_arrayrh   ~   s    ..s33:)<<%=D2%N )%% ##C(:(<$=>"DK  /1 rH   c                |   SnUc5  [        U 5      [        ::  a  g[        U 5      S::  a  [        U 5      S-  nO0SnO-SUs=::  a  [        U 5      ::  d    S5       e   S5       eUS:X  a  gSUs=:  a  S:  d   S	5       e   S	5       e [        [        X5      5      n[        U5      X!-  :  a  SnU$ ! [         a     gf = f)
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.
TFi  
   i  r   z1check_count must be in next bounds: [0; len(arg)]r\   z+unique_share must be in next bounds: (0; 1))lenstart_caching_atsetr   	TypeError)argunique_sharecheck_count
do_cachingunique_elementss        rI   should_cachert      s    : J s8''s8tc(b.KK (C(	?>	?(	?>	?(!|aN!NNN!NNfS67 ?k88
	  s   B. .
B;:B;c                   SSK Jn  U" [        S9nU(       a  [        U 5      (       d  U$ [	        U [
        R                  [        [        [        45      (       d  [
        R                  " U 5      n [        U 5      n[        U5      [        U 5      :  aH  U" Xa5      n U" XvSS9nUR                  R                  (       d  XUR                  R!                  5       )    nU$ ! [         a    Us $ f = f)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   r8   dtypeF)indexcopy)pandasr8   objectrt   
isinstancenpndarrayr-   r2   r'   arrayr+   rk   r   ry   	is_unique
duplicated)ro   formatcacheconvert_listliker8   cache_arrayunique_datescache_datess           rI   _maybe_cacher      s    0 v&KC  #

NE9MNN((3-Cc{|s3x'*<@K#$[5Q $$..)+<+<+G+G+I*IJ ' #""#s   C C+*C+c                    [         R                  " U R                  S5      (       a  U(       a  SOSn[        XUS9$ [	        XU R                  S9$ )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
MutcNtzname)r   rx   )r   is_np_dtyperx   r3   r2   )dt_arrayr   r   r   s       rI   _box_as_indexliker     s@    . x~~s++UtX488HNN;;rH   c                    SSK Jn  U" XR                  R                  S9R	                  U5      n[        UR                  SUS9$ )aO  
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{   r8   ry   rx   mapr   _values)ro   r   r   r8   results        rI   _convert_and_box_cacher      s;    ( C00667;;KHFV^^TBBrH   raisec	           	        [        U [        [        45      (       a  [        R                  " U SS9n O+[        U [
        5      (       a  [        R                  " U 5      n [        U SS5      n	U(       a  SOSn
[        U	[        5      (       aN  [        U [        [        45      (       d
  [        X
US9$ U(       a   U R                  S5      R                  S5      n U $ [        U	[        5      (       a  U	R                  [        L a  U(       a  [        U [        5      (       aa  [!        ["        U R                  5      nU	R$                  R&                  b  UR)                  S5      nOUR+                  S5      n[        U5      n U $ U	R$                  R&                  b  U R)                  S5      n U $ U R+                  S5      n U $ [,        R.                  " U	S5      (       a  [1        U	5      (       d6  [3        [        R4                  " U 5      [        R6                  " S	5      US
:H  S9n [        U [        [        45      (       d
  [        X
US9$ U(       a  U R                  S5      $ U $ Ub  Ub  [9        S5      e[;        XX#U5      $ [        U SS5      S:  a  [=        S5      e [?        U S[@        RB                  " U
5      S9u  p[I        U 5      n Uc	  [K        XS9nUb  US:w  a  [M        XX1X5      $ [O        U UUUUSS9u  nnUb  [        RP                  " UR6                  5      S   n[!        [        [S        UU5      5      nURU                  SURV                   S35      n[        RX                  " UUS9n[        RX                  " UUS9$ [[        XUS9$ ! [<         aT    US
:X  a9  [        R                  " S/SS9RE                  [G        U 5      5      n[        XS9s $ US:X  a  [        XS9nUs $ e f = f)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ndimr\   zAarg must be a string, datetime, list, tuple, 1-d array, or SeriesF)rz   r   NaTzdatetime64[ns]r   ignorerZ   mixedT)r[   	yearfirstr   errorsallow_objectr   M8[]r   ).r}   listtupler~   r   r*   getattrr%   r(   r3   
tz_converttz_localizer$   r`   r   r2   r   r,   pyarrow_dtyper   _dt_tz_convert_dt_tz_localizer   r   r   r   asarrayrx   
ValueError_to_datetime_with_unitrn   r.   libtimezonesmaybe_get_tzrepeatrk   r   rh   _array_strptime_with_fallbackr/   datetime_datar0   viewunit_simple_newr   )ro   r   r   r   r   r   r[   r   exact	arg_dtyper   	arg_array_npvaluesidxr   	tz_parsedout_unitrx   dt64_valuesdtas                        rI   _convert_listlike_datetimesr   :  s   L #e}%%hhs#&	C,	-	-hhsmWd+I4B)_--#}=>> $77..&2259C
	Iz	*	*y~~/J#u%% !4cii@	**--9 ) 8 8 ?I ) 9 9% @II& 
	 **--9,,U3C 
 --e4C
	C	(	(!),,%

3! H,	C #}=>> $77??5))
		BCC%cFCC	fa	 1	$O
 	
	$Su9R9RSU9VW 
C~1#I f/,SUSS-FI  ##FLL1!4_k)X&FGkkC

|1"56''5A((488V488I  Xxx/?@GGCQH 55x'CJs   !N AO&O&$O&c                   [        XXEUS9u  pgUba  [        R                  " UR                  5      S   n[	        XxS9n	[
        R                  " XiS9n
U(       a  U
R                  S5      n
[        XS9$ UR                  [        :w  a;  U(       a4  [        R                  " UR                  5      S   n[        USU S3US	9nU$ [        XfR                  US	9$ )
zD
Call array_strptime, with fallback behavior depending on 'errors'.
)r   r   r   r   )r   r   rw   r   r   r   z, UTC])rx   r   )
r   r~   r   rx   r%   r(   r   r   r2   r|   )ro   r   r   fmtr   r   r   tz_outr   rx   r   ress               rI   r   r     s     $CEcRNF-a065''<..'CS$$		C-a0FCvV"44@
||$77rH   c           	        [        U SS9n [        U [        5      (       a  U R                  SU S35      nSnO[        R
                  " U 5      n U R                  R                  S;   a7  U R                  SU S3SS9n [        U[        R                  " S	5      SS9nSnOU R                  R                  S:X  a<  [        R                  " S
S9    [        XS9n SSS5        WR                  S	5      nSnO+U R                  [        SS9n [        R                   " XUS9u  pVUS:X  a  ["        R$                  " XRS9nO	['        XRS9n[        U[&        5      (       d  U$ UR)                  S5      R+                  U5      nU(       a1  UR,                  c  UR)                  S5      nU$ UR+                  S5      nU$ ! [         a,    US
:X  a  e U R                  [        5      n [        XX#U5      s $ f = f! [         aA    US
:w  a+  [        U R                  [        5      XX45      s sSSS5        $ [        SU S35      ef = f! , (       d  f       GNj= f)z>
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   )r1   r}   r)   astyper~   r   rx   kindr   r   r|   r   errstater   r   r   array_with_unit_to_datetimer2   _with_inferr3   r   r   r   )ro   r   r   r   r   re   r   r   s           rI   r   r     s.    4
0C #|$$jj;tfA./	jjo99>>T! **{4&2*?CL)#rxx/AN IYY^^s"'*	3CCC + ((8$CI**V%*0C">>sQWXNC""32s.fm,,
 &11)<F
99''.F M &&u-FM[ ' LW$jj(-cFKK	L + (5JJv.C   +* .:4&B  +*s<   =F5 H<	G.53G+*G+.0H9H<)H99H<<
Ic                   US:X  a  U n[        S5      R                  5       nUS:w  a  [        S5      e X-
  n [         R                  R                  5       U-
  n[         R
                  R                  5       U-
  n[        R                  " X:  5      (       d  [        R                  " X:  5      (       a  [        U S35      e U $ [        U 5      (       dF  [        U 5      (       d6  [        [        R                  " U 5      5      (       d  [        SU  S	U S
35      e [        XS9nUR                  b  [        SU S35      eU[        S5      -
  n	U	[        SUS9-  n
[        U 5      (       a@  [!        U ["        [$        [        R&                  45      (       d  [        R                  " U 5      n X
-   n U $ ! [         a  n[        S5      UeSnAff = f! [         a  n[        SU S35      UeSnAf[         a  n[        SU S35      UeSnAff = f)aV  
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-naiver\   )r   to_julian_dater   rn   maxminr~   anyr   r    r   r#   r   r   r   r"   r}   r'   r2   r   )ro   originr   originalj0errj_maxj_minoffset	td_offsetioffsets              rI   _adjust_to_originr   &  s   $ q\((*3;CDD	(C ,,.3,,.366#+"&&"5"5%*AB  #6H J; __2B2::c?2S2SC59& B; ; 	v1F 99 ~fX5FGHHYq\)	 y66 Zi

5S%T%T**S/CmJY  	E	2 # 	T%x7H&IJPSS 	&!DE	s;   F2 	G 2
G<GG
HG**H7HHc                    g Nr@   ro   r   r[   r   r   r   r   r   infer_datetime_formatr   r   s              rI   to_datetimer   n       rH   c                    g r   r@   r   s              rI   r   r     r   rH   c                    g r   r@   r   s              rI   r   r     r   rH   unixc           
        U[         R                  La  US;   a  [        S5      eU[         R                  La  [        R                  " S[        5       S9  US:X  a"  [        R                  " S[        [        5       S9  U c  gU	S:w  a  [        X	U5      n [        [        UUUUUUS	9n[        U [        5      (       a<  U nU(       a1  U R                  b  U R                  S
5      nU$ U R                  S
5      nU$ [        U [        5      (       aj  [!        XX5      nUR"                  (       d  U R%                  U5      nU$ U" U R&                  U5      nU R)                  XR*                  U R,                  S9n U$ [        U [.        [0        R2                  45      (       a  [5        XU5      nU$ [        U [6        5      (       aG  [!        XX5      nUR"                  (       d  [9        XU R,                  S9nU$ U" XU R,                  S9n U$ [;        U 5      (       ao   [=        [>        [@        [B        [D        [F        RH                  S[6        4   U 5      n[!        XX5      nUR"                  (       d  [9        WU5      nU$ U" WU5      n U$ U" [F        RR                  " U /5      U5      S   n[        U [T        5      (       a*  [        U[F        RV                  5      (       a  [U        U5      nU$ ! [J         a    US:X  a  e SSK&J'n  U" / [P        S9n Nf = f)a/6  
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.r]   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   r[   r   r   r   r   )ry   r   r   r8   r   r   rv   rw   ),r   
no_defaultr   rb   rc   r   FutureWarningr   r   r   r}   r   r   r   r   r'   r   emptyr   r   _constructorry   r   r&   r   MutableMapping_assemble_from_unit_mappingsr2   r   r"   r   r   r   r   r-   r~   r   r   r{   r8   r|   r   boolbool_)ro   r   r[   r   r   r   r   r   r   r   r   r   r   r   valuesargcr8   s                    rI   r   r     s   n
 CNN"v1E'ESTTCNN23
 ()	
 ! ')	
 {T2# #y!!vv!.b M_ /^ M] 
C	#	#"3H  WW[)FV MS &ckk6:F%%fIICHH%MFP MO 
C,(:(:;	<	<-c3?L MK 
C		"3H  +C388LFD MA &cAF@ M? 
c			3
 dE>2::xNOQTD 'tUMK   +D+>F M &dF3F M ""((C5/6:1=c4  Z%A%A&\F
 M+ # 	3  % 62K	3s   AK& &"L
Lr=   yearsr>   monthsr?   daysrN   hrO   rP   mrQ   rR   srS   rT   millisecondmillisecondsrU   microsecondrV   )microsecondsrV   
nanosecondnanosecondsc                v  ^^ SSK JnJmJn  U" U 5      n U R                  R
                  (       d  [        S5      eS nU R                  5        Vs0 s H  ofU" U5      _M     nnUR                  5        VVs0 s H  u  phX_M	     n	nn/ SQn
[        [        U
5      [        U	R                  5       5      -
  5      n[        U5      (       a   SR                  U5      n[        SU S35      e[        [        U	R                  5       5      [        [        R                  5       5      -
  5      n[        U5      (       a   SR                  U5      n[        S	U S
35      eUU4S jnU" X	S      5      S-  U" X	S      5      S-  -   U" X	S      5      -   n [        USTUS9n/ SQnU H6  nU	R#                  U5      nUc  M  UU ;   d  M!   UU" U" U U   5      UTS9-  nM8     U$ s  snf s  snnf ! [         [        4 a  n[        SU 35      UeSnAff = f! [         [        4 a  n[        SU SU 35      UeSnAff = f)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   )r7   
to_numericto_timedeltaz#cannot assemble with duplicate keysc                    U [         ;   a	  [         U    $ U R                  5       [         ;   a  [         U R                  5          $ U $ r   )	_unit_maplower)values    rI   r   '_assemble_from_unit_mappings.<locals>.f  s;    IU## ;;=I%U[[]++rH   )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                j   > T" U TS9n [        U R                  5      (       a  U R                  SSS9n U $ )Nr   int64Fr   )r!   rx   r   )r   r   r  s    rI   r   ,_assemble_from_unit_mappings.<locals>.coerce  s7    F62 FLL))]]7]7FrH   r=   i'  r>   d   r?   z%Y%m%d)r   r   r   zcannot assemble the datetimes: N)r  r  r  rT   rU   rV   )r   r   zcannot assemble the datetimes [z]: )r{   r7   r  r  columnsr   r   keysitemssortedrm   rk   joinr  r   r   rn   get)ro   r   r   r7   r  r   kr   vunit_revrequiredreq	_requiredexcess_excessr   r   r   unitsur  r  s    `                   @rI   r   r   q  sQ   (  C.C;;  >?? !XXZ(ZqtGZD(!%.H. (H
XX]]_!55
6C
3xxHHSM	11:<I
 	
 C(3y/?/?/A+BBCF
6{{((6"GyPQR
 	
 	sF#$%-
g&'
(3
.	/
e_%
&	' 
KVHVM  AEQ#,vc%j'9&QQ	  Me ).H z" K:3%@AsJK z*  5eWCuEs<   G7G$G* H*H:H		HH8!H33H8)r   rt   r   )F)r[   bool | Nonereturn
str | None)gffffff?N)ro   ArrayConvertiblerp   floatrq   z
int | Noner)  r   )
ro   r+  r   r*  r   r   r   r	   r)  r8   )FN)r   r   r   r   r   Hashable | Noner)  r2   r   )ro    DatetimeScalarOrArrayConvertibler   r8   r   r-  r)  r2   )NFNr   NNT)r   r*  r   r-  r   r   r   r*  r   r   r[   r(  r   r(  r   r   )
r   r   r   ra   r   r   r   ra   r)  r2   )r   r   r   ra   r)  r2   )
..........)ro   DatetimeScalarr   r   r[   r   r   r   r   r   r   r*  r   r   r   r*  r   r   r   r   r)  r   )ro   zSeries | DictConvertibler   r   r[   r   r   r   r   r   r   r*  r   r   r   r*  r   r   r   r   r)  r8   )ro   z list | tuple | Index | ArrayLiker   r   r[   r   r   r   r   r   r   r*  r   r   r   r*  r   r   r   r   r)  r3   )ro   z2DatetimeScalarOrArrayConvertible | DictConvertibler   r   r[   r   r   r   r   r   r   r*  r   zbool | lib.NoDefaultr   r*  r   zlib.NoDefault | boolr   ra   r   r   r)  z8DatetimeIndex | Series | DatetimeScalar | NaTType | None)r   r   r   r   )r
__future__r   collectionsr   datetimer   	functoolsr   	itertoolsr   typingr   r	   r
   r   r   r   rb   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/   r0   pandas.core.constructionr1   pandas.core.indexes.baser2   pandas.core.indexes.datetimesr3   collections.abcr4   pandas._libs.tslibs.nattyper5   pandas._libs.tslibs.timedeltasr6   r{   r7   r8   r   r   r+  r,  ra   Scalar
datetime64r/  r.  r<   r:   rL   DictConvertiblerl   rh   rt   r   r   r   r   r   r   r   r   r   r  r   __all__r@   rH   rI   <module>rP     s6   "         E 8 
 5 
 
 * 2 2 
 3 * 7(3: ul23 	ucz	vtR]]23#(9I)I#J  VeFCK&8,FGy 	'u 	 (+56 0 QU9	9).9CM9	9x/	// / 	/
 /f EI<<"<2A<
<@ !C	)CC C 	C: !#* !K9K9 K9 
	K9
 K9 !K9 K9 K9 K9\8 
8 
	8
 8 8 84AHEP 
 $'"%	   	
 
        
  
 $'"%	!   	
 
        
  
 $'"%	)   	
 
        
$ $+"%..25..s	;s s s 	s
 
s s  s s 0s s s >sn
FV W g	
 
5 E C S c s c s 	$ 4 D  	$!" 4#$ 
+	2[|rH   