zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
U
¬ý°d¶®ã@sNddlmZddlmZddlmZddlmZddlmZddl    m
Z
m Z m Z m Z mZmZmZmZmZddlZddlZddlmZmZdd    lmZmZmZmZmZmZm Z m!Z!m"Z"m#Z$dd
l%m&Z&dd l'm(Z(m)Z)dd l*m+Z+dd l,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2ddl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<ddl=m>Z>m?Z?ddl@mAZAddlBmCZCmDZDmEZEddlFmGZGddlHmIZIddlJmKZKddlLmMZMmNZNmOZOddlPmQZQddlRmSZSddlTmUZUe
rêddlVmWZWddlXmYZYddlZm[Z[m\Z\ee ee-fZ]ee^e_fZ`ee`efZaeeae]fZbee e`ee`dfe-fZcGdd„ded d!ZdGd"d#„d#edd$d!Zeeeed%fZfd&Zgdzd'd(d)œd*d+„Zhd{d-d.d/d0d1œd2d3„Zid-d(d0d4d5d6œd7d8„Zjd|d9d0d:d;d<œd=d>„Zkd}d?d5d@d;dAœdBdC„ZldDd0d;dEœdFdG„Zmd~d(d:d0d(dId'd'd0dJœdKdL„Znd0dMd0dMd;dNœdOdP„Zod0dMd;dQœdRdS„ZpdTdU„ZqeddVdId0d0d0d(d0d(d0d0dWdXœ dYdZ„ƒZred€d[dId0d0d0d(d0d(d0d0d5dXœ d\dZ„ƒZredd]dId0d0d0d(d0d(d0d0d^dXœ d_dZ„ƒZrdHd$d$d$dejsdejsd`d f
dadId0d0d0d(dbd(dcdMd0dddeœ dfdZ„ZrdgdgdhdhdididjdjdkdkdldldmdmdmdndndndodododpœZtdId0dqœdrds„ZudtdMdudvœdwdx„Zvdyd3dZgZwdS)‚é)Ú annotations)Úabc)Údatetime)Úpartial)Úislice)    Ú TYPE_CHECKINGÚCallableÚHashableÚListÚTupleÚ    TypedDictÚUnionÚcastÚoverloadN)ÚlibÚtslib)
ÚOutOfBoundsDatetimeÚ    TimedeltaÚ    TimestampÚastype_overflowsafeÚget_unit_from_dtypeÚiNaTÚis_supported_unitÚ nat_stringsÚparsingÚ    timezones)Úprecision_from_unit)ÚDateParseErrorÚguess_datetime_format)Úarray_strptime)Ú AnyArrayLikeÚ    ArrayLikeÚDateTimeErrorChoicesÚnpt)Úfind_stack_level)    Ú ensure_objectÚis_datetime64_dtypeÚis_datetime64tz_dtypeÚis_floatÚ
is_integerÚis_integer_dtypeÚ is_list_likeÚis_numeric_dtypeÚ    is_scalar)Ú ABCDataFrameÚ    ABCSeries)Únotna)Ú DatetimeArrayÚ IntegerArrayÚ PandasArray)Ú
algorithms)Úunique)ÚExtensionArray)Úmaybe_convert_dtypeÚobjects_to_datetime64nsÚ tz_to_dtype)Ú extract_array)ÚIndex)Ú DatetimeIndex)ÚNaTType)Ú UnitChoices)Ú    DataFrameÚSeries.c@s&eZdZUded<ded<ded<dS)ÚYearMonthDayDictÚDatetimeDictArgÚyearÚmonthÚdayN©Ú__name__Ú
__module__Ú __qualname__Ú__annotations__©rKrKúRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/tools/datetimes.pyrAks
rAT)Útotalc@sVeZdZUded<ded<ded<ded<ded<ded<ded<ded    <ded
<d S) ÚFulldatetimeDictrBÚhourÚhoursÚminuteÚminutesÚsecondÚsecondsÚmsÚusÚnsNrFrKrKrKrLrNqs
rNFr?é2z bool | Nonez
str | None)ÚdayfirstÚreturncCsnt |¡}dkrjt||}ƒtkrjt||d}|dk    r>|St ||dd…¡dkrjtjdttƒddS)Néÿÿÿÿ©rYézªCould 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$)ÚarrrYr`Zfirst_non_nan_elementZguessed_formatrKrKrLÚ _guess_datetime_format_for_array„sÿûrgçffffffæ?ÚArrayConvertibleÚfloatz
int | NoneÚbool)ÚargÚ unique_shareÚ check_countrZcCsÊd}|dkr<t|ƒtkrdSt|ƒdkr6t|ƒd}qjd}n.d|krTt|ƒks^ntdƒ‚|dkrjdSd|kr~d    ksˆntd
ƒ‚ztt||ƒƒ}Wntk
r°YdSXt|ƒ||krÆd}|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ôrz1check_count must be in next bounds: [0; len(arg)]r]z+unique_share must be in next bounds: (0; 1))ÚlenÚstart_caching_atÚAssertionErrorÚsetrÚ    TypeError)rlrmrnZ
do_cachingZunique_elementsrKrKrLÚ should_cache›s0  ÿÿ
þrurr@)rlÚformatÚcacheÚconvert_listlikerZcCsddlm}|td}|rŒt|ƒs&|St|ƒ}t|ƒt|ƒkrŒ|||ƒ}z|||dd}Wntk
rr|YSX|jjsŒ||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©r@©ÚdtypeF)ÚindexÚcopy)
Úpandasr@Úobjectrur5rprr|Ú    is_uniqueZ
duplicated)rlrvrwrxr@Ú cache_arrayZ unique_datesZ cache_datesrKrKrLÚ _maybe_cache×s 
 
 
r‚r!r    r;)Údt_arrayÚutcÚnamerZcCs2t|ƒr"|rdnd}t|||dSt|||jd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
    r„N©Útzr…)r…r{)r&r<r;r{)rƒr„r…r‡rKrKrLÚ_box_as_indexlikes rˆÚ DatetimeScalarOrArrayConvertiblezHashable | None)rlrr…rZcCs2ddlm}|||jjd |¡}t|jd|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
    rryrzF©r„r…)r~r@r|r{ÚmaprˆÚ_values)rlrr…r@ÚresultrKrKrLÚ_convert_and_box_cache#s rŽz
np.ndarray)rr„rZcCsrtjt|ƒtd}t|ƒD]J}||k}t||ƒ |¡}|r\|jdkrR| d¡}n
| d¡}|||<qt    ||dS)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
    utc : bool
        Whether to convert/localize timestamps to UTC.
    name : string, default None
        Name for a DatetimeIndex
 
    Returns
    -------
    tz_result : Index-like of parsed dates with timezone
    rzNr„©r…)
ÚnpÚemptyrprr5r1Ú tz_localizeÚtzinfoÚ
tz_convertr;)rrr„r…Z
tz_resultsÚzoneÚmaskÚdtarKrKrLÚ_return_parsed_timezone_results=s 
 
 
r˜Úraiser")rvr…r„ÚunitÚerrorsrYÚ    yearfirstÚexactc    CsRt|ttfƒrtj|dd}nt|tƒr2t |¡}t|ddƒ}    |rFdnd}
t|    ƒr†t|tt    fƒsnt    ||
|dS|r‚| 
d¡  d¡}|St |    ƒròt tj|    ƒ}    tt|    ƒƒsÄtt |¡t d¡|dkd    }t|tt    fƒsàt    ||
|dS|rî|  d¡S|S|dk    r|dk    rtd
ƒ‚t|||||ƒSt|d d ƒd kr8td ƒ‚zt|dt |
¡d\}} Wnjtk
r¾|dkrštjdgdd t|ƒ¡} t    | |dYS|dkr¸t||d} | YS‚YnXt|ƒ}|dkrÞt||d}|dk    r|dkrt||||||ƒSt|||||dd\}}|dk    rDt|t |ƒd}t    j!||dSt"|||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
    ÚOrzr{Nr„r†zM8[s]Úcoerce)Z    is_coercez#cannot specify both format and unitÚndimr]zAarg must be a string, datetime, list, tuple, 1-d array, or SeriesF)r}r‡ÚNaTzdatetime64[ns]rÚignorer\ÚmixedT)rYrœr„r›Z allow_objectrŠ)#Ú
isinstanceÚlistÚtuplerÚarrayr3Úgetattrr'r1r<r”r’r&rr{rrrÚasarrayÚ
ValueErrorÚ_to_datetime_with_unitrtr7Ú libtimezonesZ maybe_get_tzÚrepeatrpr;r%rgÚ_array_strptime_with_fallbackr8r9Z _simple_newrˆ)rlrvr…r„ršr›rYrœrZ    arg_dtyper‡Ú_ZnpvaluesÚidxrÚ    tz_parsedr—rKrKrLÚ_convert_listlike_datetimes`sx&
 
    ü
 
 
