
    `Vg$                    L   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mZmZmZ d dlZd dlZd dlmZ d d	lmZmZmZmZmZmZ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)m*Z*m+Z+ d dl,m-Z- d dl.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8 d dl9m:Z:m;Z; d dl<m=Z= d dl>m?Z?m@Z@ d dlAmBZB d dlCmDZD d dlEmFZF d dlGmHZHmIZImJZJ d dlKmLZL d dlMmNZN d dlOmPZP e
rd dlQmRZR d dlSmTZT d dlUmVZVmWZW eeee'f   ZXeeYeZf   Z[ee[ef   Z\ee\eXf   Z]eee[   ee[df   e'f   Z^ G d ded       Z_ G d! d"e_d#       Z`ee`d$f   Zad%ZbdOdPd&Zc	 dQ	 	 	 	 	 	 	 dRd'Zd	 	 	 	 	 	 	 	 	 	 dSd(Ze	 dT	 	 	 	 	 	 	 dUd)Zf	 dV	 	 	 	 	 	 	 dWd*ZgdXd+Zh	 	 	 	 	 	 	 	 dY	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dZd,Zi	 	 	 	 	 	 	 	 	 	 d[d-Zj	 	 	 	 	 	 	 	 	 	 d[d.Zkd\d/Zld0 Zme	 	 	 	 	 	 	 	 	 	 d]	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d^d1       Zne	 	 	 	 	 	 	 	 	 	 d]	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d_d2       Zne	 	 	 	 	 	 	 	 	 	 d]	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d`d3       Zn	 	 	 	 	 	 	 	 	 	 da	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dbd4Zni d5d5d6d5d7d7d8d7d9d9d:d9d;d<d=d<d>d?d@d?dAdBdCdBdDdDdEdDdFdDdGdGdHdGdGdIdIdIdJZodcdKZpdddLZqdedMZrg dNZsy)f    )annotations)abc)datetime)partial)islice)	TYPE_CHECKINGCallableHashableListTuple	TypedDictUnioncastoverloadN)tslib)OutOfBoundsDatetime	Timedelta	TimestampiNaTnat_stringsparsing	timezones)DateParseErrorformat_is_isoguess_datetime_format)array_strptime)AnyArrayLike	ArrayLikeDateTimeErrorChoicesTimezonenpt)find_stack_level)
ensure_objectis_datetime64_dtypeis_datetime64_ns_dtypeis_datetime64tz_dtypeis_float
is_integeris_integer_dtypeis_list_likeis_numeric_dtype	is_scalar)ABCDataFrame	ABCSeries)notna)DatetimeArrayIntegerArray)
algorithms)unique)ExtensionArray)maybe_convert_dtypeobjects_to_datetime64nstz_to_dtype)extract_array)Index)DatetimeIndex)NaTType)UnitChoices)	DataFrameSeries.c                  ,    e Zd ZU ded<   ded<   ded<   y)YearMonthDayDictDatetimeDictArgyearmonthdayN__name__
__module____qualname____annotations__     \/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/pandas/core/tools/datetimes.pyr@   r@   f   s    
	rK   r@   T)totalc                  h    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
<   y)FulldatetimeDictrA   hourhoursminuteminutessecondsecondsmsusnsNrE   rJ   rK   rL   rO   rO   l   s8    
rK   rO   Fr=   2   c                x    t        |       j                         d   }t        |      rt        | |d      |      S y )Nr   dayfirst)r/   nonzerolenr   )arrr\   non_nan_elementss      rL    _guess_datetime_format_for_arrayra      s@    Sz))+A.
$S)9!)<%=QQ rK   c                j   d}|3t        |       t        k  ryt        |       dk  rt        |       dz  }n,d}n)d|cxk  rt        |       k  sJ d        J d       |dk(  ryd|cxk  rdk  sJ d	        J d	       	 t        t        | |            }t        |      ||z  kD  rd}|S # t        $ r Y yw xY w)
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)]   z+unique_share must be in next bounds: (0; 1))r^   start_caching_atsetr   	TypeError)argunique_sharecheck_count
do_cachingunique_elementss        rL   should_cacherm      s    : J s8''s8tc(b.KK (C(	?>	?(	?>	?(!|aN!NNN!NNfS+67 ?kL88
	  s   <B& &	B21B2c                @   ddl m}  |t              }|rwt        |       s|S t	        |       }t        |      t        |       k  rH |||      }	  |||      }|j                  j                  s||j                  j                             }|S # t        $ r |cY S w xY w)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   r>   dtype)index)
