
    MhZu                      % S SK Jr  S SKrS SKJr  S SKJrJrJrJ	r	J
r
Jr  S SKrS SKrS SKJr  S SKJrJrJrJrJrJrJr  S SKJr  S SKJr  S S	KJr  S S
K J!r!  S SK"J#r#J$r$J%r%  S SK&J'r'J(r(  S SK)J*r*  S SK+J,r,J-r-  S SK.J/s  J0r1  S SK2J3r3J4r4  S SK5J6r6  S SK7J8r8J9r9  S SK:J/s  J;r<  S SK=J>r>J?r?  S SK@JArA  S SKBJCrCJDrDJErEJFrFJGrG  S SKHJIrI  S SKJJKrK  S SKLJMrM  S SKNJOrO  S SKPJQrQJRrR  S SKSJTrTJUrU  S SKVJWrWJXrX  S SKYJZrZJ[r[  S SK\J]r]J^r^  \(       a(  S SK_J`r`  S SKJaraJbrbJcrcJdrdJereJfrfJgrgJhrhJiriJjrjJkrk  S S KlJmrmJnrn  0 roS!\pS"'    " S# S$\C\85      rq " S% S&\8\95      rr " S' S(\q5      rs " S) S*\r\s5      rt " S+ S,\s5      ru " S- S.\r\u5      rv " S/ S0\s5      rw " S1 S2\r\w5      rxS@SAS3 jjry\qR                  \ylz              SB       SCS4 jjr{ " S5 S6\I5      r| SD         SES7 jjr}   SF               SGS8 jjr~   SF             SHS9 jjr          SIS: jr    SJ               SKS; jjr    SL     SMS< jjrSNS= jrSOS> jr        SPS? jrg)Q    )annotationsN)dedent)TYPE_CHECKINGCallableLiteralcastfinalno_type_check)lib)
BaseOffsetIncompatibleFrequencyNaTPeriod	Timedelta	Timestamp	to_offset)freq_to_period_freqstr)NDFrameT)functionAbstractMethodError)AppenderSubstitutiondoc)find_stack_levelrewrite_warning)
ArrowDtype)ABCDataFrame	ABCSeries)ResamplerWindowApplywarn_alias_replacement)ArrowExtensionArray)PandasObjectSelectionMixin)NDFrame_shared_docs)SeriesGroupBy)BaseGroupByGroupBy_apply_groupings_depr_pipe_templateget_groupby)Grouper)
BinGrouper)
MultiIndex)Index)DatetimeIndex
date_range)PeriodIndexperiod_range)TimedeltaIndextimedelta_range)is_subperiodis_superperiod)DayTick)Hashable)AnyArrayLikeAxisAxisInt	Frequency
IndexLabelInterpolateOptionsTTimedeltaConvertibleTypesTimeGrouperOriginTimestampConvertibleTypesnpt)	DataFrameSerieszdict[str, str]_shared_docs_kwargsc            	        ^  \ rS rSr% SrS\S'   S\S'   S\S'   \" 5       rS	\S
'   \" 1 Sk5      r	/ SQr
  SCSSSS.             SDS jjjr\SES j5       r\SFS j5       r\\SGS j5       5       rSHS jrS r\S 5       r\\" S SS9\" \5          SIU 4S jj5       5       5       r\" S5      r\" S5      r\\" \S   \\SS S!9SJS" j5       5       r\r\r\S# 5       r S$ r!SKSLS% jjr"SJSMS& jjr#S' r$\ SN   SOS( jj5       r%S) r&\SJSLS* jj5       r'\SJSLS+ jj5       r(\SJSLS, jj5       r)\SJSLS- jj5       r*\ SPSSSS.S\+RX                  S/.         SQS0 jjj5       r-\SJS1 j5       r.\  SR   SSS2 jj5       r/\  SR   SSS3 jj5       r0\  SR   SSS4 jj5       r1\  SR   SSS5 jj5       r2\\" \3Rh                  5         ST     SUS6 jj5       5       r4\\" \3Rj                  5         ST     SUS7 jj5       5       r5\\" \3Rl                  5      SVSWS8 jj5       5       r6\ SV SWS9 jj5       r7\  SX   SYS: jj5       r8\  SX   SYS; jj5       r9\\" \3Rt                  5        SX   SYS< jj5       5       r:\\" \3Rv                  5      S= 5       5       r;\\" \<Rz                  5      S> 5       5       r=\\" \3R|                  5      S? 5       5       r>\\" \3R~                  5      S@ 5       5       r?\SZS[SA jj5       r@SBrAU =rB$ )\	Resamplery   a  
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.
r.   _grouperTimeGrouper_timegrouperz,DatetimeIndex | TimedeltaIndex | PeriodIndexbinnerzfrozenset[Hashable]
exclusions>   axobj_indexer)freqaxisclosedlabel
conventionkindoriginoffsetr   NFT)
group_keys	selectioninclude_groupsc                  X l         S U l        SU l        UR                  U5      U l        X@l        X`l        SU l        Xl        U R                   R                  U R                  U5      SUS9u  U l        U l        U l        U R                  5       u  U l        U l        Xpl        U R                   R$                  b&  ['        U R                   R$                  /5      U l        g ['        5       U l        g )NT)sort	gpr_index)rO   keysra   _get_axis_numberrV   rZ   r]   as_indexr_   _set_grouper_convert_objrS   rR   rT   _get_binnerrP   rM   
_selectionkey	frozensetrQ   )	selfrS   timegrouperrV   rZ   rb   r]   r^   r_   s	            F/var/www/html/env/lib/python3.13/site-packages/pandas/core/resample.py__init__Resampler.__init__   s     (		((.		$,+/+<+<+I+Ic" ,J ,
($'4= &*%5%5%7"T]#  ,'):):)>)>(?@DO'kDO    c                   ^  U 4S jT R                    5       n[        T 5      R                   SSR                  U5       S3$ )z0
Provide a nice str repr of our rolling object.
c              3     >#    U  H:  n[        TR                  US 5      c  M  U S[        TR                  U5       3v   M<     g 7f)N=)getattrrO   ).0krl   s     rn   	<genexpr>$Resampler.__str__.<locals>.<genexpr>   sE      
%t((!T2 3qc74,,a012%s
   A"Az [z, ])_attributestype__name__join)rl   attrss   ` rn   __str__Resampler.__str__   sB    

%%

 t*%%&b5)9(:!<<rq   c                    XR                   ;   a  [        R                  X5      $ XR                  ;   a  [	        U R
                  U5      $ XR                  ;   a  X   $ [        R                  X5      $ N)_internal_names_setobject__getattribute__r{   ru   rO   rS   )rl   attrs     rn   __getattr__Resampler.__getattr__   sa    +++**466###4,,d3388:&&t22rq   c                    U R                   SL=(       a7    U R                   R                  SL=(       d    U R                   R                  SL$ )z@
Is the resampling from a DataFrame column or MultiIndex level.
N)rO   rj   levelrl   s    rn   _from_selectionResampler._from_selection   sG       , 
!!-T1B1B1H1HPT1T	
rq   c                "    UR                  5       $ )z
Provide any conversions for the object in order to correctly handle.

Parameters
----------
obj : Series or DataFrame

Returns
-------
Series or DataFrame
)_consolidate)rl   rS   s     rn   rg   Resampler._convert_obj   s     !!rq   c                    [        U 5      er   r   r   s    rn   _get_binner_for_timeResampler._get_binner_for_time       !$''rq   c                    U R                  5       u  pn[        U5      [        U5      :X  d   e[        X#U R                  S9nX4$ )zS
Create the BinGrouper, assume that self.set_grouper(obj)
has already been called.
)indexer)r   lenr.   rT   )rl   rP   bins	binlabelsbin_groupers        rn   rh   Resampler._get_binner   sF     #'";";"=i4yC	N*** $--H""rq   a  
    >>> 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examplesc                ,   > [         TU ]  " U/UQ70 UD6$ r   )superpipe)rl   funcargskwargs	__class__s       rn   r   Resampler.pipe  s    8 w|D242622rq   a[  
    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("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': "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
    	aggregaterG    )see_alsor   r   rV   c                l    [        XX#S9R                  5       nUc  UnU R                  " U/UQ70 UD6nU$ )N)r   r   )r    agg_groupby_and_aggregate)rl   r   r   r   resulthows         rn   r   Resampler.aggregateW  sB     &dtKOOQ>C00FtFvFFrq   c                t    U R                   R                  U R                  5      R                  " U/UQ70 UD6$ )a  
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groupbyrO   	transform)rl   argr   r   s       rn   r   Resampler.transformj  sB    B !!))$*;*;<FF

 
 	