ÿ
 
 
 ú
    
r²rb)r„Úfmtrr›rZcCsDt|||||d\}}tdd„|Dƒƒr6t||||ƒSt|||dS)zL
    Call array_strptime, with fallback behavior depending on 'errors'.
    )rr›r„css|]}|dk    VqdS©NrK)Ú.0r‡rKrKrLÚ    <genexpr>åsz0_array_strptime_with_fallback.<locals>.<genexpr>rŠ)rÚanyr˜rˆ)rlr…r„r³rr›rrrKrKrLr®Ùs r®)r„r›rZc     Cs
t|dd}t|tƒr0| d|›d¡}d}nht |¡}|jjdkr´|jd|›ddd}zt|t d    ¡dd}Wn8t    k
r¬|d
krŽ‚| t
¡}t |||||ƒYSXd}nä|jjd krvt |ƒ\}}t  |¡|tkB}    ||jd dd}
d |
|    <|
tjjk ¡s|
tjjk ¡rR|d
krB| t
¡}t |||||ƒSt    d|›dƒ‚|
jd    dd}t dd¡||    <d}n"|jt
dd}tj|||d\}}|dkr²tj||d} n t||d} t| tƒsÎ| S|  d¡ |¡} |r| jdkrü|  d¡} n
|  d¡} | S)zF
    to_datetime specalized to the case where a 'unit' is passed.
    T)Z extract_numpyz datetime64[ú]N)ÚiÚuF©r}úM8[ns]r™ÚfZf8rz cannot convert input with unit 'ú'r¡rW©r›r¢rÚUTCr„)r:r¤r2Úastyperr©r{Úkindrrrr«rÚisnanrrÚminÚ_valuer·ÚmaxZ
datetime64rZarray_with_unit_to_datetimer;Z _with_inferr<r’r”r‡) rlršr…r„r›rfr±Zmultr¯r–ZfvaluesrrKrKrLr«ësV 
 
 
 