pandasr>   objectrm   r3   r^   r   rr   	is_unique
duplicated)rh   formatcacheconvert_listliker>   cache_arrayunique_datescache_datess           rL   _maybe_cacher}      s    0 v&KC c{|s3x'*<@K#$[E $$..);+<+<+G+G+I*IJ ' #""#s   
B BBc                p    t        |       r|rdnd}t        | ||      S t        | || j                        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.
    tz : object
        None or '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
    utcNtzname)r   rq   )r$   r:   r9   rq   )dt_arrayr   r   r   s       rL   _box_as_indexliker      s7    . 8$UtX"488HNN;;rK   c                l    ddl m}  ||       j                  |      }t        |j                  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   ro   Nr   r   )rs   r>   mapr   _values)rh   rz   r   r>   results        rL   _convert_and_box_cacher     s,    ( C[__[)FV^^DAArK   c           	     .   t        j                  t        | |      D cg c]  \  }}t        |      j	                  |      ! c}}      }|2t        j                  |D cg c]  }|j                  |       c}      }t        ||      S c c}}w c c}w )a  
    Return results from array_strptime if a %z or %Z directive was passed.

    Parameters
    ----------
    result : ndarray[int64]
        int64 date representations of the dates
    timezones : ndarray
        pytz timezone objects
    tz : object
        None or pytz timezone object
    name : string, default None
        Name for a DatetimeIndex

    Returns
    -------
    tz_result : Index-like of parsed dates with timezone
    r   )nparrayzipr   tz_localize
tz_convertr9   )r   r   r   r   reszone
tz_results	tz_results           rL   _return_parsed_timezone_resultsr   (  s~    & ;>vy;QRic43	#	#D	)RJ 
~XXTIy33B7TU
$'' 	S Us   $B
 Bc
           
        t        | t        t        f      rt        j                  | d      } t        | dd      }
t        |
      rKt        | t        t        f      st        | ||      S |dk(  r | j                  d      j                  |      } | S t        |
      r:t        | t        t        f      s	 t        | ||      S |r| j                  |      S | S ||t        d      t        | ||||      S t        | dd	      d	kD  rt        d
      | }	 t        | dt!        j"                  |            \  } }t+        |       } d}|r|t-        | |      }|t/        |      }|r| }d}|t1        | |||||	||      }||S ||sJ |dk(  }t3        | |||||d      \  }}|-t        |t5        |            }t        j6                  ||      S |dk(  }t9        |||      S # t        $ r Y | S w xY w# t        $ r\ |dk(  r?t        j                  dgd      j%                  t'        |             }t        ||      cY S |dk(  rt)        | |      }|cY S  w xY w)aS  
    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
    tz : object
        None or 'utc'
    unit : str
        None or string of the frequency of the passed data
    errors : str
        error handing behaviors from to_datetime, 'raise', 'coerce', 'ignore'
    infer_datetime_format : bool, default False
        inferring format behavior from to_datetime
    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
    Orp   rq   Nr   r   z#cannot specify both format and unitndimrd   zAarg must be a string, datetime, list, tuple, 1-d array, or SeriesF)copyr   coerceNaTzdatetime64[ns]r   ignorer[   T)r\   	yearfirstr   errorsrequire_iso8601allow_objectr   )
isinstancelisttupler   r   getattrr&   r0   r:   r   r   r%   
ValueError_to_datetime_with_unitrg   r5   r   maybe_get_tzrepeatr^   r9   r#   ra   r   _to_datetime_with_formatr6   r7   _simple_newr   )rh   rw   r   r   unitr   infer_datetime_formatr\   r   exact	arg_dtypeorig_arg_npvaluesidxr   format_is_iso8601r   r   r   	tz_parseddtas                         rL   _convert_listlike_datetimesr   E  s   R #e}%hhs#&Wd+IY'#}=> $77;..&2226C
			*#}=>$SRd;; ??2&&
		BCC%c4r6BB	fa	 1	$O
 	
 H	$Su9O9OPR9STQ 
CO1#I
 *&1"77OF&4VUF<Q
 ?J>222
+C/'FI  F+i*@A((488
+CV488S  
 
