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
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
U
¬ý°d    *ã
@s„UddlmZddlZddlmZddlmZmZmZm    Z    m
Z
m Z m Z ddl Z ddlZddlmZddlmZmZmZmZmZmZmZddlmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&ddl'm(Z)dd    l*m+Z+dd
l,m-Z-m.Z.m/Z/dd l0m1Z1dd l2m3Z3m4Z4ddl5m6m7Z8dd l9m:Z:ddl;m<Z<ddl=m6m>Z?ddl@mAZAmBZBddlCmDZDddlEmFZFmGZGmHZHmIZIddlJmKZKddlLmMZMddlNmOZOmPZPddlQmRZRmSZSddlTmUZUmVZVddlWmXZXmYZYddlZm[Z[m\Z\erøddl]m^Z^m_Z_m`Z`iZadebd<Gdd„deFe<ƒZcGdd„de<ƒZdGd d!„d!ecƒZeGd"d#„d#edeeƒZfGd$d%„d%eeƒZgGd&d'„d'edegƒZhGd(d)„d)eeƒZiGd*d+„d+edeiƒZjdhd,dd-œd.d/„Zkecjlek_ldid0dd1œd2d3„ZmGd4d5„d5eKƒZndjd6d7d8d9d6d:œd;d<„Zodkd?d?d@dAdBdCdDdEdFœdGdH„ZpdldIdId@dBdCdDdJdKœdLdM„ZqdNdOdNdPdQdRœdSdT„Zrdmd?d?dWdBdCdDdAdEdXœdYdZ„Zsdnd6d\d6d]œd^d_„Ztd`daœdbdc„ZudAdddeœdfdg„ZvdS)oé)Ú annotationsN)Údedent)Ú TYPE_CHECKINGÚCallableÚHashableÚLiteralÚcastÚfinalÚ no_type_check)Úlib)Ú
BaseOffsetÚIncompatibleFrequencyÚNaTÚPeriodÚ    TimedeltaÚ    TimestampÚ    to_offset) Ú AnyArrayLikeÚAxisÚAxisIntÚ    FrequencyÚ
IndexLabelÚNDFrameTÚQuantileInterpolationÚTÚTimedeltaConvertibleTypesÚTimeGrouperOriginÚTimestampConvertibleTypesÚnpt)Úfunction©ÚAbstractMethodError)ÚAppenderÚ SubstitutionÚdoc)Úfind_stack_level)Ú ABCDataFrameÚ    ABCSeries)ÚResamplerWindowApply)Ú PandasObject)ÚNDFrameÚ _shared_docs)Ú SeriesGroupBy)Ú BaseGroupByÚGroupByÚ_pipe_templateÚ get_groupby)ÚGrouper)Ú
BinGrouper)Ú DatetimeIndexÚ
date_range)Ú PeriodIndexÚ period_range)ÚTimedeltaIndexÚtimedelta_range)Ú is_subperiodÚis_superperiod)ÚDayÚTick)Ú    DataFrameÚIndexÚSerieszdict[str, str]Ú_shared_docs_kwargsc    s,eZdZUdZded<ded<ded<eƒZded    <ed
d d hƒZd dddddddgZ    dŒdddœdddddddœdd „Z
d!d"œd#d$„Z d!d%œd&d'„Z e dd"œd(d)„ƒZd*d*d+œd,d-„Zd.d/„Zed0d1„ƒZedd2d3eeƒd4d5d6œ‡fd7d8„ ƒƒZed9ƒZed:ƒZeed;eed<d=d>dd?d@„ƒZeZeZdAdB„ZdCdD„Z dŽdEdF„Z!ddGdHœdIdJ„Z"dKdL„Z#dMdNœdOdP„Z$dQdR„Z%ddSdT„Z&d‘dUdV„Z'd’dWdX„Z(d“dYdZ„Z)ee*j+fe,Žd”dddd\ddd]œd^ddd_d`œdadb„ƒZ+d•dcdd„Z-d–ddGdeœdfdg„Z.ee/j0ƒd—ddGdeœdhdi„ƒZ0d˜ddGdeœdjdk„Z1d™ddGdeœdldm„Z2ee/j3ƒdšddGdeœdndo„ƒZ3ee/j4ƒd›ddGdeœdpdq„ƒZ4ee/j5ƒdœddrœdsdt„ƒZ5dddrœdudv„Z6dždGddxœdydz„Z7dŸdGddxœd{d|„Z8ee/j9ƒd dGddxœd}d~„ƒZ9ee/j:ƒdd€„ƒZ:ee;j<ƒdd‚„ƒZ<ee/j=ƒdƒd„„ƒZ=ee/j>ƒd…d†„ƒZ>d¡dˆd‰œdŠd‹„Z?‡Z@S)¢Ú    Resamplera/
    Class for resampling datetimelike data, a groupby-like operation.
    See aggregate, transform, and apply functions on this object.
 
    It's easiest to use obj.resample(...) to use Resampler.
 
    Parameters
    ----------
    obj : Series or DataFrame
    groupby : TimeGrouper
    axis : int, default 0
    kind : str or None
        'period', 'timestamp' to override default index treatment
 
    Returns
    -------
    a Resampler of the appropriate type
 
    Notes
    -----
    After resampling, see aggregate, apply, and transform functions.
    r2ÚgrouperÚ TimeGrouperÚ _timegrouperz,DatetimeIndex | TimedeltaIndex | PeriodIndexÚbinnerzfrozenset[Hashable]Ú
exclusionsÚobjÚaxÚ_indexerÚfreqÚaxisÚclosedÚlabelÚ
conventionÚkindÚoriginÚoffsetrNF)Ú
group_keysÚ    selectionr*rr>ÚboolÚNone)rGÚ timegrouperrKÚ    gpr_indexrRÚreturncCs”||_d|_d|_| |¡|_||_||_d|_|jj|     |¡d|d\|_
|_ |_ |  ¡\|_|_||_|jjdk    rˆt|jjgƒ|_ntƒ|_dS)NT)ÚsortrW)rDÚkeysrYZ_get_axis_numberrKrOrRZas_indexÚ _set_grouperÚ _convert_objrGrHrIÚ _get_binnerrErBÚ
_selectionÚkeyÚ    frozensetrF)ÚselfrGrVrKrOrWrRrS©rbúKd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/resample.pyÚ__init__“s"  ÿ zResampler.__init__Ústr)rXcs0‡fdd„ˆjDƒ}tˆƒj›dd |¡›dS)z@
        Provide a nice str repr of our rolling object.
        c3s6|].}tˆj|dƒdk    r|›dtˆj|ƒ›VqdS)Nú=)ÚgetattrrD)Ú.0Úk©rarbrcÚ    <genexpr>´sþz$Resampler.__str__.<locals>.<genexpr>z [z, ú])Ú _attributesÚtypeÚ__name__Újoin)raÚattrsrbrjrcÚ__str__°s
þzResampler.__str__)ÚattrcCsJ||jkrt ||¡S||jkr,t|j|ƒS||jkr>||St ||¡S©N)Ú_internal_names_setÚobjectÚ__getattribute__rmrgrDrG)rarsrbrbrcÚ __getattr__»s
 
 
zResampler.__getattr__cCs"|jdk    o |jjdk    p |jjdk    S)zP
        Is the resampling from a DataFrame column or MultiIndex level.
        N)rDr_ÚlevelrjrbrbrcÚ_from_selectionÅs