ÿ
 
 
 
r«c
CsÐ|dkr¬|}tdƒ ¡}|dkr(tdƒ‚z ||}Wn,tk
r`}ztdƒ|‚W5d}~XYnXtj ¡|}tj ¡|}t ||k¡sšt ||k¡r¨t|›dƒ‚n t    |ƒrÄt
|ƒsèt |ƒsèt t  |¡ƒsètd|›d    |›d
ƒ‚zt||d }Wnjtk
r.}ztd |›d ƒ|‚W5d}~XYn6tk
rb}ztd |›dƒ|‚W5d}~XYnX|jdk    r€td|›dƒ‚|tdƒ}    |    td|d }
t|ƒrÄt|tttjfƒsÄt  |¡}||
}|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)
    ZjulianrÚ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 specified)ršzorigin z is Out of Boundsz# cannot be converted to a Timestampzorigin offset z must be tz-naiver])rZto_julian_daterªrtrÆrÄrr·rr-r)r(r,r©r‡rr+r¤r/r;Úndarray) rlÚoriginršÚoriginalZj0ÚerrZj_maxZj_minÚoffsetZ    td_offsetZioffsetrKrKrLÚ_adjust_to_origin3s`  ÿþÿÿÿÿ þÿ"
ÿþ  
rÍÚDatetimeScalarr) rlr›rYrœr„rvrršÚinfer_datetime_formatrwrZc CsdSr´rK© rlr›rYrœr„rvrršrÏrÉrwrKrKrLÚ to_datetime|srÑzSeries | DictConvertiblec CsdSr´rKrÐrKrKrLrэsz list | tuple | Index | ArrayLiker<c CsdSr´rKrÐrKrKrLrўsÚunixz2DatetimeScalarOrArrayConvertible | DictConvertiblezbool | lib.NoDefaultzlib.NoDefault | boolz8DatetimeIndex | Series | DatetimeScalar | NaTType | None) rlr›rYrœr„rvrršrÏrÉrwrZc     Cs&|tjk    r|dkrtdƒ‚|tjk    r4tjdtƒd|dkr@dS|    dkrTt||    |ƒ}tt||||||d} t    |t
ƒr |} |rœ|j dk    r’|  d¡} n
|  d¡} n‚t    |tƒrît|||
| ƒ} | jsÊ| | ¡} n | |j|ƒ}|j||j|jd    } n4t    |ttjfƒrt|||ƒ} nt    |tƒrVt|||
| ƒ} | jsDt|| |jd
} n| |||jd
} nÌt|ƒrêz.tttt t!t"j#d tf|ƒ}t|||
| ƒ} Wn:t$k
rÈ|d kr¬‚d dl%m&}|gt'd} YnX| jsÞt|| ƒ} n
| ||ƒ} n8| t" (|g¡|ƒd } t    |t)ƒr"t    | t"j*ƒr"t)| ƒ} | S)uÙ5
    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.
 
    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.
 
        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`.
    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 millisecond difference
          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**
 
    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')
    '13000101'
    >>> 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`. 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 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)])
    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'zùThe 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^NrÒ)r„ršrYrœr›rr„)r|r…rr@r™rryrz)+rÚ