rq   c                    [        U 5      er   r   )rl   fr   s      rn   _downsampleResampler._downsample  r   rq   c                    [        U 5      er   r   )rl   r   limit
fill_values       rn   	_upsampleResampler._upsample  r   rq   c                    U R                   nUc&  U R                  nUb  X1   nOUR                  S:X  d   eUS:X  a  UR                  S:X  d   e[        USX@R                  U R
                  S9nU$ )
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   bygrouperrV   r]   )rM   rS   ndimr,   rV   r]   )rl   rj   r   subsetr   groupeds         rn   _gotitemResampler._gotitem  sv     -->XXF {{a'''19;;!###tW99
 rq   c                   ^^^ U R                   nU R                  n[        USX@R                  U R                  S9n [        T5      (       a  UUU4S jnUR                  U5      nOUR                  " T/TQ70 TD6n U R                  U5      $ ! [        [        4 a    [        UT/TQ7SU R                  0TD6n N?[         a7  n	S[        U	5      ;   a  Oe [        UT/TQ7SU R                  0TD6n Sn	A	NzSn	A	ff = f)z1
Re-evaluate the obj with a groupby aggregation.
Nr   c                   > T" U /TQ70 TD6$ r    )xr   r   r   s    rn   <lambda>2Resampler._groupby_and_aggregate.<locals>.<lambda>  s    Q!8!8!8rq   r_   zMust produce aggregated value)rM   _obj_with_exclusionsr,   rV   r]   callabler   AttributeErrorKeyError_applyr_   
ValueErrorstr_wrap_result)
rl   r   r   r   r   rS   r   r   r   errs
    ```      rn   r    Resampler._groupby_and_aggregate  s    -- ''D'		doo
 	}} 9 **40 **3@@@6   ((5 ) 
	 #484G4GKQF  	.#c(:  #484G4GKQF	s#   )B 'B ,C==	C=-C88C=c                "    U R                  XXS9$ )z7
Return the correct class for resampling with groupby.
)r   rj   parentr_   )_resampler_for_grouping)rl   r   rj   r_   s       rn   _get_resampler_for_grouping%Resampler._get_resampler_for_grouping  s!     ++T , 
 	
rq   c                   U R                   n[        U[        5      (       a]  [        U5      S:X  aN  [        UR                  [
        5      (       d/  UR                  [        UR                  SS U R                  S9SS9n[        U[        5      (       a  U R                  b  U R                  Ul        [        U[        5      (       aI  UR                  (       a8  [        UR                  SS U R                  S9Ul        [        USS5      Ul        U R                  R                  b4  UR                  R!                  U R                  R                  5      Ul        U$ )z
Potentially wrap any results.
r   NrU   T)appendname)rS   
isinstancer   r   indexr3   	set_index_asfreq_compatrU   r   ri   r   emptyru   rO   _arrow_dtypeastype)rl   r   rS   s      rn   r   Resampler._wrap_result  s   
 hhv|,,Fq v||[99%%syy!}499=d & F fi((T__-H//FKfi((V\\)#))BQ-diiHFL!#vt4FK))5!<<..t/@/@/M/MNFLrq   c                "    U R                  SUS9$ )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.

Examples
--------
Here we only create a ``Series``.

>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
...                 ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
>>> ser
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    4
dtype: int64

Example for ``ffill`` with downsampling (we have fewer dates after resampling):

>>> ser.resample('MS').ffill()
2023-01-01    1
2023-02-01    3
Freq: MS, dtype: int64

Example for ``ffill`` with upsampling (fill the new dates with
the previous value):

>>> ser.resample('W').ffill()
2023-01-01    1
2023-01-08    1
2023-01-15    2
2023-01-22    2
2023-01-29    2
2023-02-05    3
2023-02-12    3
2023-02-19    4
Freq: W-SUN, dtype: int64

With upsampling and limiting (only fill the first new date with the
previous value):

>>> ser.resample('W').ffill(limit=1)
2023-01-01    1.0
2023-01-08    1.0
2023-01-15    2.0
2023-01-22    2.0
2023-01-29    NaN
2023-02-05    3.0
2023-02-12    NaN
2023-02-19    4.0
Freq: W-SUN, dtype: float64
ffillr   r   rl   r   s     rn   r   Resampler.ffill	  s    F ~~gU~33rq   c                "    U R                  SUS9$ )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: 15min, 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: 15min, dtype: float64
nearestr   r   r   s     rn   r   Resampler.nearestN  s    v ~~iu~55rq   c                "    U R                  SUS9$ )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: 30min, 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: 15min, 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   s     rn   r   Resampler.bfill  s    J ~~gU~33rq   c                    [         R                  " [        U 5      R                   S3[        [        5       S9  U R                  XS9$ )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: 30min, 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: 30min, 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: 15min, 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: 30min, 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: 30min, 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: 30min, 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: 30min, 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: 30min, 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
zv.fillna is deprecated and will be removed in a future version. Use obj.ffill(), obj.bfill(), or obj.nearest() instead.
stacklevelr   )warningswarnr|   r}   FutureWarningr   r   )rl   methodr   s      rn   fillnaResampler.fillna  sI    ~ 	Dz""# $( ( ')	
 ~~f~22rq   forward)rV   r   inplacelimit_direction
limit_areadowncastc                   U[         R                  L d   eU R                  S5      n	U	R                  " SUUUUUUUS.UD6$ )a  
Interpolate values between target timestamps according to different methods.

The original index is first reindexed to target timestamps
(see :meth:`core.resample.Resampler.asfreq`),
then the interpolation of ``NaN`` values via :meth:`DataFrame.interpolate`
happens.

Parameters
----------
method : str, default 'linear'
    Interpolation technique to use. One of:

    * 'linear': Ignore the index and treat the values as equally
      spaced. This is the only method supported on MultiIndexes.
    * 'time': Works on daily and higher resolution data to interpolate
      given length of interval.
    * 'index', 'values': use the actual numerical values of the index.
    * 'pad': Fill in NaNs using existing values.
    * 'nearest', 'zero', 'slinear', 'quadratic', 'cubic',
      'barycentric', 'polynomial': Passed to
      `scipy.interpolate.interp1d`, whereas 'spline' is passed to
      `scipy.interpolate.UnivariateSpline`. These methods use the numerical
      values of the index.  Both 'polynomial' and 'spline' require that
      you also specify an `order` (int), e.g.
      ``df.interpolate(method='polynomial', order=5)``. Note that,
      `slinear` method in Pandas refers to the Scipy first order `spline`
      instead of Pandas first order `spline`.
    * 'krogh', 'piecewise_polynomial', 'spline', 'pchip', 'akima',
      'cubicspline': Wrappers around the SciPy interpolation methods of
      similar names. See `Notes`.
    * 'from_derivatives': Refers to
      `scipy.interpolate.BPoly.from_derivatives`.

axis : {{0 or 'index', 1 or 'columns', None}}, default None
    Axis to interpolate along. For `Series` this parameter is unused
    and defaults to 0.
limit : int, optional
    Maximum number of consecutive NaNs to fill. Must be greater than
    0.
inplace : bool, default False
    Update the data in place if possible.
limit_direction : {{'forward', 'backward', 'both'}}, Optional
    Consecutive NaNs will be filled in this direction.

    If limit is specified:
        * If 'method' is 'pad' or 'ffill', 'limit_direction' must be 'forward'.
        * If 'method' is 'backfill' or 'bfill', 'limit_direction' must be
          'backwards'.

    If 'limit' is not specified:
        * If 'method' is 'backfill' or 'bfill', the default is 'backward'
        * else the default is 'forward'

        raises ValueError if `limit_direction` is 'forward' or 'both' and
            method is 'backfill' or 'bfill'.
        raises ValueError if `limit_direction` is 'backward' or 'both' and
            method is 'pad' or 'ffill'.

limit_area : {{`None`, 'inside', 'outside'}}, default None
    If limit is specified, consecutive NaNs will be filled with this
    restriction.

    * ``None``: No fill restriction.
    * 'inside': Only fill NaNs surrounded by valid values
      (interpolate).
    * 'outside': Only fill NaNs outside valid values (extrapolate).

downcast : optional, 'infer' or None, defaults to None
    Downcast dtypes if possible.

    .. deprecated:: 2.1.0

``**kwargs`` : optional
    Keyword arguments to pass on to the interpolating function.

Returns
-------
DataFrame or Series
    Interpolated values at the specified freq.

See Also
--------
core.resample.Resampler.asfreq: Return the values at the new freq,
    essentially a reindex.
DataFrame.interpolate: Fill NaN values using an interpolation method.

Notes
-----
For high-frequent or non-equidistant time-series with timestamps
the reindexing followed by interpolation may lead to information loss
as shown in the last example.

Examples
--------

>>> start = "2023-03-01T07:00:00"
>>> timesteps = pd.date_range(start, periods=5, freq="s")
>>> series = pd.Series(data=[1, -1, 2, 1, 3], index=timesteps)
>>> series
2023-03-01 07:00:00    1
2023-03-01 07:00:01   -1
2023-03-01 07:00:02    2
2023-03-01 07:00:03    1
2023-03-01 07:00:04    3
Freq: s, dtype: int64

Upsample the dataframe to 0.5Hz by providing the period time of 2s.

>>> series.resample("2s").interpolate("linear")
2023-03-01 07:00:00    1
2023-03-01 07:00:02    2
2023-03-01 07:00:04    3
Freq: 2s, dtype: int64

Downsample the dataframe to 2Hz by providing the period time of 500ms.

>>> series.resample("500ms").interpolate("linear")
2023-03-01 07:00:00.000    1.0
2023-03-01 07:00:00.500    0.0
2023-03-01 07:00:01.000   -1.0
2023-03-01 07:00:01.500    0.5
2023-03-01 07:00:02.000    2.0
2023-03-01 07:00:02.500    1.5
2023-03-01 07:00:03.000    1.0
2023-03-01 07:00:03.500    2.0
2023-03-01 07:00:04.000    3.0
Freq: 500ms, dtype: float64

Internal reindexing with ``asfreq()`` prior to interpolation leads to
an interpolated timeseries on the basis the reindexed timestamps (anchors).
Since not all datapoints from original series become anchors,
it can lead to misleading interpolation results as in the following example:

>>> series.resample("400ms").interpolate("linear")
2023-03-01 07:00:00.000    1.0
2023-03-01 07:00:00.400    1.2
2023-03-01 07:00:00.800    1.4
2023-03-01 07:00:01.200    1.6
2023-03-01 07:00:01.600    1.8
2023-03-01 07:00:02.000    2.0
2023-03-01 07:00:02.400    2.2
2023-03-01 07:00:02.800    2.4
2023-03-01 07:00:03.200    2.6
2023-03-01 07:00:03.600    2.8
2023-03-01 07:00:04.000    3.0
Freq: 400ms, dtype: float64

Note that the series erroneously increases between two anchors
``07:00:00`` and ``07:00:02``.
asfreq)r   rV   r   r  r  r  r  r   )r   
no_defaultr   interpolate)
rl   r   rV   r   r  r  r  r  r   r   s
             rn   r  Resampler.interpolate  s\    H 3>>))))!! 	
+!	
 	
 		
rq   c                "    U R                  SUS9$ )a  
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.

Examples
--------

>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
...                 ['2023-01-01', '2023-01-31', '2023-02-01', '2023-02-28']))
>>> ser
2023-01-01    1
2023-01-31    2
2023-02-01    3
2023-02-28    4
dtype: int64
>>> ser.resample('MS').asfreq()
2023-01-01    1
2023-02-01    3
Freq: MS, dtype: int64
r  )r   r   )rl   r   s     rn   r  Resampler.asfreqK  s    J ~~h:~>>rq   c                |    [        [        U 5      SX45        [        R                  " SX45        U R	                  SXS9$ )a  
Compute sum of group values.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

    .. versionchanged:: 2.0.0

        numeric_only no longer accepts ``None``.

min_count : int, default 0
    The required number of valid values to perform the operation. If fewer
    than ``min_count`` non-NA values are present the result will be NA.

Returns
-------
Series or DataFrame
    Computed sum of values within each group.

Examples
--------
>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
...                 ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
>>> ser
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    4
dtype: int64
>>> ser.resample('MS').sum()
2023-01-01    3
2023-02-01    7
Freq: MS, dtype: int64
sumnumeric_only	min_countmaybe_warn_args_and_kwargsr|   nvvalidate_resampler_funcr   rl   r  r  r   r   s        rn   r  Resampler.sumr  s;    X 	#4:udC
""5$7LVVrq   c                |    [        [        U 5      SX45        [        R                  " SX45        U R	                  SXS9$ )a!  
Compute prod of group values.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.

    .. versionchanged:: 2.0.0

        numeric_only no longer accepts ``None``.

min_count : int, default 0
    The required number of valid values to perform the operation. If fewer
    than ``min_count`` non-NA values are present the result will be NA.

Returns
-------
Series or DataFrame
    Computed prod of values within each group.

Examples
--------
>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
...                 ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
>>> ser
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    4
dtype: int64
>>> ser.resample('MS').prod()
2023-01-01    2
2023-02-01   12
Freq: MS, dtype: int64
prodr  r  r  s        rn   r  Resampler.prod  s;    X 	#4:vtD
""648\WWrq   c                |    [        [        U 5      SX45        [        R                  " SX45        U R	                  SXS9$ )a  
Compute min value of group.

Returns
-------
Series or DataFrame

Examples
--------
>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
...                 ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
>>> ser
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    4
dtype: int64
>>> ser.resample('MS').min()
2023-01-01    1
2023-02-01    3
Freq: MS, dtype: int64
minr  r  r  s        rn   r  Resampler.min  s:    > 	#4:udC
""5$7LVVrq   c                |    [        [        U 5      SX45        [        R                  " SX45        U R	                  SXS9$ )a  
Compute max value of group.

Returns
-------
Series or DataFrame

Examples
--------
>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
...                 ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
>>> ser
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    4
dtype: int64
>>> ser.resample('MS').max()
2023-01-01    2
2023-02-01    4
Freq: MS, dtype: int64
maxr  r  r  s        rn   r  Resampler.max  s:    < 	#4:udC
""5$7LVVrq   c                ~    [        [        U 5      SXE5        [        R                  " SXE5        U R	                  SXUS9$ )Nfirstr  r  skipnar  rl   r  r  r#  r   r   s         rn   r!  Resampler.first  sC     	#4:wE
""7D9,F   
 	
rq   c                ~    [        [        U 5      SXE5        [        R                  " SXE5        U R	                  SXUS9$ )Nlastr"  r  r$  s         rn   r'  Resampler.last'  sC     	#4:vtD
""6486   
 	
rq   c                |    [        [        U 5      SX#5        [        R                  " SX#5        U R	                  SUS9$ )Nmedianr  r  rl   r  r   r   s       rn   r*  Resampler.median7  s:     	#4:xF
""8T:|DDrq   c                |    [        [        U 5      SX#5        [        R                  " SX#5        U R	                  SUS9$ )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.

Examples
--------

>>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex(
...                 ['2023-01-01', '2023-01-15', '2023-02-01', '2023-02-15']))
>>> ser
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    4
dtype: int64
>>> ser.resample('MS').mean()
2023-01-01    1.5
2023-02-01    3.5
Freq: MS, dtype: float64
meanr+  r  r,  s       rn   r/  Resampler.mean>  s;    P 	#4:vtD
""648\BBrq   c                |    [        [        U 5      SX45        [        R                  " SX45        U R	                  SXS9$ )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.

Examples
--------

>>> ser = pd.Series([1, 3, 2, 4, 3, 8],
...                 index=pd.DatetimeIndex(['2023-01-01',
...                                         '2023-01-10',
...                                         '2023-01-15',
...                                         '2023-02-01',
...                                         '2023-02-10',
...                                         '2023-02-15']))
>>> ser.resample('MS').std()
2023-01-01    1.000000
2023-02-01    2.645751
Freq: MS, dtype: float64
stdddofr  r  rl   r4  r  r   r   s        rn   r2  Resampler.stdj  s;    X 	#4:udC
""5$7DLLrq   c                |    [        [        U 5      SX45        [        R                  " SX45        U R	                  SXS9$ )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.

Examples
--------

>>> ser = pd.Series([1, 3, 2, 4, 3, 8],
...                 index=pd.DatetimeIndex(['2023-01-01',
...                                         '2023-01-10',
...                                         '2023-01-15',
...                                         '2023-02-01',
...                                         '2023-02-10',
...                                         '2023-02-15']))
>>> ser.resample('MS').var()
2023-01-01    1.0
2023-02-01    7.0
Freq: MS, dtype: float64

>>> ser.resample('MS').var(ddof=0)
2023-01-01    0.666667
2023-02-01    4.666667
Freq: MS, dtype: float64
varr3  r  r5  s        rn   r8  Resampler.var  s;    d 	#4:udC
""5$7DLLrq   c                |    [        [        U 5      SX45        [        R                  " SX45        U R	                  SXS9$ )Nsemr3  r  r5  s        rn   r;  Resampler.sem  s:     	#4:udC
""5$7DLLrq   c                
   [        [        U 5      SX5        [        R                  " SX5        U R                  nU R
                  n[        U5      S:X  a  UR                  5       n[        UR                  U R                  5      Ul	        UR                  S:X  a$  UR                  5       nUR                  / SQSS9nU$ [        R                  " UR                   / SQ/5      nUR                  USS9nU$ U R#                  S5      $ )Nohlcr   r   )openhighlowcloserV   )r  r|   r  r  rR   r   r   copyr   r   rU   r   to_framereindexr/   from_productcolumnsr   )rl   r   r   rR   rS   mis         rn   r>  Resampler.ohlc  s     	#4:vtD
""648WW''r7a<((*C&syy$))<CIxx1}llnkk"BkK J	  ,,[["BC kk"1k-J''rq   c                ~    [        [        U 5      SX5        [        R                  " SX5        U R	                  S5      $ )Nnuniquer  )rl   r   r   s      rn   rL  Resampler.nunique  s5     	#4:y$G
""9d;	**rq   c                ^   U R                  S5      n[        U[        5      (       a   UR                  (       d  UR	                  SS9n[        U R                  5      (       dL  SSKJn  U R                  R                  S:X  a  U R                  R                  nOS nU" / UR                  SUS9nU$ )	NsizeT)future_stackr   )rH   r   int64r   dtyper   )r   r   r   r   stackr   rR   pandasrH   r   r   r   r   )rl   r   rH   r   s       rn   rO  Resampler.size  s     !!&) fl++FLL\\t\4F477||%!!&&!+))..Bfll'MFrq   c                N   U R                  S5      n[        U R                  5      (       dy  U R                  R                  S:X  a<  [        U R                  5      " / UR                  SU R                  R                  S9nU$ SSKJ	n  U" / UR                  UR                  SS9nU$ )Ncountr   rQ  rR  r   )rG   )r   rH  rS  )r   r   rR   r   r   r|   r   r   rU  rG   rH  )rl   r   rG   s      rn   rX  Resampler.count  s     !!'*477||!!&&!+d001fll'@R@R@W@W  -"fllFNN' rq   c                *    U R                   " SSU0UD6$ )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.

Examples
--------

>>> ser = pd.Series([1, 3, 2, 4, 3, 8],
...                 index=pd.DatetimeIndex(['2023-01-01',
...                                         '2023-01-10',
...                                         '2023-01-15',
...                                         '2023-02-01',
...                                         '2023-02-10',
...                                         '2023-02-15']))
>>> ser.resample('MS').quantile()
2023-01-01    2.0
2023-02-01    4.0
Freq: MS, dtype: float64

>>> ser.resample('MS').quantile(.25)
2023-01-01    1.5
2023-02-01    3.5
Freq: MS, dtype: float64
q)quantile)r   )rl   r[  r   s      rn   r\  Resampler.quantile*  s    Z :a:6::rq   )rM   rT   ri   rO   re   rR   rV   rP   rQ   r]   r_   rc   rZ   rS   ra   )r   N)rS   r%   rm   rN   rV   r=   rb   r0   r]   boolr_   r^  returnNone)r_  r   )r   r   )r_  r^  rS   r   r_  r   )r   z/Callable[..., T] | tuple[Callable[..., T], str]r_  rB   r   NNr   
int | None)r   intT)r   r)   r_   r^  )linear)
r   rA   rV   r=   r   rd  r  r^  r  z&Literal['forward', 'backward', 'both'])Fr   )r  r^  r  re  )Fr   T)r  r^  r  re  r#  r^  F)r  r^  )r   F)r4  re  r  r^  )g      ?)r[  z"float | list[float] | AnyArrayLike)Cr}   
__module____qualname____firstlineno____doc____annotations__rk   rQ   setr   r{   ro   r	   r   r   propertyr   rg   r   rh   r   r   r+   r   r   _agg_see_also_doc_agg_examples_docr   r&   r   r   applyr   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r)   r!  r'  r*  r/  r2  r8  r;  r>  r'   rL  rO  rX  r\  __static_attributes____classcell__r   s   @rn   rK   rK   y   s   . 88&/kJ#178	K * !#** !* 	* * * * 
*> 	= 	= 3 3 
  
"( # # ( n3=3
 
3 ) ,3 		 '	)V [!""  CE
"
 "
H((8/)b <@

59
 
8 B4 B4H :6 :6x d4 d4L e3 e3N  &.n
  BKn
"n
 	n

 n
 n
 @n
 n
` $? $?L  #-W-W -W -W^  #-X-X -X -X^  # W W  W  WD  #WW W WB  #	

 
 	
  
  #	

 
 	
  
 E  E
  #)C)C )CV  "-M-M -M -M^  "3M3M 3M 3Mj  "	M	M 	M  	M (  (4 		+   +   $     ,; ,;rq   rK   c                      \ rS rSr% SrS\S'   SrS\S'   S\S	'   S
\S'   SSSS.         SS jjr\S 5       r	\	r
\	r\	r\SS j5       rSrg)_GroupByMixiniZ  z!
Provide the groupby facilities.
z	list[str]r{   NIndexLabel | Noneri   r)   _groupbyrN   rO   F)rj   r^   r_   c          	        [        U[        5      (       d   [        U5      5       e[        U[        5      (       d   [        U5      5       eU R                   H  n[        X[        X5      5        M     X@l        UR                  U l        X0l	        X l
        [        R                  " UR                  5      U l        UR                  U l        UR                  U l        XPl        g r   )r   r)   r|   rK   r{   setattrru   ri   rP   rj   ry  rD  rO   rR   rS   r_   )rl   r   r   rj   r^   r_   r   s          rn   ro   _GroupByMixin.__init__d  s     '7++:T']:+ &),,:d6l:, $$DD 56 %#mm IIf&9&9:))::,rq   c                |   ^ ^^^ UUUU 4S jn[        T R                  UT R                  S9nT R                  U5      $ )z
Dispatch to _upsample; we are stripping all of the _upsample kwargs and
performing the original function call on the grouped object.
c                   > TR                  U TR                  TR                  S9n [        T[        5      (       a  [        U T5      " S0 TD6$ U R                  " T/TQ70 TD6$ )N)rm   rb   r   )_resampler_clsrO   rR   r   r   ru   rr  )r   r   r   r   rl   s    rn   r   "_GroupByMixin._apply.<locals>.func  sa    ##A43D3DPTPWPW#XA!S!!q!}.v..771.t.v..rq   )r_   )r   ry  r_   r   )rl   r   r   r   r   r   s   ````  rn   r   _GroupByMixin._apply  s8    	/ 	/ tD<O<OP  ((rq   c                   Uc&  U R                   nUb  X1   nOUR                  S:X  d   e [        U[        5      (       a8  U R                  U;  a(  U R                  b  UR                  U R                  5        U R                  U   nU R                  X5      n[        U 5      " U[        [        U 5      US9nU$ ! [         a    U R                  n NJf = f)r   r   )r   r   r^   )rS   r   r   listrj   r   ry  
IndexError_infer_selectionr|   r   rK   )rl   rj   r   r   r   r^   new_rss          rn   r   _GroupByMixin._gotitem  s     >XXF {{a'''	$#t$$)<AU

488$mmC(G ))#6	d	4(

   	$mmG	$s   AB9 9CC)ry  ri   rO   rR   rP   r_   rj   rS   )