ÿzResampler._from_selectionr©rGrXcCs| ¡S)zÜ
        Provide any conversions for the object in order to correctly handle.
 
        Parameters
        ----------
        obj : Series or DataFrame
 
        Returns
        -------
        Series or DataFrame
        )Z _consolidate)rarGrbrbrcr\Ðs zResampler._convert_objcCs t|ƒ‚dSrtr rjrbrbrcÚ_get_binner_for_timeÞszResampler._get_binner_for_timecCs:| ¡\}}}t|ƒt|ƒks"t‚t|||jd}||fS)zk
        Create the BinGrouper, assume that self.set_grouper(obj)
        has already been called.
        )Úindexer)r|ÚlenÚAssertionErrorr2rI)rarEÚbinsÚ    binlabelsZ bin_grouperrbrbrcr]ászResampler._get_binnera¼
    >>> df = pd.DataFrame({'A': [1, 2, 3, 4]},
    ...                   index=pd.date_range('2012-08-02', periods=4))
    >>> df
                A
    2012-08-02  1
    2012-08-03  2
    2012-08-04  3
    2012-08-05  4
 
    To get the difference between each 2-day period's maximum and minimum
    value in one pass, you can do
 
    >>> df.resample('2D').pipe(lambda x: x.max() - x.min())
                A
    2012-08-02  1
    2012-08-04  1)ÚklassÚexamplesz/Callable[..., T] | tuple[Callable[..., T], str]r)ÚfuncrXcstƒj|f|ž|ŽSrt)ÚsuperÚpipe)rar„ÚargsÚkwargs©Ú    __class__rbrcr†ìszResampler.pipea[
    See Also
    --------
    DataFrame.groupby.aggregate : Aggregate using callable, string, dict,
        or list of string/callables.
    DataFrame.resample.transform : Transforms the Series on each group
        based on the given function.
    DataFrame.aggregate: Aggregate using one or more
        operations over the specified axis.
    a‚
    Examples
    --------
    >>> s = pd.Series([1, 2, 3, 4, 5],
    ...               index=pd.date_range('20130101', periods=5, freq='s'))
    >>> s
    2013-01-01 00:00:00    1
    2013-01-01 00:00:01    2
    2013-01-01 00:00:02    3
    2013-01-01 00:00:03    4
    2013-01-01 00:00:04    5
    Freq: S, dtype: int64
 
    >>> r = s.resample('2s')
 
    >>> r.agg(np.sum)
    2013-01-01 00:00:00    3
    2013-01-01 00:00:02    7
    2013-01-01 00:00:04    5
    Freq: 2S, dtype: int64
 
    >>> r.agg(['sum', 'mean', 'max'])
                         sum  mean  max
    2013-01-01 00:00:00    3   1.5    2
    2013-01-01 00:00:02    7   3.5    4
    2013-01-01 00:00:04    5   5.0    5
 
    >>> r.agg({'result': lambda x: x.mean() / x.std(),
    ...        'total': np.sum})
                           result  total
    2013-01-01 00:00:00  2.121320      3
    2013-01-01 00:00:02  4.949747      7
    2013-01-01 00:00:04       NaN      5
 
    >>> r.agg(average="mean", total="sum")
                             average  total
    2013-01-01 00:00:00      1.5      3
    2013-01-01 00:00:02      3.5      7
    2013-01-01 00:00:04      5.0      5
    Ú    aggregater=Ú)Zsee_alsorƒr‚rKcOs6t||||d ¡}|dkr2|}|j|f|ž|Ž}|S)N)r‡rˆ)r(ÚaggÚ_groupby_and_aggregate)rar„r‡rˆÚresultÚhowrbrbrcr‹As
zResampler.aggregatecOs|j |j¡j|f|ž|ŽS)aw
        Call function producing a like-indexed Series on each group.
 
        Return a Series with the transformed values.
 
        Parameters
        ----------
        arg : function
            To apply to each group. Should return a Series with the same index.
 
        Returns
        -------
        Series
 
        Examples
        --------
        >>> s = pd.Series([1, 2],
        ...               index=pd.date_range('20180101',
        ...                                   periods=2,
        ...                                   freq='1h'))
        >>> s
        2018-01-01 00:00:00    1
        2018-01-01 01:00:00    2
        Freq: H, dtype: int64
 
        >>> resampled = s.resample('15min')
        >>> resampled.transform(lambda x: (x - x.mean()) / x.std())
        2018-01-01 00:00:00   NaN
        2018-01-01 01:00:00   NaN
        Freq: H, dtype: float64
        )Ú _selected_objÚgroupbyrDÚ    transform)raÚargr‡rˆrbrbrcr“Ss ÿÿÿzResampler.transformcKs t|ƒ‚dSrtr )raÚfrˆrbrbrcÚ _downsamplewszResampler._downsamplecCs t|ƒ‚dSrtr )rar•ÚlimitÚ
fill_valuerbrbrcÚ    _upsamplezszResampler._upsampleÚint)ÚndimcCsd|j}|dkr4|j}|dk    r&||}n|jdks4t‚|dkrJ|jdksJt‚t|d||j|jd}|S)á
        Sub-classes to define. Return a sliced object.
 
        Parameters
        ----------
        key : string / list of selections
        ndim : {1, 2}
            requested ndim of result
        subset : object, default None
            subset to act on
        Né©ZbyrBrKrR)rBrGr›rr0rKrR)rar_r›ÚsubsetrBÚgroupedrbrbrcÚ_gotitem}s  
ÿzResampler._gotitemc
 
sè|j}|jjdkr|j}n|j}t|d||j|jd}z:tˆƒr\‡‡‡fdd„}| |¡}n|jˆfˆžˆŽ}Wnlt    t
fk
rš|j ˆfˆžˆŽ}YnDt k
rÜ}    z&dt |    ƒkr¸n‚|j ˆfˆžˆŽ}W5d}    ~    XYnX| |¡S)zA
        Re-evaluate the obj with a groupby aggregation.
        rNržcsˆ|fˆžˆŽSrtrb©Úx©r‡rrˆrbrcÚ<lambda>¬óz2Resampler._groupby_and_aggregate.<locals>.<lambda>zMust produce aggregated value)rBr‘r›Ú_obj_with_exclusionsr0rKrRÚcallabler‹ÚAttributeErrorÚKeyErrorÚapplyÚ
ValueErrorreÚ _wrap_result)
rarr‡rˆrBrGr r„rÚerrrbr¤rcrŽ™s0 ÿ  $z Resampler._groupby_and_aggregater.)r’cCs|j|||dS)zG
        Return the correct class for resampling with groupby.
        )r’r_Úparent)Ú_resampler_for_grouping)rar’r_rbrbrcÚ_get_resampler_for_groupingÈsz%Resampler._get_resampler_for_groupingcCs¢|j}t|tƒrJt|ƒdkrJt|jtƒsJ|jt|jdd…|jddd}t|t    ƒrf|j
dk    rf|j
|_ t|t    ƒrž|j ržt|jdd…|jd|_t |ddƒ|_ |S)z/
        Potentially wrap any results.
        rN©rJT)ÚappendÚname)rGÚ