no_defaultrªrcrdr$rÍrr²r¤rr‡r”r’r/r‚r‘r‹rŒZ _constructorr|r…r.rÚMutableMappingÚ_assemble_from_unit_mappingsr;rŽr+rr r¥r¦r6rrÈrr~r@rr§rkZbool_)rlr›rYrœr„rvrršrÏrÉrwrxrrÚvaluesZargcr@rKrKrLrѯsxD
ú ù
 
 
 
ÿ
   rCrDrEÚhÚmÚsrUrVrW)rCZyearsrDÚmonthsrEÚdaysrOrPrQrRrSrTrUZ millisecondZ millisecondsrVÚ microsecondÚ microsecondsrWZ
nanosecondÚ nanoseconds)r›r„c sddlm}m‰m}||ƒ}|jjs,tdƒ‚dd„‰‡fdd„| ¡Dƒ}dd„| ¡Dƒ}d    d
d g}t    t
|ƒt
| ¡ƒƒ}t |ƒr d   |¡}    td |    ›dƒ‚t    t
| ¡ƒt
t  ¡ƒƒ}
t |
ƒrÞd   |
¡} td| ›dƒ‚‡‡fdd„} | ||d    ƒd| ||d
ƒd| ||d ƒ} zt| dˆ|d} Wn8ttfk
rp}ztd|›ƒ|‚W5d}~XYnXddddddg}|D]‚}| |¡}|dk    r†||kr†z| || ||ƒ|ˆd7} Wn>ttfk
r}ztd |›d!|›ƒ|‚W5d}~XYnX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)r?Ú
to_numericÚ to_timedeltaz#cannot assemble with duplicate keyscSs,|tkrt|S| ¡tkr(t| ¡S|Sr´)Ú    _unit_mapÚlower)ÚvaluerKrKrLr½s
  z'_assemble_from_unit_mappings.<locals>.fcsi|]}|ˆ|ƒ“qSrKrK)rµÚk)r½rKrLÚ