r   rK   r   r)   r^   rx  r_   r^  r_  r`  r   )r}   ri  rj  rk  rl  rm  ri   ro   r
   r   r   r   r   r	   r   rs  r   rq   rn   rw  rw  Z  s     $(J!( '+$- - 	- %- - 
-@ ) )" IK#
$ $rq   rw  c                  d   ^  \ rS rSr% S\S'   \S 5       rS rS rS r	SSS jjr
U 4S	 jrS
rU =r$ )DatetimeIndexResampleri  r1   rR   c                    [         $ r   )DatetimeIndexResamplerGroupbyr   s    rn   r   .DatetimeIndexResampler._resampler_for_grouping  s    ,,rq   c                    U R                   S:X  a%  U R                  R                  U R                  5      $ U R                  R	                  U R                  5      $ )Nperiod)rZ   rO   _get_time_period_binsrR   _get_time_binsr   s    rn   r   +DatetimeIndexResampler._get_binner_for_time  sD    99 $$::477CC  //88rq   c                   Un[         R                  " U5      =(       d    UnX1:w  a  [        XU5        U R                  nU R                  n[        U5      (       d  UR                  5       nUR                  R                  U R                  5      Ul        UR                  R                  U R                  :X  d'   UR                  R                  U R                  45       eU$ UR                  c  UR                  b?  [        U R                  R                  5      [        U5      :  a  Uc  U R                  5       $ U R                  S:X  a-  UR                  U R                  5      R                   " U40 UD6nO@UR"                  R                  U R                  5      R                   " U40 UD6R"                  nU R%                  U5      $ )
Downsample the cython defined function.

Parameters
----------
how : string / cython mapped function
**kwargs : kw args passed to how function
r   )comget_cython_funcr!   rR   r   r   rD  r   
_with_freqrU   inferred_freqrM   r   r  rV   r   r   rB   r   )rl   r   r   orig_howrR   rS   r   s          rn   r   "DatetimeIndexResampler._downsample  sY    !!#&-#?"437WW ''2ww((*C		,,TYY7CI99>>TYY.K0KK.J WW B$4$4$@DMM++,s2w6 ;;=  99>[[/99#HHF UU]]4==1;;CJ6JLLF  ((rq   c                >    U R                   S:X  a  USS nU$ USS nU$ )zd
Adjust our binner when upsampling.

The range of a new index should not be outside specified range
rightr   N)rW   rl   rP   s     rn   _adjust_binner_for_upsample2DatetimeIndexResampler._adjust_binner_for_upsample  s4     ;;'!ABZF  CR[Frq   c                   U R                   (       a  [        S5      eU R                  (       a  [        S5      eU R                  nU R
                  nU R                  nU R                  U5      nUcR  [        UR                  5      U R                  :X  a/  [        U5      [        U5      :X  a  UR                  5       nXxl        OUS:X  a  SnUR                  XqX#S9nU R                  U5      $ )aJ  
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.

zaxis must be 0zvUpsampling from level= or on= selection is not supported, use .set_index(...) to explicitly set index to datetime-likeNr  )r   r   r   )rV   AssertionErrorr   r   rR   r   rP   r  r   r  rU   r   rD  r   rF  r   )	rl   r   r   r   rR   rS   rP   	res_indexr   s	            rn   r    DatetimeIndexResampler._upsample	  s      99 !122;  WW  44V<	 M"**+tyy8CC	N*XXZF$L![[ ! F   ((rq   c                  > [         TU ]  U5      nU R                  S:X  a  [        UR                  [
        5      (       d  [        UR                  [        5      (       a  [        UR                  R                  S   [
        5      (       dQ  UR                  R                  S   R                  U R                  5      nUR                  R                  USS9Ul        U$ UR                  R                  U R                  5      Ul        U$ )Nr  r  )r   )r   r   rZ   r   r   r3   r/   levels	to_periodrU   
set_levels)rl   r   	new_levelr   s      rn   r   #DatetimeIndexResampler._wrap_result8  s    %f- 99 FLL+)N)N&,,
33!&,,"5"5b"9;GG & 3 3B 7 A A$)) LI#)<<#:#:9B#:#OFL   &||55dii@rq   r   rb  rc  )r}   ri  rj  rk  rm  ro  r   r   r   r  r   r   rs  rt  ru  s   @rn   r  r    s;    - -9,)\
-)^ rq   r  c                  (    \ rS rSrSr\S 5       rSrg)r  iJ  z1
Provides a resample of a groupby implementation
c                    [         $ r   )r  r   s    rn   r  ,DatetimeIndexResamplerGroupby._resampler_clsQ  s    %%rq   r   Nr}   ri  rj  rk  rl  ro  r  rs  r   rq   rn   r  r  J  s     & &rq   r  c                  t   ^  \ rS rSr% S\S'   \S 5       rU 4S jrS
U 4S jjrU 4S jr	SSU 4S jjjr
S	rU =r$ )PeriodIndexResampleriV  r3   rR   c                R    [         R                  " S[        [        5       S9  [        $ )NzgResampling a groupby with a PeriodIndex is deprecated. Cast to DatetimeIndex before resampling instead.r   )r   r   r   r   PeriodIndexResamplerGroupbyr   s    rn   r   ,PeriodIndexResampler._resampler_for_grouping[  s$    ?')		
 +*rq   c                   > U R                   S:X  a  [        TU ]	  5       $ U R                  R	                  U R
                  5      $ )N	timestamp)rZ   r   r   rO   _get_period_binsrR   )rl   r   s    rn   r   )PeriodIndexResampler._get_binner_for_timee  s8    99#7/11  11$''::rq   c                   > [         TU ]  U5      nU R                  (       a  Sn[        U5      eU R                  S:X  a  UR                  U R                  S9nU$ )NzResampling from level= or on= selection with a PeriodIndex is not currently supported, use .set_index(...) to explicitly set indexr  r   )r   rg   r   NotImplementedErrorrZ   to_timestamprY   )rl   rS   msgr   s      rn   rg   !PeriodIndexResampler._convert_objj  s\    g"3'> 
 &c** 99#""t"7C
rq   c                j  > U R                   S:X  a  [        TU ]  " U40 UD6$ Un[        R                  " U5      =(       d    UnX1:w  a  [        XU5        U R                  n[        UR                  U R                  5      (       a  U R                  " U40 UD6$ [        UR                  U R                  5      (       a'  US:X  a  U R                  U5      $ U R                  5       $ UR                  U R                  :X  a  U R                  5       $ [        SUR                   SU R                   S35      e)r  r  r>  z
Frequency z cannot be resampled to z&, as they are not sub or super periods)rZ   r   r   r  r  r!   rR   r7   rU   r   r8   r  r   )rl   r   r   r  rR   r   s        rn   r    PeriodIndexResampler._downsample|  s    99#7&s5f55!!#&-#?"437WW++..s=f==BGGTYY//f} 22377;;= WW		!;;= #	!9$)) E3 3
 	
rq   c                N  > U R                   S:X  a  [        T
U ]	  XUS9$ U R                  nU R                  nU R
                  nUR                  U R                  U R                  S9nUS:X  a  SnUR                  XaUS9n[        UUUU R                  S9n	U R                  U	5      $ )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  N)r   r   rC  )rZ   r   r   rR   rS   rP   r  rU   rY   get_indexer_take_new_indexrV   r   )rl   r   r   r   rR   rS   	new_indexmembr   new_objr   s             rn   r   PeriodIndexResampler._upsample  s    " 99#7$VZ$PPWWhhKK	 yyy8 XF""95"I!	
   ))rq   r   ra  rb  rc  )r}   ri  rj  rk  rm  ro  r   r   rg   r   r   rs  rt  ru  s   @rn   r  r  V  s6     	O+ +;
$%
N%* %*rq   r  c                  (    \ rS rSrSr\S 5       rSrg)r  i  2
Provides a resample of a groupby implementation.
c                    [         $ r   )r  r   s    rn   r  *PeriodIndexResamplerGroupby._resampler_cls  s    ##rq   r   Nr  r   rq   rn   r  r    s     $ $rq   r  c                  <    \ rS rSr% S\S'   \S 5       rS rS rSr	g)	TimedeltaIndexResampleri  r5   rR   c                    [         $ r   )TimedeltaIndexResamplerGroupbyr   s    rn   r   /TimedeltaIndexResampler._resampler_for_grouping  s    --rq   c                L    U R                   R                  U R                  5      $ r   )rO   _get_time_delta_binsrR   r   s    rn   r   ,TimedeltaIndexResampler._get_binner_for_time  s      55dgg>>rq   c                    U$ )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
r   r  s     rn   r  3TimedeltaIndexResampler._adjust_binner_for_upsample  s	     rq   r   N)
r}   ri  rj  rk  rm  ro  r   r   r  rs  r   rq   rn   r  r    s&     	. .?rq   r  c                  (    \ rS rSrSr\S 5       rSrg)r  i  r  c                    [         $ r   )r  r   s    rn   r  -TimedeltaIndexResamplerGroupby._resampler_cls  s    &&rq   r   Nr  r   rq   rn   r  r    s     ' 'rq   r  c                8    [        U 40 UD6nUR                  XS9$ )z0
Create a TimeGrouper and return our resampler.
rZ   )rN   _get_resampler)rS   rZ   kwdstgs       rn   get_resamplerr    s'     
S	!D	!BS,,rq   c                    [        SXS.UD6n	U	R                  U R                  US9n
U
R                  XU	R                  S9$ )z9
Return our appropriate resampler when grouping as well.
)rU   rj   r  )r   r_   rj   r   )rN   r  rS   r   rj   )r   ruler   fill_methodr   rZ   onr_   r   r  	resamplers              rn   get_resampler_for_groupingr    sP     
	1$	1&	1B!!'++D!9I00BFF 1  rq   c                  B  ^  \ rS rSr% Sr\R                  S-   rS\S'                 S                           SU 4S jjjrSSS jjr	 S     SS	 jjr
SS
 jr      SS jrSS jrSS jrSS jr SSS.       SU 4S jjjjrSrU =r$ )rN   i  aD  
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
)rW   rX   r   rZ   rY   r[   r\   rD   r[   Nc                  > US;  a  [        SU S35      eUS;  a  [        SU S35      eUS;  a  [        SU S35      eUc"  Ub  [        UR                  [        5      (       d  Ub!  Ub  [	        X   SS 5      S:X  a  [        US	S
9nO[        U5      n1 SknUR                  nUU;   d  SU;   a#  US UR                  S5       U;   a  Uc  SnUc  SnOUS;   a  Uc  SnUc  SnO
Uc  SnUc  SnX@l        XPl	        Xl
        Ub  UOSU l        X`l        Xl        Xl        Xl        S U l        US;   a  Xl        O [%        U5      U l         Ub  [)        U5      OS U l        S	US'   [,        TU ]\  " SX#US.UD6  g ! [         [&        4 a  n[        SU S35      UeS nAff = f! [         [&        4 a  n[        SU S35      UeS nAff = f)N>   Nleftr  zUnsupported value z for `label`z for `closed`>   Nesendstartz for `convention`rS  r  T)	is_period>   WMEQEYEBMEBQEBYE-r  r  end_dayr  r  )epochr  	start_dayr  r  z|'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 'ra   )rU   rj   rV   r   )r   r   r   r3   ru   r   	rule_codefindrW   rX   rZ   rY   r   r  r   r]   r   r[   r   	TypeErrorr   r\   r   ro   )rl   rS   rU   rj   rW   rX   r   rV   r  r   rZ   rY   r[   r\   r]   r   	end_typesr  r   r   s                      rn   ro   TimeGrouper.__init__7  s7   * //1%EFF001&GHH==1*=NOPP K399k22OCHgt4@ TT2DT?D@	~~96F		#1G91T~ } ++>$F=#E>#F="E
	(2(>*C&
$/3FF !K'/	/5/A)F+tDK vAd$A&A% 	*  DDJ8:W 	 I& 	xz+ 	s0   :E9 F! 9F	FF!G1GGc           	     t   U R                  USS9u  p4n[        U[        5      (       a"  [        UU UU R                  U R
                  US9$ [        U[        5      (       d  US:X  a|  [        U[        5      (       a#  [        R                  " S[        [        5       S9  O"[        R                  " S[        [        5       S9  [        UU UU R                  U R
                  US9$ [        U[        5      (       a!  [        UU U R                  U R
                  US9$ [        S	[        U5      R                    S
35      e)z
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rb   )rm   rZ   rV   r]   rb   r  zcResampling with a PeriodIndex is deprecated. Cast index to DatetimeIndex before resampling instead.r   zIResampling with kind='period' is deprecated.  Use datetime paths instead.)rm   rV   r]   rb   zVOnly valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of '')rf   r   r1   r  rV   r]   r3   r   r   r   r   r  r5   r  r  r|   r}   )rl   rS   rZ   _rR   s        rn   r  TimeGrouper._get_resampler  s2   & $$SD$9qb-(() YY??  K((DH,<"k**M!/1	 2!/1	 ( YY??  N++* YY??  ''+Bx'8'8&9<
 	
rq   c                p    U R                  U5      nUR                  [        [        UR                  5      4$ r   )r  rM   r   r   rS   )rl   rS   validaters       rn   _get_grouperTimeGrouper._get_grouper  s.     $zz4!%%000rq   c                   [        U[        5      (       d!  [        S[        U5      R                   35      e[        U5      S:X  a0  [        / U R                  UR                  UR                  S9=p#U/ U4$ [        UR                  5       UR                  5       U R                  UR                  U R                  U R                  U R                  S9u  pE[!        U R                  UUUR"                  UR                  SSUR                  S9=p#UR$                  nU R'                  X&5      u  p'[(        R*                  " XgU R                  UR,                  S9nU R                  S	:X  a  UnU R.                  S	:X  a  US
S  nOU R.                  S	:X  a  US
S  nUR,                  (       a,  UR1                  S[2        5      nUR1                  S[2        5      n[        U5      [        U5      :  a  US [        U5       nX(U4$ )N5axis must be a DatetimeIndex, but got an instance of r   datarU   r   rS  unitrW   r[   r\   Tshift_forward)rU   r  r  tzr   	ambiguousnonexistentr  )hasnansr  r   )r   r1   r  r|   r}   r   rU   r   rS  _get_timestamp_range_edgesr  r  r  rW   r[   r\   r2   r  asi8_adjust_bin_edgesr   generate_bins_dt64r  rX   insertr   )	rl   rR   rP   labelsr!  r'  	ax_values	bin_edgesr   s	            rn   r  TimeGrouper._get_time_bins  s   "m,,""&r("3"3!46 
 r7a<+diibggRXX F 2v%%0FFHFFHII;;;;;;
  %uu'	
 		
 GG	 226E %%$++rzz
 ;;'!FzzW$ZZ7"ABZF::]]1c*F]]1c*F
 t9s6{"Kc$i(FV##rq   c                V   U R                   R                  S;   d,  U R                   R                  R                  S5      S   S;   a  U R                  S:X  a  UR	                  S 5      nU[        SUR                  S9R                  UR                  5      -   [        SUR                  S9R                  UR                  5      -
  nUR	                  UR                  5      R                  nOUR                  nUS	   UR                  5       :  a
  US S
 nUS S
 nX4$ UR                  nX4$ )N)r  r  r  r  r   )r  r  r  r  r  r  r   )daysr  r  r  )rU   r   splitrW   tz_localizer   r  as_unitr  r  r  )rl   rP   r  	edges_dtir  s        rn   r  TimeGrouper._adjust_bin_edges0	  s   
 99>>//499>>3G3G3LQ3O T
 4
 {{g%"..t4	QY^^<DDY^^TU	7??	OP 
 &11&))<AA	"KK	 }y}}.%crN	    I  rq   c                   [        U[        5      (       d!  [        S[        U5      R                   35      e[        U R
                  [        5      (       d  [        SU R
                   35      e[        U5      (       d%  [        / U R
                  UR                  S9=p#U/ U4$ UR                  5       UR                  5       pTU R                  S:X  a  XPR
                  -  n[        XEU R
                  UR                  S9=p2UnU R                  S:X  a  X`R
                  -  nUR                  X`R                  S9nU R                  (       a  X0R                  -  nX'U4$ )Nz6axis must be a TimedeltaIndex, but got an instance of zWResampling on a TimedeltaIndex requires fixed-duration `freq`, e.g. '24h' or '3D', not r	  rU   r   r  r  r  rU   r   r  side)r   r5   r  r|   r}   rU   r:   r   r   r   r  r  rW   r6   searchsortedr\   )rl   rR   rP   r  r  r  
end_stampsr   s           rn   r   TimeGrouper._get_time_delta_binsT	  s4   "n--""&r("3"3!46 
 $))T**++/99+7 
 2ww,"499277SSF2v%%VVXrvvxs;;'!99C)tyyrww
 	
 
;;& ))#Jz<;;kk!FV##rq   c                   [        U[        5      (       d!  [        S[        U5      R                   35      eU R
                  n[        U5      S:X  a%  [        / X!R                  UR                  S9=p4U/ U4$ [        US   US   X!R                  S9=pCXB-   R                  US5      R                  5       nUR                  (       a  UR                  UR                  5      nUR                  USS9nX6U4$ )	Nr  r   r  r  r%  r  r  r&  )r   r1   r  r|   r}   rU   r   r3   r   rS  r4   r  r  r  r  r(  )rl   rR   rU   rP   r  r)  r   s          rn   r  !TimeGrouper._get_time_period_bins{	  s    "m,,""&r("3"3!46 
 yyr7a<)d F 2v%%&RU2TPWPWXXm++D#6CCE
55#//6Jz7V##rq   c           	        [        U[        5      (       d!  [        S[        U5      R                   35      eUR                  U R                  U R                  S9nSnUR                  (       a/  [        R                  " UR                  5      nX"R                  )    n[        U5      (       do  [        R                  " / [        R                  S9n[        / U R                  UR                  S9=pV[        U5      S:  a  [!        XTU[        U5      5      u  pTnXTU4$ U R                  R"                  nUR%                  5       R                  U R                  U R                  S9nUR'                  5       R                  U R                  SS9n	Sn
[        U R                  [(        5      (       at  [+        UU	U R                  U R,                  U R.                  U R0                  S9u  p[3        XR                  5      [3        XR                  5      -
  nUR"                  U-  n
Un[5        XU R                  UR                  S9=peUR6                  n[        U5      U-  nXS	   US   -
  -
  n[        R8                  " US   US	   U-   U5      nUU-  nUU
-  n[        UR:                  5      " UUR<                  S9nUR?                  US
S9nUS:  a  [!        XTXc5      u  pTnXTU4$ )Nz3axis must be a PeriodIndex, but got an instance of r  r   )rS  r$  r  )rW   r[   r\   r%  r  r  r&  ) r   r3   r  r|   r}   r  rU   rY   r  npr  _isnanr   arrayrQ  r   _insert_nat_binnr  r  r:   _get_period_range_edgesrW   r[   r\   r   r4   r  arange_datarS  r(  )rl   rR   r  	nat_countr   rP   r  	freq_multr  r  	bin_shiftp_startstart_offseti8expected_bins_count	i8_extendrngprngs                     rn   r  TimeGrouper._get_period_bins	  sz   "k**""&r("3"3!46 
 yyy8 	<< t{{+I%D4yy88Bbhh/D)r		PPF2w{'6vVSQSW'U$f''IIKK			t?ffhoodiiUo3	dii&&
 3		{{{{{{LG "%3fWii6PPL$2IE&tyyrww
 	
 YY "&kI5'b6BqE>:	ii1r"v	19=yy DJJ4::6  F 3q=#26#S F&V##rq   r  c               $  > [         TU ]  XUS9u  pn[        UR                  [        5      (       a\  UR                  R
                  S;   aB  UR                  U l        [        [        [        UR                  5      R                  5       5      nXU4$ )Nr  Mm)r   rf   r   rS  r   rZ   r   r0   r   r"   r0  _maybe_convert_datelike_array)rl   rS   ra   rb   rR   r   r   s         rn   rf   TimeGrouper._set_grouper	  sy     !7/Y/Obhh
++0E "D("((3QQSB rq   )r   rW   rY   r  r]   r   rZ   rX   r   r\   r[   )NMinNNNr/  r   NNNNr  NF)rS   zGrouper | NonerU   r?   rj   
str | NonerW   Literal['left', 'right'] | NonerX   rG  r   r   rV   r=   r   rd  rZ   rF  rY   z(Literal['start', 'end', 'e', 's'] | Noner[   zTLiteral['epoch', 'start', 'start_day', 'end', 'end_day'] | TimestampConvertibleTypesr\   z TimedeltaConvertibleTypes | Noner]   r^  r_  r`  r   )rS   r%   r_  rK   rf  )rS   r   r  r^  r_  ztuple[BinGrouper, NDFrameT])rR   r1   )rP   r1   r  znpt.NDArray[np.int64]r_  z+tuple[DatetimeIndex, npt.NDArray[np.int64]])rR   r5   )rR   r3   rh  )rS   r   ra   r^  rb   zIndex | Noner_  z3tuple[NDFrameT, Index, npt.NDArray[np.intp] | None])r}   ri  rj  rk  rl  r-   r{   rm  ro   r  r  r  r  r  r  r  rf   rs  rt  ru  s   @rn   rN   rN     s   
 %% ) K  #2615 ?C&137 !iBiB iB 	iB
 0iB /iB iB iB iB iB =iB$iB 1iB  !iB$ 
%iB iBVB
J /311'+1	$1A$F"!#"!0E"!	4"!H%$N$0I$X +0	 NR	 	 #'	 ?K	 	<	  	 rq   rN   c                j   [        U [        5      (       a;  [        R                  " U R                  U5      nU R                  XBU R                  S9$ [        U [        5      (       aD  US:X  a  [        S5      eU R                  R                  X!SS9nU R                  XUR                  S9$ [        S5      e)N)r   r   r   zaxis 1 is not supported)new_axisr   rV   )axesz.'obj' should be either a Series or a DataFrame)r   r   algostake_nd_values_constructorr   r   r  _mgrreindex_indexer_constructor_from_mgrrJ  r   )rS   r   r  rV   
new_valuesnew_mgrs         rn   r  r  	  s     #y!!]]3;;8
chh   
 	
 
C	&	&19%&?@@((**IUV*W((||(DDIJJrq   c           
        [        U[        5      (       a  U R                  n[        U[        5      (       a  UR                  SL USL :w  a  [	        S5      eUS:X  a
  [        SUS9n[        U[
        5      (       aH  U R                  S5      n UR                  S5      n[        U[        5      (       a  UR                  S5      n[        XX$XVUS9u  p[        U[
        5      (       a"  U R                  U5      n UR                  U5      nX4$ U R                  5       n UR                  5       nUS:X  a  [        UR                  U 5      5      n O[        X-
  5      n [        X-   5      nX4$ )a  
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.r  z
1970-01-01)r  )rW   r[   r\   r  r  )
r   r:   r  r   r   r9   r  _adjust_dates_anchored	normalizerollback)r!  r'  rU   r  rW   r[   r\   index_tzs           rn   r  r  	  sP   R $88fi((fii4.?XQUEU-VSTTW |9FdC   %%d+E##D)D&),,++D1,VQU
 dC  %%h/E##H-D ; !~~VdmmE23Eel+E%;rq   c           
     z   [        S X4 5       5      (       d  [        S5      eU R                  5       nUR                  5       nUR                  U5      (       + nUR                  U5      n	[	        XgUSX4US9u  pgU[        U5      U-  -   R                  U5      n U[        U	5      U-  -
  R                  U5      nX4$ )a  
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.
c              3  B   #    U  H  n[        U[        5      v   M     g 7fr   )r   r   )rv   rS   s     rn   rx   *_get_period_range_edges.<locals>.<genexpr>r
  s     @-3z#v&&-s   z3'first' and 'last' must be instances of type Periodnsr
  )allr  r  is_on_offsetr  re  r  )
r!  r'  rU   rW   r[   r\   first_tslast_tsadjust_firstadjust_lasts
             rn   r3  r3  L
  s    L @5-@@@MNN !!#H!G((22L##G,K24d6QWH L)D00;;DAEc+&--88>D;rq   c                    US:  d   eX-  n[         R                  " USU5      nU R                  S[        5      n UR                  S[        5      nXU4$ )Nr   )r.  r  r   )rP   r   r  r6  s       rn   r1  r1  
  sY    
 q==D99T1i(D ]]1c"F ]]1c"Frq   c                   U R                  U5      n UR                  U5      nUb  UR                  U5      n[        U5      R                  U5      R                  nSnUS:X  a  U R                  5       R                  nOUS:X  a  U R                  nO[	        U[
        5      (       a  UR                  U5      R                  nOYUS;   aS  US:X  a  UOUR                  S5      n	U	R                  U R                  -
  U-  n
US:X  a  U
S-  n
XU-  -
  n U R                  nX(       a  UR                  OS-  nU R                  nUR                  nUb  U R                  S	5      n Ub  UR                  S	5      nU R                  U-
  U-  nUR                  U-
  U-  nUS
:X  aJ  US:  a  U R                  U-
  nOU R                  U-
  nUS:  a  UR                  X~-
  -   nOVUR                  nOIUS:  a  U R                  U-
  nOU R                  nUS:  a  UR                  X~-
  -   nOUR                  U-   n[        XS9n[        UUS9nUb   UR                  S	5      R                  U5      nUb   UR                  S	5      R                  U5      nUU4$ )Nr   r  r  r  r  Dr  r   UTCr  r  )
r   r   _valuerV  r   r   ceiltzinfo
tz_convertr  )r!  r'  rU   rW   r[   r\   r  
freq_valueorigin_timestamporigin_lastsub_freq_timesfirst_tzinfolast_tzinfofoffsetloffsetfresult_intlresult_intfresultlresults                      rn   rU  rU  
  ss    MM$E<<D%4((.55J ??,33	7	 <<	FI	&	&!>>$/66	%	%$od499S>%,,u||;
JVaNt33 <<Q6
 <<L++K  'u%||..*<G{{--;GQ;,,0K,,3KQ;++)=>K ++KQ;,,0K  ,,KQ;++)=>K++
2K/G$/G%%e,77E%%e,77DGrq   c                   [        U R                  [        5      (       a  Ub  [        S5      eUc  Sn[        U[        5      (       aK  [        US5      (       a!  [        UR                  UR                  5      nO[        SUR                   S35      eU R                  5       nU R                  R                  XS9Ul        U$ [        U R                  5      S:X  a-  U R                  5       n[        U R                  U5      Ul        U$ Sn[        U R                  [        5      (       a  U R                  R                   n[#        U R                  R%                  5       U R                  R'                  5       XS	9nU R                  R                  Ul        U R)                  XUS
9nU(       a  UR                  R+                  5       Ul        U$ )zv
Utility frequency conversion method for Series/DataFrame.

See :meth:`pandas.NDFrame.asfreq` for full documentation.
Nz"'method' argument is not supportedE_period_dtype_codezInvalid offset: 'z.' for converting time series with PeriodIndex.r  r   )rU   r  )r   r   )r   r   r3   r  r   hasattrr   r2  r   r   baserD  r  r   r   r1   r  r2   r  r  rF  rV  )	rS   rU   r   r   rV  r   r  r  dtis	            rn   r  r  
  si    #))[))%&JKK;CdJ''t122-dffdii@ '		{ 3( ) 
 ((*		(((7" N 
SYY1	((*&syy$7 N cii//99>>D#))--/P99>>++cZ+H#MM335GMNrq   c                   [        U 5      S:w  a  [        S5      e[        U [        5      (       a  U R	                  US9nU$ [        U [
        5      (       a!  [        / U R                  XR                  S9nU$ [        U [        5      (       a!  [        / U R                  XR                  S9nU$ [        [        U 5      5      e)z
Helper to mimic asfreq on (empty) DatetimeIndex and TimedeltaIndex.

Parameters
----------
index : PeriodIndex, DatetimeIndex, or TimedeltaIndex
freq : DateOffset

Returns
-------
same type as index
r   zECan only set arbitrary freq for empty DatetimeIndex or TimedeltaIndexr   )rS  rU   r   )r   r   r   r3   r  r1   rS  r   r5   r  r|   )r   rU   r  s      rn   r   r     s     5zQS
 	
 %%%LLdL+	  
E=	)	)!"EKKdT	
 	 
E>	*	*"2U[[t**U	  U$$rq   c           	         USL=(       a    [        U5      S:  nUSL=(       a    [        U5      S:  nU(       a
  U(       a  SnOU(       a  SnOU(       a  SnOg[        R                  " SU SU R                   SU S	3[        [        5       S
9  g)ak  
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.
Nr   zargs and kwargsr   r   zPassing additional z to .zj has no impact on the result and is deprecated. This will raise a TypeError in a future version of pandas.)categoryr   )r   r   r   r}   r   r   )clskernelr   r   	warn_argswarn_kwargsr  s          rn   r  r  :  s     D 2SY]I$8VqK[		MM
cU$s||nAfX >; 	; #%rq   c                   Sn[         R                  " SS5      n[        U[        US9   U R                  " U/UQ7SU0UD6nS S S 5        U$ ! , (       d  f       W$ = f)Nz7DataFrameGroupBy.apply operated on the grouping columnsDataFrameGroupByresample)target_messagetarget_categorynew_messager_   )r*   formatr   DeprecationWarningrr  )r   r   r_   r   r   r  r  r   s           rn   r   r   \  sk     ON'../A:NK	%*

 sSTS.SFS
 M
 
 Ms   A
Ar   )rS   zSeries | DataFramer_  rK   )NNNNNT)r   r)   r   rd  r_   r^  r_  rK   )r   )
rS   r   r   znpt.NDArray[np.intp]r  r0   rV   r>   r_  r   )r  r  N)r!  r   r'  r   rU   r   r  r   rW   Literal['right', 'left']r[   rD   r\   Timedelta | Noner_  tuple[Timestamp, Timestamp])r!  r   r'  r   rU   r   rW   r  r[   rD   r\   r  r_  ztuple[Period, Period])
rP   r3   r   z
np.ndarrayr  r3   r6  re  r_  z+tuple[PeriodIndex, np.ndarray, PeriodIndex])r  r  Nr\  )r!  r   r'  r   rU   r:   rW   r  r[   rD   r\   r  r  r   r_  r  )NNFN)rS   r   rV  r^  r_  r   )r   z,DatetimeIndex | PeriodIndex | TimedeltaIndex)r  r   r_  r`  )r   r)   r   r   r_   r^  r_  rG   )
__future__r   rD  textwrapr   typingr   r   r   r   r	   r
   r   numpyr.  pandas._libsr   pandas._libs.tslibsr   r   r   r   r   r   r   pandas._libs.tslibs.dtypesr   pandas._typingr   pandas.compat.numpyr   r  pandas.errorsr   pandas.util._decoratorsr   r   r   pandas.util._exceptionsr   r   pandas.core.dtypes.dtypesr   pandas.core.dtypes.genericr   r   pandas.core.algorithmscore
algorithmsrK  pandas.core.applyr    r!   pandas.core.arraysr"   pandas.core.baser#   r$   pandas.core.commoncommonr  pandas.core.genericr%   r&   pandas.core.groupby.genericr'   pandas.core.groupby.groupbyr(   r)   r*   r+   r,   pandas.core.groupby.grouperr-   pandas.core.groupby.opsr.   pandas.core.indexes.apir/   pandas.core.indexes.baser0   pandas.core.indexes.datetimesr1   r2   pandas.core.indexes.periodr3   r4   pandas.core.indexes.timedeltasr5   r6   pandas.tseries.frequenciesr7   r8   pandas.tseries.offsetsr9   r:   collections.abcr;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rU  rG   rH   rI   rm  rK   rw  r  r  r  r  r  r  r  rl  r  rN   r  r  r3  r1  rU  r  r   r  r   r   rq   rn   <module>r     s   "         > # . - 

 1
 ' & 3 !   6  0 . . *

 (   
 ') ^ (^;\ ^;B/eL. ePCY CP	&)	&r*1 r*n	$'	$4 0	'*	'- "))  		
   ,I ' I Z UVK	K0K=BKJQKK0 (. +#LL
L L 	L
 %L L L !Lf (. +#55
5 5 %	5
 5 5 5p  ) 3> KN 0 , (/ +#QQ
Q Q %	Q
 Q Q Q !Qn /	/
 / /d<D#<@rq   