isinstancer&r~Úindexr5Z    set_indexÚ_asfreq_compatrJr'r^r´Úemptyrg)rarrGrbrbrcr­Îs"ÿ
þ
ýÿzResampler._wrap_resultcCs|jd|dS)a
        Forward fill the values.
 
        Parameters
        ----------
        limit : int, optional
            Limit of how many values to fill.
 
        Returns
        -------
        An upsampled Series.
 
        See Also
        --------
        Series.fillna: Fill NA/NaN values using the specified method.
        DataFrame.fillna: Fill NA/NaN values using the specified method.
        Úffill©r—©r™©rar—rbrbrcr¹çszResampler.ffillcCs|jd|dS)a™
        Resample by using the nearest value.
 
        When resampling data, missing values may appear (e.g., when the
        resampling frequency is higher than the original frequency).
        The `nearest` method will replace ``NaN`` values that appeared in
        the resampled data with the value from the nearest member of the
        sequence, based on the index value.
        Missing values that existed in the original data will not be modified.
        If `limit` is given, fill only this many values in each direction for
        each of the original values.
 
        Parameters
        ----------
        limit : int, optional
            Limit of how many values to fill.
 
        Returns
        -------
        Series or DataFrame
            An upsampled Series or DataFrame with ``NaN`` values filled with
            their nearest value.
 
        See Also
        --------
        backfill : Backward fill the new missing values in the resampled data.
        pad : Forward fill ``NaN`` values.
 
        Examples
        --------
        >>> s = pd.Series([1, 2],
        ...               index=pd.date_range('20180101',
        ...                                   periods=2,
        ...                                   freq='1h'))
        >>> s
        2018-01-01 00:00:00    1
        2018-01-01 01:00:00    2
        Freq: H, dtype: int64
 
        >>> s.resample('15min').nearest()
        2018-01-01 00:00:00    1
        2018-01-01 00:15:00    1
        2018-01-01 00:30:00    2
        2018-01-01 00:45:00    2
        2018-01-01 01:00:00    2
        Freq: 15T, dtype: int64
 
        Limit the number of upsampled values imputed by the nearest:
 
        >>> s.resample('15min').nearest(limit=1)
        2018-01-01 00:00:00    1.0
        2018-01-01 00:15:00    1.0
        2018-01-01 00:30:00    NaN
        2018-01-01 00:45:00    2.0
        2018-01-01 01:00:00    2.0
        Freq: 15T, dtype: float64
        Únearestrºr»r¼rbrbrcr½ûs:zResampler.nearestcCs|jd|dS)a­
        Backward fill the new missing values in the resampled data.
 
        In statistics, imputation is the process of replacing missing data with
        substituted values [1]_. When resampling data, missing values may
        appear (e.g., when the resampling frequency is higher than the original
        frequency). The backward fill will replace NaN values that appeared in
        the resampled data with the next value in the original sequence.
        Missing values that existed in the original data will not be modified.
 
        Parameters
        ----------
        limit : int, optional
            Limit of how many values to fill.
 
        Returns
        -------
        Series, DataFrame
            An upsampled Series or DataFrame with backward filled NaN values.
 
        See Also
        --------
        bfill : Alias of backfill.
        fillna : Fill NaN values using the specified method, which can be
            'backfill'.
        nearest : Fill NaN values with nearest neighbor starting from center.
        ffill : Forward fill NaN values.
        Series.fillna : Fill NaN values in the Series using the
            specified method, which can be 'backfill'.
        DataFrame.fillna : Fill NaN values in the DataFrame using the
            specified method, which can be 'backfill'.
 
        References
        ----------
        .. [1] https://en.wikipedia.org/wiki/Imputation_(statistics)
 
        Examples
        --------
        Resampling a Series:
 
        >>> s = pd.Series([1, 2, 3],
        ...               index=pd.date_range('20180101', periods=3, freq='h'))
        >>> s
        2018-01-01 00:00:00    1
        2018-01-01 01:00:00    2
        2018-01-01 02:00:00    3
        Freq: H, dtype: int64
 
        >>> s.resample('30min').bfill()
        2018-01-01 00:00:00    1
        2018-01-01 00:30:00    2
        2018-01-01 01:00:00    2
        2018-01-01 01:30:00    3
        2018-01-01 02:00:00    3
        Freq: 30T, dtype: int64
 
        >>> s.resample('15min').bfill(limit=2)
        2018-01-01 00:00:00    1.0
        2018-01-01 00:15:00    NaN
        2018-01-01 00:30:00    2.0
        2018-01-01 00:45:00    2.0
        2018-01-01 01:00:00    2.0
        2018-01-01 01:15:00    NaN
        2018-01-01 01:30:00    3.0
        2018-01-01 01:45:00    3.0
        2018-01-01 02:00:00    3.0
        Freq: 15T, dtype: float64
 
        Resampling a DataFrame that has missing values:
 
        >>> df = pd.DataFrame({'a': [2, np.nan, 6], 'b': [1, 3, 5]},
        ...                   index=pd.date_range('20180101', periods=3,
        ...                                       freq='h'))
        >>> df
                               a  b
        2018-01-01 00:00:00  2.0  1
        2018-01-01 01:00:00  NaN  3
        2018-01-01 02:00:00  6.0  5
 
        >>> df.resample('30min').bfill()
                               a  b
        2018-01-01 00:00:00  2.0  1
        2018-01-01 00:30:00  NaN  3
        2018-01-01 01:00:00  NaN  3
        2018-01-01 01:30:00  6.0  5
        2018-01-01 02:00:00  6.0  5
 
        >>> df.resample('15min').bfill(limit=2)
                               a    b
        2018-01-01 00:00:00  2.0  1.0
        2018-01-01 00:15:00  NaN  NaN
        2018-01-01 00:30:00  NaN  3.0
        2018-01-01 00:45:00  NaN  3.0
        2018-01-01 01:00:00  NaN  3.0
        2018-01-01 01:15:00  NaN  NaN
        2018-01-01 01:30:00  6.0  5.0
        2018-01-01 01:45:00  6.0  5.0
        2018-01-01 02:00:00  6.0  5.0
        Úbfillrºr»r¼rbrbrcr¾7sdzResampler.bfillcCs|j||dS)a 
        Fill missing values introduced by upsampling.
 
        In statistics, imputation is the process of replacing missing data with
        substituted values [1]_. When resampling data, missing values may
        appear (e.g., when the resampling frequency is higher than the original
        frequency).
 
        Missing values that existed in the original data will
        not be modified.
 
        Parameters
        ----------
        method : {'pad', 'backfill', 'ffill', 'bfill', 'nearest'}
            Method to use for filling holes in resampled data
 
            * 'pad' or 'ffill': use previous valid observation to fill gap
              (forward fill).
            * 'backfill' or 'bfill': use next valid observation to fill gap.
            * 'nearest': use nearest valid observation to fill gap.
 
        limit : int, optional
            Limit of how many consecutive missing values to fill.
 
        Returns
        -------
        Series or DataFrame
            An upsampled Series or DataFrame with missing values filled.
 
        See Also
        --------
        bfill : Backward fill NaN values in the resampled data.
        ffill : Forward fill NaN values in the resampled data.
        nearest : Fill NaN values in the resampled data
            with nearest neighbor starting from center.
        interpolate : Fill NaN values using interpolation.
        Series.fillna : Fill NaN values in the Series using the
            specified method, which can be 'bfill' and 'ffill'.
        DataFrame.fillna : Fill NaN values in the DataFrame using the
            specified method, which can be 'bfill' and 'ffill'.
 
        References
        ----------
        .. [1] https://en.wikipedia.org/wiki/Imputation_(statistics)
 
        Examples
        --------
        Resampling a Series:
 
        >>> s = pd.Series([1, 2, 3],
        ...               index=pd.date_range('20180101', periods=3, freq='h'))
        >>> s
        2018-01-01 00:00:00    1
        2018-01-01 01:00:00    2
        2018-01-01 02:00:00    3
        Freq: H, dtype: int64
 
        Without filling the missing values you get:
 
        >>> s.resample("30min").asfreq()
        2018-01-01 00:00:00    1.0
        2018-01-01 00:30:00    NaN
        2018-01-01 01:00:00    2.0
        2018-01-01 01:30:00    NaN
        2018-01-01 02:00:00    3.0
        Freq: 30T, dtype: float64
 
        >>> s.resample('30min').fillna("backfill")
        2018-01-01 00:00:00    1
        2018-01-01 00:30:00    2
        2018-01-01 01:00:00    2
        2018-01-01 01:30:00    3
        2018-01-01 02:00:00    3
        Freq: 30T, dtype: int64
 
        >>> s.resample('15min').fillna("backfill", limit=2)
        2018-01-01 00:00:00    1.0
        2018-01-01 00:15:00    NaN
        2018-01-01 00:30:00    2.0
        2018-01-01 00:45:00    2.0
        2018-01-01 01:00:00    2.0
        2018-01-01 01:15:00    NaN
        2018-01-01 01:30:00    3.0
        2018-01-01 01:45:00    3.0
        2018-01-01 02:00:00    3.0
        Freq: 15T, dtype: float64
 
        >>> s.resample('30min').fillna("pad")
        2018-01-01 00:00:00    1
        2018-01-01 00:30:00    1
        2018-01-01 01:00:00    2
        2018-01-01 01:30:00    2
        2018-01-01 02:00:00    3
        Freq: 30T, dtype: int64
 
        >>> s.resample('30min').fillna("nearest")
        2018-01-01 00:00:00    1
        2018-01-01 00:30:00    2
        2018-01-01 01:00:00    2
        2018-01-01 01:30:00    3
        2018-01-01 02:00:00    3
        Freq: 30T, dtype: int64
 
        Missing values present before the upsampling are not affected.
 
        >>> sm = pd.Series([1, None, 3],
        ...               index=pd.date_range('20180101', periods=3, freq='h'))
        >>> sm
        2018-01-01 00:00:00    1.0
        2018-01-01 01:00:00    NaN
        2018-01-01 02:00:00    3.0
        Freq: H, dtype: float64
 
        >>> sm.resample('30min').fillna('backfill')
        2018-01-01 00:00:00    1.0
        2018-01-01 00:30:00    NaN
        2018-01-01 01:00:00    NaN
        2018-01-01 01:30:00    3.0
        2018-01-01 02:00:00    3.0
        Freq: 30T, dtype: float64
 
        >>> sm.resample('30min').fillna('pad')
        2018-01-01 00:00:00    1.0
        2018-01-01 00:30:00    1.0
        2018-01-01 01:00:00    NaN
        2018-01-01 01:30:00    NaN
        2018-01-01 02:00:00    3.0
        Freq: 30T, dtype: float64
 
        >>> sm.resample('30min').fillna('nearest')
        2018-01-01 00:00:00    1.0
        2018-01-01 00:30:00    NaN
        2018-01-01 01:00:00    NaN
        2018-01-01 01:30:00    3.0
        2018-01-01 02:00:00    3.0
        Freq: 30T, dtype: float64
 
        DataFrame resampling is done column-wise. All the same options are
        available.
 
        >>> df = pd.DataFrame({'a': [2, np.nan, 6], 'b': [1, 3, 5]},
        ...                   index=pd.date_range('20180101', periods=3,
        ...                                       freq='h'))
        >>> df
                               a  b
        2018-01-01 00:00:00  2.0  1
        2018-01-01 01:00:00  NaN  3
        2018-01-01 02:00:00  6.0  5
 
        >>> df.resample('30min').fillna("bfill")
                               a  b
        2018-01-01 00:00:00  2.0  1
        2018-01-01 00:30:00  NaN  3
        2018-01-01 01:00:00  NaN  3
        2018-01-01 01:30:00  6.0  5
        2018-01-01 02:00:00  6.0  5
        rºr»)raÚmethodr—rbrbrcÚfillnaszResampler.fillnaÚlinearZforward)rKr—ÚinplaceÚlimit_directionÚ