,  Xxx/?@GGCQH 55x$'CJs+   3G" $G2 "	G/.G/2AI?IIc                
   |dk(  }	 t        | |||      \  }}	d|v sd|v rt        ||	||      S t        |||      S # t        $ rX |dk(  r |dk(  rHt        j                  | j
                  d      }|j                  d	      }
|
j                  t               n| }Y nt        $ r] |sV|dk(  r |dk(  rHt        j                  | j
                  d      }|j                  d	      }
|
j                  t               n| }nY y
Y w xY w)zL
    Call array_strptime, with fallback behavior depending on 'errors'.
    r   )r   r   z%Zz%zraiser   M8[ns]rp   i8Nr   )r   r   r   r   emptyshapeviewfillr   r   r   )rh   r   r   fmtr   r   r   r   r   r   iresults              rL   _array_strptime_with_fallbackr     s    +CP*35P	6 3;$#+269b$OOV488;  WxXXciix8Fkk$'GLLF  % 8##))8< ++d+T" s   = ADA DDc           	         d}|dk(  r.t        |      }	 t        ||      }||dk(  }
t        ||
|      S t        | ||||||      }|S # t        t        t        f$ r}	t        d      |	d}	~	ww xY w)zG
    Try parsing with the given format, returning None on failure.
    N%Y%m%dr   z0cannot convert the input to '%Y%m%d' date formatr   r   )r#   _attempt_YYYYMMDDr   rg   r   r   r   )rh   r   r   r   r   r   r   r   r   errr   r   s               rL   r   r     s     F h !*	&x?F
 +C$V4@@ (T2sE6+@C J I':; 	B	s   A	 	A.A))A.c                   t        | d      } t        | t              r| j                  d| d      }d}n0t	        j
                  |       } t        j                  | ||      \  }}|dk(  rt        j                  ||      }nt        ||      }t        |t              s|S |j                  d	      j                  |      }|0|j                  |j                  |      }|S |j                  |      }|S )
zF
    to_datetime specalized to the case where a 'unit' is passed.
    T)extract_numpyzdatetime64[]Nr   r   r   UTC)r8   r   r1   astyper   asarrayr   array_with_unit_to_datetimer9   _with_inferr:   r   r   r   )rh   r   r   r   r   r_   r   r   s           rL   r   r      s     4
0C #|$jj;tfA./	jjo::3VTY""3T2s.fm,
 &11)<F	~99''+F M &&r*FMrK   c                   |dk(  r| }t        d      j                         }|dk7  rt        d      	 | |z
  } t         j                  j                         |z
  }t         j
                  j                         |z
  }t        j                  | |kD        st        j                  | |k        rt        | d      | S t        |       rt        |       s;t        |       s0t        t        j                  |             st        d|  d	| d
      	 t        |      }|j                  t        d| d      |t        d      z
  }	|	t        d|      z  }
t!        |       r:t#        | t$        t&        t        j(                  f      st        j                  |       } | |
z   } | S # t        $ r}t        d      |d}~ww xY w# t        $ r}t        d| d      |d}~wt        $ r}t        d| d      |d}~ww xY w)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''z!' is not compatible with origin='z+'; it must be numeric with a unit specifiedzorigin z is Out of Boundsz# cannot be converted to a Timestampzorigin offset z must be tz-naiverd   )r   )r   to_julian_dater   rg   maxminr   anyr   r,   r(   r'   r+   r   r   r   r*   r   r.   r9   ndarray)rh   originr   originalj0r   j_maxj_minoffset	td_offsetioffsets              rL   _adjust_to_originr   E  s   $ q\((*3;CDD	(C ,,.3,,.366#+"&&u"5%*AB H J= s^CHSM

30C59& B; ; 	v&F 99 ~fX5FGHHYq\)	 y66 Zi

5S%T**S/CGmJ[  	E	4 # 	T%x7H&IJPSS 	&!DE	s;   F F8 	F5$F00F58	G2GG2G--G2c                     y NrJ   rh   r   r\   r   r   rw   r   r   r   r   rx   s              rL   to_datetimer          rK   c                     y r   rJ   r   s              rL   r   r     r   rK   c                     y r   rJ   r   s              rL   r   r     r   rK   c           
        | y|	dk7  rt        | |	|      } |rdnd}t        t        |||||||      }t        | t              r6| }|0| j
                  | j                  |      }|S | j                  |      }|S t        | t              rjt        | ||