<dictcomp>‰sz0_assemble_from_unit_mappings.<locals>.<dictcomp>cSsi|]\}}||“qSrKrK)rµråÚvrKrKrLræŠsrCrDrEú,zNto assemble mappings requires at least that [year, month, day] be specified: [z ] is missingz9extra keys have been passed to the datetime assemblage: [r¸cs&ˆ|ˆd}t|ƒr"|jddd}|S)Nr¿Úint64Fr»)r*rÁ)r×)r›ràrKrLrŸžs z,_assemble_from_unit_mappings.<locals>.coerceé'édz%Y%m%d)rvr›r„zcannot assemble the datetimes: NrØrÙrÚrUrVrW)ršr›zcannot assemble the datetimes [z]: )r~r?ràráÚcolumnsr€rªÚkeysÚitemsÚsortedrsrpÚjoinrâr×rÑrtÚget)rlr›r„r?ráršZunit_revÚrequiredÚreqZ    _requiredZexcessZ_excessrŸr×rËZunitsrºrärK)r›r½ràrLrÖ`sX
 
 
 
ÿ
 
ÿ
ÿþÿ"
ÿþrÖznpt.NDArray[np.object_]znp.ndarray | None)rlr›rZc
s¼‡fdd„‰‡fdd„}zˆ| tj¡ƒWStttfk
rDYnXz| tj¡}||t|ƒƒWStttfk
r|YnXzt     |t
t ƒ¡}|||ƒWStttfk
r¶YnXdS)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'}
    cs>|jtdd}t |d|dd|d¡}tj|ˆddS)NFr»rêrër¿r)rÁrrZtry_parse_year_month_dayrZarray_to_datetime)ÚcargÚparsedr¿rKrLÚcalcÊs
ÿz_attempt_YYYYMMDD.<locals>.calccsRtj|jdd}| d¡}t||<ˆ|| tj¡ tj¡ƒ}| d¡||<|S)Nr¼rzÚi8)rr‘ÚshapeÚviewrrÁÚfloat64ré)rôr–rZiresultZ masked_result)rörKrLÚcalc_with_maskÒs 
 
z)_attempt_YYYYMMDD.<locals>.calc_with_maskN) rÁrrérªÚ OverflowErrorrtrúr0r4Úisinr¥r)rlr›rûrôr–rK)rör›rLÚ_attempt_YYYYMMDD¾s" 
  rþr)F)rhN)FN)N)NFNr™NNT)
..........)
..........)
..........)xÚ
__future__rÚ collectionsrrÚ    functoolsrÚ    itertoolsrÚtypingrrr    r
r r r rrrcÚnumpyrZ pandas._libsrrZpandas._libs.tslibsrrrrrrrrrrr¬Zpandas._libs.tslibs.conversionrZpandas._libs.tslibs.parsingrrZpandas._libs.tslibs.strptimerZpandas._typingr r!r"r#Zpandas.util._exceptionsr$Zpandas.core.dtypes.commonr%r&r'r(r)r*r+r,r-Zpandas.core.dtypes.genericr.r/Zpandas.core.dtypes.missingr0Z pandas.arraysr1r2r3Z pandas.corer4Zpandas.core.algorithmsr5Zpandas.core.arrays.baser6Zpandas.core.arrays.datetimesr7r8r9Zpandas.core.constructionr:Zpandas.core.indexes.baser;Zpandas.core.indexes.datetimesr<Zpandas._libs.tslibs.nattyper=Zpandas._libs.tslibs.timedeltasr>r~r?r@rirjrbZScalarrÎr‰rBrArNZDictConvertiblerqrgrur‚rˆrŽr˜r²r®r«rÍrÑrÔrârÖrþÚ__all__rKrKrKrLÚ<module>s     , 0   ,              ÿ<0ÿ ý&÷yHIõ&õ&õ&õ&ë^7ý