limit_areaÚdowncastrz(Literal[('forward', 'backward', 'both')])r¿rKrÂrÃc
 
Ks*| d¡}    |    jf|||||||dœ|—ŽS)zD
        Interpolate values according to different methods.
        Úasfreq)r¿rKr—rÂrÃrÄrÅ)r™Ú interpolate)
rar¿rKr—rÂrÃrÄrÅrˆrrbrbrcrÇ=s
ùøzResampler.interpolatecCs|jd|dS)a6
        Return the values at the new freq, essentially a reindex.
 
        Parameters
        ----------
        fill_value : scalar, optional
            Value to use for missing values, applied during upsampling (note
            this does not fill NaNs that already were present).
 
        Returns
        -------
        DataFrame or Series
            Values at the specified freq.
 
        See Also
        --------
        Series.asfreq: Convert TimeSeries to specified frequency.
        DataFrame.asfreq: Convert TimeSeries to specified frequency.
        rÆ)r˜r»)rar˜rbrbrcrÆYszResampler.asfreq©Ú numeric_onlyÚ    min_countcOs0tt|ƒd||ƒt d||¡|jd||dS)NÚsumrÈ©Úmaybe_warn_args_and_kwargsrnÚnvZvalidate_resampler_funcr–©rarÉrÊr‡rˆrbrbrcrËosz Resampler.sumcOs0tt|ƒd||ƒt d||¡|jd||dS)NÚprodrÈrÌrÏrbrbrcrÐzszResampler.prodcOs0tt|ƒd||ƒt d||¡|jd||dS)NÚminrÈrÌrÏrbrbrcrцsz Resampler.mincOs0tt|ƒd||ƒt d||¡|jd||dS)NÚmaxrÈrÌrÏrbrbrcrґsz Resampler.maxcOs0tt|ƒd||ƒt d||¡|jd||dS)NÚfirstrÈrÌrÏrbrbrcrӜszResampler.firstcOs0tt|ƒd||ƒt d||¡|jd||dS)NÚlastrÈrÌrÏrbrbrcrÔ¨szResampler.last©rÉcOs.tt|ƒd||ƒt d||¡|jd|dS)NÚmedianrÕrÌ©rarÉr‡rˆrbrbrcrÖ´szResampler.mediancOs.tt|ƒd||ƒt d||¡|jd|dS)a›
        Compute mean of groups, excluding missing values.
 
        Parameters
        ----------
        numeric_only : bool, default False
            Include only `float`, `int` or `boolean` data.
 
            .. versionchanged:: 2.0.0
 
                numeric_only now defaults to ``False``.
 
        Returns
        -------
        DataFrame or Series
            Mean of values within each group.
        ÚmeanrÕrÌr×rbrbrcrغszResampler.meanr©ÚddofrÉcOs0tt|ƒd||ƒt d||¡|jd||dS)a
        Compute standard deviation of groups, excluding missing values.
 
        Parameters
        ----------
        ddof : int, default 1
            Degrees of freedom.
        numeric_only : bool, default False
            Include only `float`, `int` or `boolean` data.
 
            .. versionadded:: 1.5.0
 
            .. versionchanged:: 2.0.0
 
                numeric_only now defaults to ``False``.
 
        Returns
        -------
        DataFrame or Series
            Standard deviation of values within each group.
        ÚstdrÙrÌ©rarÚrÉr‡rˆrbrbrcrÛÕsz Resampler.stdcOs0tt|ƒd||ƒt d||¡|jd||dS)a
        Compute variance of groups, excluding missing values.
 
        Parameters
        ----------
        ddof : int, default 1
            Degrees of freedom.
 
        numeric_only : bool, default False
            Include only `float`, `int` or `boolean` data.
 
            .. versionadded:: 1.5.0
 
            .. versionchanged:: 2.0.0
 
                numeric_only now defaults to ``False``.
 
        Returns
        -------
        DataFrame or Series
            Variance of values within each group.
        ÚvarrÙrÌrÜrbrbrcrÝõsz Resampler.varcOs0tt|ƒd||ƒt d||¡|jd||dS)NÚsemrÙrÌrÜrbrbrcrÞsz Resampler.semcOs*tt|ƒd||ƒt d||¡| d¡S)NÚohlcrÌ©rar‡rˆrbrbrcrß"szResampler.ohlccOs*tt|ƒd||ƒt d||¡| d¡S)NÚnuniquerÌràrbrbrcrá,szResampler.nuniquecCsh| d¡}t|tƒr"|js"| ¡}t|jƒsdddlm}|j    j