|      }|j                  s| j                  |      }|S  || j                  |      }| j                  || j                  | j                        }|S t        | t         t"        j$                  f      rt'        | ||      }|S t        | t(              rKt        | ||
|      }|j                  st+        | || j                        }|S  || || j                        }|S t-        |       rk	 t/        t0        t2        t4        t6        t8        j:                  dt(        f   |       }t        |||
|      }|j                  st+        |      }|S  ||      }|S  |t9        jD                  | g      |      d	   }t        | tF              r%t        |t8        jH                        rtG        |      }|S # t<        $ r |dk(  r d	d
lm }  |g tB              }Y w xY w)uF7  
    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"`.
    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. If a delimited date string cannot be parsed in
            accordance with the given `dayfirst` option, e.g.
            ``to_datetime(['31-12-2021'])``, then a warning will be shown.

    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 None
        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.

        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"`. Note that
        :const:`"%f"` will parse all the way up to nanoseconds. See
        `strftime documentation
        <https://docs.python.org/3/library/datetime.html
        #strftime-and-strptime-behavior>`_ for more information on choices.
    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.

    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.
    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, origin is set to Timestamp identified by
          origin.
    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.

        .. versionchanged:: 0.25.0
            changed default value from :const:`False` to :const:`True`.

    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]

    Passing ``infer_datetime_format=True`` can often-times speedup a parsing
    if its not an ISO8601 format exactly, but in a regular format.

    >>> s = pd.Series(['3/11/2000', '3/12/2000', '3/13/2000'] * 1000)
    >>> s.head()
    0    3/11/2000
    1    3/12/2000
    2    3/13/2000
    3    3/11/2000
    4    3/12/2000
    dtype: object

    >>> %timeit pd.to_datetime(s, infer_datetime_format=True)  # doctest: +SKIP
    100 loops, best of 3: 10.4 ms per loop

    >>> %timeit pd.to_datetime(s, infer_datetime_format=False)  # doctest: +SKIP
    1 loop, best of 3: 471 ms per loop

    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)

    **Non-convertible date/times**

    If a date does not meet the `timestamp limitations
    <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html
    #timeseries-timestamp-limits>`_, passing ``errors='ignore'``
    will return the original input instead of raising any exception.

    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='ignore')
    datetime.datetime(1300, 1, 1, 0, 0)
    >>> 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', '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, pytz.FixedOffset(-300)]', 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`. Instead a
      simple :class:`Index` containing :class:`datetime.datetime` objects is
      returned:

    >>> pd.to_datetime(['2020-10-25 02:00 +0200', '2020-10-25 04:00 +0100'])
    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 converted to
      a timezone-aware :class:`DatetimeIndex` if the offsets of the timezone-aware
      are constant:

    >>> from datetime import datetime
    >>> pd.to_datetime(["2020-01-01 01:00 -01:00", datetime(2020, 1, 1, 3, 0)])
    DatetimeIndex(['2020-01-01 01:00:00-01:00', '2020-01-01 02:00:00-01:00'],
                  dtype='datetime64[ns, pytz.FixedOffset(-60)]', freq=None)

    |

    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 naive and aware, string or datetime, the above
      rules still apply

    >>> from datetime import timezone, timedelta
    >>> pd.to_datetime(['2018-10-26 12:00', '2018-10-26 12:00 -0530',
    ...                datetime(2020, 1, 1, 18),
    ...                datetime(2020, 1, 1, 18,
    ...                tzinfo=timezone(-timedelta(hours=1)))],
    ...                utc=True)
    DatetimeIndex(['2018-10-26 12:00:00+00:00', '2018-10-26 17:30:00+00:00',
                   '2020-01-01 18:00:00+00:00', '2020-01-01 19:00:00+00:00'],
                  dtype='datetime64[ns, UTC]', freq=None)
    Nunixr   )r   r   r\   r   r   r   r   )rr   r   r   r>   r   r   ro   rp   )%r   r   r   r   r   r   r   r   r.   r}   r   r   r   _constructorrr   r   r-   r   MutableMapping_assemble_from_unit_mappingsr9   r   r*   r   r   r   r   r4   r   r   r   rs   r>   rt   r   boolbool_)rh   r   r\   r   r   rw   r   r   r   r   rx   r   ry   r   rz   valuesargcr>   s                     rL   r   r     s   V
 {VT24B#3	 #y!>vv!+b M_ ,^ M] 
C	#"37GH  WW[)FV MS &ckk6:F%%fCIICHH%MFP MO 
C,(:(:;	<-c62>L MK 
C	"37GH  +C388LFD MA &c6AF@ M? 
c		3
 dE>2::xNOQTD 'tVU<LMK   +D+>F M &dF3F M ""((C5/6:1=c4 Z%A&\F
 M+ # 	3  % 62K	3s   	AI
 
#I0/I0rB   yearsrC   monthsrD   daysrP   hrQ   rR   mrS   rT   srU   rV   millisecondmillisecondsrW   microsecondrX   )microsecondsrX   
nanosecondnanosecondsc                P   ddl m}mm}  ||       } | j                  j
                  st        d      d }| j                         D ci c]  }| ||       }}|j                         D ci c]  \  }}||
 }	}}g d}