dkrN|j    j }nd}|g|j d|d}|S)NÚsizer)r?rÚint64©r¶Údtyper´) r–rµr&r¸Ústackr~rHÚpandasr?r‘r›r´r¶)rarr?r´rbrbrcrâ6s
 
 
zResampler.sizecCsb| d¡}t|jƒs^|jjdkr>t|jƒg|jd|jjd}n ddlm    }|g|j|j
dd}|S)NÚcountrrãrär)r=)r¶Úcolumnsrå) r–r~rHr‘r›rnr¶r´rçr=ré)rarr=rbrbrcrèIs"
 
 ÿ ÿzResampler.countçà?zfloat | AnyArrayLike)ÚqcKs|jdd|i|—ŽS)aÁ
        Return value at the given quantile.
 
        Parameters
        ----------
        q : float or array-like, default 0.5 (50% quantile)
 
        Returns
        -------
        DataFrame or Series
            Quantile of values within each group.
 
        See Also
        --------
        Series.quantile
            Return a series, where the index is q and the values are the quantiles.
        DataFrame.quantile
            Return a DataFrame, where the columns are the columns of self,
            and the values are the quantiles.
        DataFrameGroupBy.quantile
            Return a DataFrame, where the columns are groupby columns,
            and the values are its quantiles.
        Úquantilerë)rì)r–)rarërˆrbrbrcrìZszResampler.quantile)rN)N)NN)N)N)N)N)N)rÁ)N)Fr)Fr)Fr)Fr)Fr)Fr)F)F)rF)rF)rF)rê)AroÚ
__module__Ú __qualname__Ú__doc__Ú__annotations__r`rFÚsetrurmrdrrrxÚpropertyrzr\r|r    r]r#r"r/r†rZ_agg_see_also_docZ_agg_examples_docr$r+r‹rr«r“r–r™r¡rŽr±r­r¹r½r¾rÀr*rÇr@rÆrËr.rÐrÑrÒrÓrÔrÖrØrÛrÝrÞrßr,rárârèrìÚ __classcell__rbrbr‰rcrAisì
øû÷ 
 
 
 
þÿ ÿ+û $
/
 
<
f
! þ÷
ý ý ý ý ý ý þý"ý!ý 
    
    
 
rAc@sxeZdZUdZded<dZded<ded<d    ed
<ddd œd ddd dœdd„Zedd„ƒZeZ    eZ
eZ e ddd„ƒZ dS)Ú _GroupByMixinz)
    Provide the groupby facilities.
    z    list[str]rmNzIndexLabel | Noner^r.Ú_groupbyrCrD)r_rSrArU)r¯r’rSrXcCs†t|tƒstt|ƒƒ‚t|tƒs,tt|ƒƒ‚|jD]}t||t||ƒƒq2||_|j    |_    ||_
||_ t   |j ¡|_ |j|_|j|_dSrt)rµr.rrnrArmÚsetattrrgr^rEr_rõÚcopyrDrHrG)rar¯r’r_rSrsrbrbrcrds
 
z_GroupByMixin.__init__cs(‡‡‡‡fdd„}ˆj |¡}ˆ |¡S)zž
        Dispatch to _upsample; we are stripping all of the _upsample kwargs and
        performing the original function call on the grouped object.
        cs@ˆj|ˆjˆjd}tˆtƒr.t|ˆƒfˆŽS|jˆfˆžˆŽS)N)rVrW)Ú_resampler_clsrDrHrµrergr«r¢©r‡r•rˆrarbrcr„¤s
z"_GroupByMixin._apply.<locals>.func)rõr«r­)rar•r‡rˆr„rrbrùrcÚ_applys z_GroupByMixin._applycCsð|dkr.|j}|dk    r ||}n|jdks.t‚z8t|tƒrZ|j|krZ|jdk    rZ| |j¡|j|}Wntk
r€|j}YnXd}|jdkr²t     
|¡r¢||ks¬t      |¡r²|}n"|jdkrÔt     
|¡rÔ||j krÔ|}t |ƒ|tt|ƒ|d}|S)rœNré)r’r¯rS)rGr›rrµÚlistr_r³rõÚ
IndexErrorr Z    is_scalarZ is_list_liker´rnrrA)rar_r›rŸr’rSZnew_rsrbrbrcr¡³s8
 
ÿÿÿýz_GroupByMixin._gotitem)N)rorírîrïrðr^rdr
rúr™r–rŽr    r¡rbrbrbrcrôus
 ú
rôcsJeZdZedd„ƒZdd„Zdd„Zdd„Zdd
d „Z‡fd d „Z    ‡Z
S)ÚDatetimeIndexResamplercCstSrt)ÚDatetimeIndexResamplerGroupbyrjrbrbrcr°âsz.DatetimeIndexResampler._resampler_for_groupingcCs&|jdkr|j |j¡S|j |j¡S©NÚperiod)rOrDÚ_get_time_period_binsrHÚ_get_time_binsrjrbrbrcr|æs
z+DatetimeIndexResampler._get_binner_for_timecKsÐt |¡p |}|j}|jjdkr(|j}n|j}t|ƒsr| ¡}|j     |j
¡|_|jj
|j
ksnt |jj
|j
fƒ‚|S|j
dk    s†|j dk    rªt|j jƒt|ƒkrª|dkrª| ¡S|j|j |jdj|f|Ž}| |¡S)úÀ
        Downsample the cython defined function.
 
        Parameters
        ----------
        how : string / cython mapped function
        **kwargs : kw args passed to how function
        rN©rK)ÚcomÚget_cython_funcrHr‘r›r§r~r÷r¶Z
_with_freqrJrÚ inferred_freqrBrrÆr’rKr‹r­)rarrˆrHrGrrbrbrcr–ìs*      ÿÿþýz"DatetimeIndexResampler._downsamplecCs(|jdkr|dd…}n |dd…}|S)z|
        Adjust our binner when upsampling.
 
        The range of a new index should not be outside specified range
        ÚrightrNéÿÿÿÿ)rL©rarErbrbrcÚ_adjust_binner_for_upsamples
 z2DatetimeIndexResampler._adjust_binner_for_upsampleNc    CsŒ|jrtdƒ‚|jrtdƒ‚|j}|j}|j}| |¡}|dkrpt|j    ƒ|j
krpt |ƒt |ƒkrp|  ¡}||_ n|j||||d}| |¡S)aª
        Parameters
        ----------
        method : string {'backfill', 'bfill', 'pad',
            'ffill', 'asfreq'} method for upsampling
        limit : int, default None
            Maximum size gap to fill when reindexing
        fill_value : scalar, default None
            Value to use for missing values
 
        See Also
        --------
        .fillna: Fill NA/NaN values using the specified method.
 
        zaxis must be 0zvUpsampling from level= or on= selection is not supported, use .set_index(...) to explicitly set index to datetime-likeN)r¿r—r˜)rKrrzr¬rHr‘rEr rrrJr~r÷r¶Úreindexr­)    rar¿r—r˜rHrGrEZ    res_indexrrbrbrcr™!s2ÿ
ÿþýÿz DatetimeIndexResampler._upsamplecs6tƒ |¡}|jdkr2t|jtƒs2|j |j¡|_|Sr)r…r­rOrµr¶r5Ú    to_periodrJ)rarr‰rbrcr­Ns z#DatetimeIndexResampler._wrap_result)NN) rorírîròr°r|r–r r™r­rórbrbr‰rcrþás
)
-rþc@seZdZdZedd„ƒZdS)rÿz9
    Provides a resample of a groupby implementation
    cCstSrt)rþrjrbrbrcrø]sz,DatetimeIndexResamplerGroupby._resampler_clsN©rorírîrïròrørbrbrbrcrÿXsrÿcsVeZdZedd„ƒZ‡fdd„Zdddœ‡fdd„ Z‡fd    d
„Zd‡fd d „    Z‡Z    S)ÚPeriodIndexResamplercCstSrt)ÚPeriodIndexResamplerGroupbyrjrbrbrcr°csz,PeriodIndexResampler._resampler_for_groupingcs"|jdkrtƒ ¡S|j |j¡S)NÚ    timestamp)rOr…r|rDÚ_get_period_binsrHrjr‰rbrcr|gs
 
z)PeriodIndexResampler._get_binner_for_timerr{cs:tƒ |¡}|jrd}t|ƒ‚|jdkr6|j|jd}|S)Nz‚Resampling from level= or on= selection with a PeriodIndex is not currently supported, use .set_index(...) to explicitly set indexr©r)r…r\rzÚNotImplementedErrorrOÚ to_timestamprN)rarGÚmsgr‰rbrcr\ls ÿ
z!PeriodIndexResampler._convert_objc s¤|jdkrtƒj|f|ŽSt |¡p&|}|j}t|j|jƒrJ|j|f|ŽSt    |j|jƒrr|dkrj| |¡S| 
¡S|j|jkr†| 
¡St d|j›d|j›dƒ‚dS)rrrßz
Frequency z cannot be resampled to z&, as they are not sub or super periodsN) rOr…r–rrrHr9rJrŽr:rÆr )rarrˆrHr‰rbrcr–~s
 
 
 ÿz PeriodIndexResampler._downsampleNc
sl|jdkrtƒj|||dS|j}|j}|j}|j|j|jd}|j    |||d}t
||||j d}    |  |    ¡S)aœ
        Parameters
        ----------
        method : {'backfill', 'bfill', 'pad', 'ffill'}
            Method for upsampling.
        limit : int, default None
            Maximum size gap to fill when reindexing.
        fill_value : scalar, default None
            Value to use for missing values.
 
        See Also
        --------
        .fillna: Fill NA/NaN values using the specified method.
 
        r)r—r˜r)r¿r—r) rOr…r™rHrGrErÆrJrNZ get_indexerÚ_take_new_indexrKr­)
rar¿r—r˜rHrGÚ    new_indexÚmembr}Únew_objr‰rbrcr™¢s
üzPeriodIndexResampler._upsample)NN)
rorírîròr°r|r\r–r™rórbrbr‰rcrbs 
  $rc@seZdZdZedd„ƒZdS)rú:
    Provides a resample of a groupby implementation.
    cCstSrt)rrjrbrbrcrøÍsz*PeriodIndexResamplerGroupby._resampler_clsNrrbrbrbrcrÈsrc@s(eZdZedd„ƒZdd„Zdd„ZdS)ÚTimedeltaIndexResamplercCstSrt)ÚTimedeltaIndexResamplerGroupbyrjrbrbrcr°Ósz/TimedeltaIndexResampler._resampler_for_groupingcCs|j |j¡Srt)rDÚ_get_time_delta_binsrHrjrbrbrcr|×sz,TimedeltaIndexResampler._get_binner_for_timecCs|S)zÇ
        Adjust our binner when upsampling.
 
        The range of a new index is allowed to be greater than original range
        so we don't need to change the length of a binner, GH 13022
        rbr rbrbrcr Úsz3TimedeltaIndexResampler._adjust_binner_for_upsampleN)rorírîròr°r|r rbrbrbrcrÒs
rc@seZdZdZedd„ƒZdS)rrcCstSrt)rrjrbrbrcrøész-TimedeltaIndexResamplerGroupby._resampler_clsNrrbrbrbrcräsrzSeries | DataFramer{cKstf|Ž}|j||dS)z8
    Create a TimeGrouper and return our resampler.
    ©rO)rCÚ_get_resampler)rGrOÚkwdsÚtgrbrbrcÚ get_resamplerîs
r$r.)r’rXc
Ks4tf||dœ|—Ž}|j|j|d}    |    j||jdS)zA
    Return our appropriate resampler when grouping as well.
    )rJr_r )r’r_)rCr!rGr±r_)
r’ÚrulerÚ fill_methodr—rOÚonrˆr#Z    resamplerrbrbrcÚget_resampler_for_groupingùsr(c sÀeZdZUdZejdZded<d4d d d d ddddddddœ ‡fdd„ Zd5dddœdd„Zd6dddd œd!d"„Z    d#d$œd%d&„Z
d#d'd(d)œd*d+„Z d,d$œd-d.„Z d#d$œd/d0„Z d1d$œd2d3„Z‡ZS)7rCah
    Custom groupby class for time-interval grouping.
 
    Parameters
    ----------
    freq : pandas date offset or offset alias for identifying bin edges
    closed : closed end of interval; 'left' or 'right'
    label : interval boundary to use for labeling; 'left' or 'right'
    convention : {'start', 'end', 'e', 's'}
        If axis is PeriodIndex
    )rLrMrrOrNrPrQrrPÚMinNrØrÚ    start_dayFrz!Literal[('left', 'right')] | Nonererz
str | Nonez*Literal[('start', 'end', 'e', 's')] | NonezVLiteral[('epoch', 'start', 'start_day', 'end', 'end_day')] | TimestampConvertibleTypesz TimedeltaConvertibleTypes | NonerTrU) rJrLrMrrKrOrNrPrQrRrXc 
sø|dkrtd|›dƒ‚|dkr0td|›dƒ‚|    dkrHtd|    ›dƒ‚t|ƒ}ddd    d
d d d h}|j}||ksŽd|kr¨|d| d¡…|kr¨|dkršd}|dkrâd}n:|
dkrÊ|dkr¼d}|dkrâd}n|dkrÖd}|dkrâd}||_||_||_|    dk    r|    nd|_||_||_    ||_
| |_ |
dkr2|
|_ nJzt |
ƒ|_ Wn:ttfk
rz}ztd|
›dƒ|‚W5d}~XYnXz| dk    rt| ƒnd|_Wn:ttfk
rÒ}ztd| ›dƒ|‚W5d}~XYnXd| d<tƒjf||dœ| —ŽdS)N>Nr    ÚleftzUnsupported value z  for `label`z  for `closed`>ÚstartÚendNÚeÚsz for `convention`ÚMÚAÚQZBMZBAZBQÚWú-r    ©r-Úend_dayr+r.)Úepochr,r*r-r6z|'origin' should be equal to 'epoch', 'start', 'start_day', 'end', 'end_day' or should be a Timestamp convertible type. Got 'z
' instead.z6'offset' should be a Timedelta convertible type. Got 'TrY)rJrK)r¬rZ    rule_codeÚfindrLrMrOrNrr&r—rRrPrÚ    TypeErrorrrQr…rd)rarJrLrMrrKr&r—rOrNrPrQrRrˆZ    end_typesr%r®r‰rbrcrd%sf&
 
ÿü
ÿýzTimeGrouper.__init__r*rAr{cCsš|j|dd\}}}t|tƒr6t||||j|j|dSt|tƒsH|dkr`t||||j|j|dSt|tƒr€t    |||j|j|dSt
dt |ƒj ›dƒ‚dS)ad
        Return my resampler or raise if we have an invalid axis.
 
        Parameters
        ----------
        obj : Series or DataFrame
        kind : string, optional
            'period','timestamp','timedelta' are valid
 
        Returns
        -------
        Resampler
 
        Raises
        ------
        TypeError if incompatible axis
 
        N)rW)rVrOrKrRrWr)rVrKrRrWzVOnly valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'ú') r[rµr3rþrKrRr5rr7rr9rnro)rarGrOÚ_rHr}rbrbrcr!s<