t        t        |
      t        |	j                               z
        }t        |      r dj                  |      }t        d| d      t        t        |	j                               t        t        j                               z
        }t        |      r dj                  |      }t        d	| d
      fd} || |	d            dz   || |	d            dz  z    || |	d            z   }	 t        |d|      }g d}|D ]3  }|	j#                  |      }||| v s	 | | || |         |      z  }5 |S c c}w c c}}w # t         t        f$ r}t        d|       |d}~ww xY w# t         t        f$ r}t        d| d|       |d}~ww xY w)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
    tz : None or 'utc'

    Returns
    -------
    Series
    r   )r=   
to_numericto_timedeltaz#cannot assemble with duplicate keysc                    | t         v r	t         |    S | j                         t         v rt         | j                            S | S r   )	_unit_maplower)values    rL   fz'_assemble_from_unit_mappings.<locals>.f  s;    IU## ;;=I%U[[]++rK   )rB   rC   rD   ,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                X     |       } t        |       r| j                  dd      } | S )Nr   int64Fr   )r)   r   )r   r   r   s    rL   r   z,_assemble_from_unit_mappings.<locals>.coerce  s0    F62 F#]]7]7FrK   rB   '  rC   d   rD   r   )rw   r   r   zcannot assemble the datetimes: N)r   r   r   rV   rW   rX   )r   r   zcannot assemble the datetimes [z]: )rs   r=   r   r   columnsru   r   keysitemssortedrf   r^   joinr  r   r   rg   get)rh   r   r   r=   r   r  kr   vunit_revrequiredreq	_requiredexcess_excessr   r   r   unitsur  r   s    `                   @rL   r   r   r  s\   &  C.C;;  >?? !XXZ(AqtG(D(!%.A1.H. (H
XX]]_!55
6C
3xHHSM	11:<I
 	
 C(3y/?/?/A+BBCF
6{((6"GyPQR
 	
 	s8F#$%-
Xg&'
(3
.	/
Xe_%
&	' 
KVHVL  AE Q#,vc%j'9&QQ	 Me ).H z" K:3%@AsJK z*  5eWCuEs<   G0GG 3G?G<(G77G<?H%H  H%c                   fdfd}	  | j                  t        j                              S # t        t        t
        f$ r Y nw xY w	 | j                  t        j                        } ||t        |            S # t        t        t
        f$ r Y nw xY w	 t        j                  | t        t                     } || |      S # t        t        t
        f$ r Y yw xY w)a*  
    try to parse the YYYYMMDD/%Y%m%d format, try to deal with NaT-like,
    arg is a passed in as an object dtype, but could really be ints/strings
    with nan-like/or floats (e.g. with nan)

    Parameters
    ----------
    arg : np.ndarray[object]
    errors : {'raise','ignore','coerce'}
    c                    | j                  t        d      } t        j                  | dz  | dz  dz  | dz        }t	        j
                  |      d   S )NFr	  r
  r  r   r   )r   rt   r   try_parse_year_month_dayr   array_to_datetime)cargparsedr   s     rL   calcz_attempt_YYYYMMDD.<locals>.calc  sW    {{6{.115L$*s*D3J
 &&vf=a@@rK   c                2   t        j                  | j                  d      }|j                  d      }t        || <    | |   j                  t         j                        j                  t         j                              }|j                  d      ||<   |S )Nr   rp   r   )r   r   r   r   r   r   float64r  )r   maskr   r   masked_resultr"  s        rL   calc_with_maskz)_attempt_YYYYMMDD.<locals>.calc_with_mask  su    $**H5++d#T$Z..rzz:AA"((KL$++H5trK   N)r   r   r  r   OverflowErrorrg   r$  r/   r2   isinr   r   )rh   r   r'  r   r%  r"  s    `   @rL   r   r     s    ACJJrxx())y1 zz"**%dE$K00y1  T+%677c4((y1 s3   $3 A
	A