úú
ûÿzTimeGrouper._get_resamplerTrztuple[BinGrouper, NDFrameT])rGÚvalidaterXcCs| |¡}|jtt|jƒfSrt)r!rBrrrG)rarGr<ÚrrbrbrcÚ _get_grouper·s
zTimeGrouper._get_grouperr3)rHc    
CsPt|tƒstdt|ƒj›ƒ‚t|ƒdkrJtg|j|jd}}|g|fSt|     ¡| 
¡|j|j |j |j |jd\}}t|j|||j|jdd|j d}}|j}| ||¡\}}tj|||j |jd}|j d    krì|}|jd    krê|d
d…}n|jd    kr|d
d…}|jr$| dt¡}| dt¡}t|ƒt|ƒkrF|dt|ƒ…}|||fS) Nú5axis must be a DatetimeIndex, but got an instance of r©ÚdatarJr´©ÚunitrLrPrQTZ shift_forward)rJr,r-Útzr´Z    ambiguousZ nonexistentrC)Úhasnansr    r)rµr3r9rnror~rJr´Ú_get_timestamp_range_edgesrÑrÒrCrLrPrQr4rDÚasi8Ú_adjust_bin_edgesr Zgenerate_bins_dt64rErMÚinsertr)    rarHrEÚlabelsrÓrÔÚ    ax_valuesÚ    bin_edgesr€rbrbrcr¾s\
ÿ 
ù
ø
ÿ
 
    zTimeGrouper._get_time_binsznpt.NDArray[np.int64]z+tuple[DatetimeIndex, npt.NDArray[np.int64]])rErKrXcCs¨|jdkršt|jdƒrš|jdkrj| d¡}|td|jd |j¡td|jd |j¡}| |j¡j}n|j}|d|     ¡kr |dd…}|dd…}n|j}||fS)NÚDr    r)ÚdaysrC©rCéþÿÿÿr
)
rJr:rLÚ tz_localizerrCÚas_unitrDrGrÒ)rarErKZ    edges_dtirLrbrbrcrHÿs 
 
ÿþÿ zTimeGrouper._adjust_bin_edgesr7cCsÆt|tƒstdt|ƒj›ƒ‚t|ƒsFtg|j|jd}}|g|fS| ¡|     ¡}}|j
dkrl||j7}t |||j|jd}}|}|j
dkrœ||j7}|j ||j
d}|j r¼||j 7}|||fS)Nz6axis must be a TimedeltaIndex, but got an instance of r@r    ©r,r-rJr´r+©Zside)rµr7r9rnror~rJr´rÑrÒrLr8Ú searchsortedrQ)rarHrErJr,r-Ú
end_stampsr€rbrbrcrs.
ÿ
 
 
ÿ
 
 
 
z TimeGrouper._get_time_delta_binscCs¦t|tƒstdt|ƒj›ƒ‚|j}t|ƒsJtg||jd}}|g|fSt    |d|d||jd}}|| 
|d¡  ¡}|j rŽ|  |j ¡}|j|dd}|||fS)    Nr?r@rr
rSr/r+rT)rµr3r9rnrorJr~r5r´r6rÆrrDrQrU)rarHrJrErJrVr€rbrbrcr9s
ÿ
 z!TimeGrouper._get_time_period_binsr5cCsêt|tƒstdt|ƒj›ƒ‚|j|j|jd}d}|jrRt     
|j ¡}||j }t |ƒs®t    j gt    jd}tg|j|jd}}t |ƒdkr¤t|||t |ƒƒ\}}}|||fS|jj}| ¡j|j|jd}| ¡j|jdd}    d}
t|jtƒr8t||    |j|j|j|jd\} }    t||jƒt| |jƒ} | j|}
| }t||    |j|jd}}|j} t |ƒ|}|| d    | d}t     | d| d    ||¡}||7}||
8}t|jƒ||jd}|j|d
d }|dkràt||||ƒ\}}}|||fS) Nz3axis must be a PeriodIndex, but got an instance of rr)rår@r-)rLrPrQrSr
r+rT) rµr5r9rnrorÆrJrNrEÚnprËZ_isnanr~Úarrayrãr´Ú_insert_nat_binÚnrÑrÒr<Ú_get_period_range_edgesrLrPrQrr6rGZarangeÚ_datarårU)rarHrÚ    nat_countr€rErJZ    freq_multr,r-Z    bin_shiftZp_startZ start_offsetÚi8Zexpected_bins_countZ    i8_extendÚrngZprngrbrbrcrOs`
ÿ   
ú
 
 
ÿ
 
zTimeGrouper._get_period_bins) r)NNrØrNNNNr*NF)N)T)rorírîrïr1rmrðrdr!r>rrHrrrrórbrbr‰rcrC s0
 
 
ò(\7ÿA rCrznpt.NDArray[np.intp]r>r)rGr}rrKrXcCslt|tƒr*t |j|¡}|j|||jdSt|tƒr`|dkrDtdƒ‚|j    j
||dd}| |¡St dƒ‚dS)N)r¶r´rzaxis 1 is not supported)Znew_axisr}rKz.'obj' should be either a Series or a DataFrame) rµr'ÚalgosZtake_ndZ_valuesZ _constructorr´r&rZ_mgrZreindex_indexerr¬)rGr}rrKZ
new_valuesZnew_mgrrbrbrcr›s
ÿ
 
rr+r*rr rezLiteral[('right', 'left')]rzTimedelta | Noneztuple[Timestamp, Timestamp])rÓrÔrJrCrLrPrQrXc    Csüt|tƒr´|j}t|tƒr4|jdk|dkkr4tdƒ‚|dkrHtd|d}t|tƒrz| d¡}| d¡}t|tƒrz| d¡}t|||||||d\}}t|tƒrô| |¡}| |¡}n@| ¡}| ¡}|dkrÜt|     |¡ƒ}n t||ƒ}t||ƒ}||fS)aW
    Adjust the `first` Timestamp to the preceding Timestamp that resides on
    the provided offset. Adjust the `last` Timestamp to the following
    Timestamp that resides on the provided offset. Input Timestamps that
    already reside on the offset will be adjusted depending on the type of
    offset and the `closed` parameter.
 
    Parameters
    ----------
    first : pd.Timestamp
        The beginning Timestamp of the range to be adjusted.
    last : pd.Timestamp
        The ending Timestamp of the range to be adjusted.
    freq : pd.DateOffset
        The dateoffset to which the Timestamps will be adjusted.
    closed : {'right', 'left'}, default "left"
        Which side of bin interval is closed.
    origin : {'epoch', 'start', 'start_day'} or Timestamp, default 'start_day'
        The timestamp on which to adjust the grouping. The timezone of origin must
        match the timezone of the index.
        If a timestamp is not used, these values are also supported:
 
        - 'epoch': `origin` is 1970-01-01
        - 'start': `origin` is the first value of the timeseries
        - 'start_day': `origin` is the first day at midnight of the timeseries
    offset : pd.Timedelta, default is None
        An offset timedelta added to the origin.
 
    Returns
    -------
    A tuple of length 2, containing the adjusted pd.Timestamp objects.
    Nz4The origin must have the same timezone as the index.r7z