0A? ?BB,C CCc                l    t        j                  dt        t                      ddlm}  || |||      S )Nzz`to_time` has been moved, should be imported from pandas.core.tools.times. This alias will be removed in a future version.)
stacklevelr   )to_time)warningswarnFutureWarningr"   pandas.core.tools.timesr,  )rh   rw   infer_time_formatr   r,  s        rL   r,  r,    s3    MM	:#%	 03 16::rK   )r   rm   r   r,  )F)r\   bool | None)gffffff?N)rh   ArrayConvertibleri   floatrj   z
int | Nonereturnr   )
rh   r3  rw   
str | Nonerx   r   ry   r	   r5  r>   )NN)r   r   r   r2  r   r
   r5  r9   r   )rh    DatetimeScalarOrArrayConvertiblerz   r>   r   zHashable | Noner5  r9   )r   z
np.ndarrayr5  r9   )NNNr   FNNT)rw   r6  r   r
   r   zTimezone | Noner   r6  r   strr   r   r\   r2  r   r2  r   r   )
r   r8  r   r   r   r8  r   r   r5  zIndex | None)r   r8  r5  r9   )
..........)rh   DatetimeScalarr   r   r\   r   r   r   r   r2  rw   r6  r   r   r   r6  r   r   rx   r   r5  r   )rh   zSeries | DictConvertibler   r   r\   r   r   r   r   r2  rw   r6  r   r   r   r6  r   r   rx   r   r5  r>   )rh   z list | tuple | Index | ArrayLiker   r   r\   r   r   r   r   r2  rw   r6  r   r   r   r6  r   r   rx   r   r5  r:   )
r   FFNNTNFr   T)rh   z2DatetimeScalarOrArrayConvertible | DictConvertibler   r   r\   r   r   r   r   r2  rw   r6  r   r   r   r6  r   r   rx   r   r5  z8DatetimeIndex | Series | DatetimeScalar | NaTType | None)r   r   )rh   znpt.NDArray[np.object_]r   r8  r5  znp.ndarray | None)NFr   )t
__future__r   collectionsr   r   	functoolsr   	itertoolsr   typingr   r	   r
   r   r   r   r   r   r   r-  numpyr   pandas._libsr   pandas._libs.tslibsr   r   r   r   r   r   r   pandas._libs.tslibs.parsingr   r   r   pandas._libs.tslibs.strptimer   pandas._typingr   r   r   r    r!   pandas.util._exceptionsr"   pandas.core.dtypes.commonr#   r$   r%   r&   r'   r(   r)   r*   r+   r,   pandas.core.dtypes.genericr-   r.   pandas.core.dtypes.missingr/   pandas.arraysr0   r1   pandas.corer2   pandas.core.algorithmsr3   pandas.core.arrays.baser4   pandas.core.arrays.datetimesr5   r6   r7   pandas.core.constructionr8   pandas.core.indexes.baser9   pandas.core.indexes.datetimesr:   pandas._libs.tslibs.nattyper;   pandas._libs.tslibs.timedeltasr<   rs   r=   r>   r3  r4  r8  Scalarr9  r7  rA   r@   rO   DictConvertiblere   ra   rm   r}   r   r   r   r   r   r   r   r   r   r  r   r   r,  __all__rJ   rK   rL   <module>rV     sy   "    
 
 
      
 8  5   - # ) 2 
 3 * 73: ul23 	ucz	vx'(#(9I)I#J  VeFCK&8,FGy 	'u 	 (+56 R QU9	9).9CM9	9x,	,, , 	,
 ,` DH<<)<8@<
<@ !B	)BB B 	B4(@ "' !B9B9 B9 		B9
 B9 B9  B9 B9 B9 B9J-9 
	-9
 -9 -9  -9 -9`#
 
# # #  # #L"JFR 
 $'"%	   	
 
        
  
 $'"%	!   	
 
        
  
 $'"%	)   	
 
        
$ $+"'T	;T T T 	T
 
T T T T  T T >Tp
FV W g	
 
5 E C S c s c s 	$ 4 D  	$!" 4#$ 
+	2Zz3l
;rK   