1970-01-01)rD)rLrPrQrCr+)
rµr<rDrr¬r;rQÚ_adjust_dates_anchoredÚ    normalizeÚrollback)rÓrÔrJrCrLrPrQZindex_tzrbrbrcrF¯s<)
 
 
 
 
 
ÿ
 
 
   rFrztuple[Period, Period])rÓrÔrJrLrPrQrXc
    Cs’tdd„||fDƒƒstdƒ‚| ¡}| ¡}| |¡ }| |¡}    t|||d|||d\}}|t|ƒ| |¡}|t|    ƒ| |¡}||fS)al
    Adjust the provided `first` and `last` Periods to the respective Period of
    the given offset that encompasses them.
 
    Parameters
    ----------
    first : pd.Period
        The beginning Period of the range to be adjusted.
    last : pd.Period
        The ending Period of the range to be adjusted.
    freq : pd.DateOffset
        The freq to which the Periods will be adjusted.
    closed : {'right', 'left'}, default "left"
        Which side of bin interval is closed.
    origin : {'epoch', 'start', 'start_day'}, Timestamp, default 'start_day'
        The timestamp on which to adjust the grouping. The timezone of origin must
        match the timezone of the index.
 
        If a timestamp is not used, these values are also supported:
 
        - 'epoch': `origin` is 1970-01-01
        - 'start': `origin` is the first value of the timeseries
        - 'start_day': `origin` is the first day at midnight of the timeseries
    offset : pd.Timedelta, default is None
        An offset timedelta added to the origin.
 
    Returns
    -------
    A tuple of length 2, containing the adjusted pd.Period objects.
    css|]}t|tƒVqdSrt)rµr)rhrGrbrbrcrk$sz*_get_period_range_edges.<locals>.<genexpr>z3'first' and 'last' must be instances of type PeriodÚnsrB)Úallr9rZ is_on_offsetrFršr)
rÓrÔrJrLrPrQZfirst_tsZlast_tsZ adjust_firstZ adjust_lastrbrbrcr[þs$& 
ÿ
r[r5z
np.ndarrayršz+tuple[PeriodIndex, np.ndarray, PeriodIndex])rEr€rJr]rXcCsD|dks t‚||7}t |d|¡}| dt¡}| dt¡}|||fS)Nr)rrWrIr)rEr€rJr]rbrbrcrY6s    rYr    rdr<)rÓrÔrJrLrPrQrCrXcCs| |¡}| |¡}|dk    r&| |¡}t|ƒ |¡j}d}|dkrN| ¡j}nx|dkr^|j}nht|tƒrv| |¡j}nP|dkrÆ|dkrŠ|n| d¡}    |    j|j|}
|dkr´|
d7}
|    |
|}|j}||rÒ|jnd7}|j} |j} | dk    rö| d    ¡}| dk    r
| d    ¡}|j||} |j||}|d
krr| dkrF|j| }n
|j|}|dkrj|j||}n|j}n@| dkrˆ|j| }n|j}|dkr¨|j||}n
|j|}t||d }t||d }| dk    rä|     d    ¡ | ¡}| dk    rþ|     d    ¡ | ¡}||fS) Nrr*r,r5r-rMr+rÚUTCr    rO)
rRrÚ_valuerbrµrÚceilÚtzinfoZ
tz_convertrQ)rÓrÔrJrLrPrQrCZ
freq_valueZorigin_timestampZ origin_lastZsub_freq_timesZ first_tzinfoZ last_tzinfoZfoffsetZloffsetZ fresult_intZ lresult_intZfresultZlresultrbrbrcraHs`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
raFrT)rGrbrXcCs²t|jtƒrD|dk    rtdƒ‚|dkr(d}| ¡}|jj||d|_njt|jƒdkrj| ¡}t|j|ƒ|_nDt|j     ¡|j 
¡|d}|jj |_ |j |||d}|r®|j  ¡|_|S)z‚
    Utility frequency conversion method for Series/DataFrame.
 
    See :meth:`pandas.NDFrame.asfreq` for full documentation.
    Nz"'method' argument is not supportedÚErrr²)r¿r˜)rµr¶r5rr÷rÆr~r·r4rÑrÒr´r rb)rGrJr¿rrbr˜rZdtirbrbrcrƜs  
 rÆz,DatetimeIndex | PeriodIndex | TimedeltaIndex)r¶cCs|t|ƒdkrtdƒ‚t|tƒr,|j|d}nLt|tƒrLtg|j||jd}n,t|tƒrltg|j||jd}n t    t
|ƒƒ‚|S)zì
    Helper to mimic asfreq on (empty) DatetimeIndex and TimedeltaIndex.
 
    Parameters
    ----------
    index : PeriodIndex, DatetimeIndex, or TimedeltaIndex
    freq : DateOffset
 
    Returns
    -------
    same type as index
    rzECan only set arbitrary freq for empty DatetimeIndex or TimedeltaIndexr²)rårJr´) r~r¬rµr5rÆr3rår´r7r9rn)r¶rJrrbrbrcr·Ás ÿ
 
 
 r·rU)ÚkernelrXcCsz|dk    ot|ƒdk}|dk    o&t|ƒdk}|r6|r6d}n|r@d}n|rJd}ndStjd|›d|j›d|›d    ttƒd
dS) a›
    Warn for deprecation of args and kwargs in resample functions.
 
    Parameters
    ----------
    cls : type
        Class to warn about.
    kernel : str
        Operation name.
    args : tuple or None
        args passed by user. Will be None if and only if kernel does not have args.
    kwargs : dict or None
        kwargs passed by user. Will be None if and only if kernel does not have kwargs.
    Nrzargs and kwargsr‡rˆzPassing additional z to Ú.zj has no impact on the result and is deprecated. This will raise a TypeError in a future version of pandas.)ÚcategoryÚ
stacklevel)r~ÚwarningsÚwarnroÚ FutureWarningr%)Úclsrkr‡rˆZ    warn_argsZ warn_kwargsrrbrbrcrÍßsûrÍ)N)NNNNN)r)r+r*N)r+r*N)r    r*Nrd)NNFN)wÚ
__future__rr÷ÚtextwraprÚtypingrrrrrr    r
roÚnumpyrWZ pandas._libsr Zpandas._libs.tslibsr r rrrrrZpandas._typingrrrrrrrrrrrrZpandas.compat.numpyrrÎZ pandas.errorsr!Zpandas.util._decoratorsr"r#r$Zpandas.util._exceptionsr%Zpandas.core.dtypes.genericr&r'Zpandas.core.algorithmsÚcoreZ
algorithmsr`Zpandas.core.applyr(Zpandas.core.baser)Zpandas.core.commonÚcommonrZpandas.core.genericr*r+Zpandas.core.groupby.genericr,Zpandas.core.groupby.groupbyr-r.r/r0Zpandas.core.groupby.grouperr1Zpandas.core.groupby.opsr2Zpandas.core.indexes.datetimesr3r4Zpandas.core.indexes.periodr5r6Zpandas.core.indexes.timedeltasr7r8Zpandas.tseries.frequenciesr9r:Zpandas.tseries.offsetsr;r<rçr=r>r?r@rðrArôrþrÿrrrrr$rïr(rCrrFr[rYrarÆr·rÍrbrbrbrcÚ<module>s¤  $     $    8         lw
f
 
ùÿùSú8ùWú%