
    A>i7                      % S SK Jr  S SKrS SKJrJr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Jr  S SKJr  S S	K J!r!  S S
K"J#r#J$r$  S SK%J&r&J'r'  S SK(J)s  J*r+  S SK,J-r-  S SK.J/r/  S SK0J1r1J2r2  S SK3J4r4  S SK5J6r6J7r7J8r8  S SK9J:r:  S SK;J<r<  S SK=J>r>  S SK?J@r@  S SKAJBrBJCrC  S SKDJErEJFrF  S SKGJHrHJIrI  S SKJJKrK  S SKLJMrMJNrN  S SKOJPrPJQrQ  \(       a6  S SKRJSrSJTrT  S SKJUrUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`JaraJbrb  S SKcJdrdJere  S SK3J4r4  0 rfS\gS'   \" S 5       " S! S"\6\15      5       rh " S# S$\1\25      ri " S% S&\h5      rj\" S 5       " S' S(\i\j5      5       rk " S) S*\j5      rl\" S 5       " S+ S,\i\l5      5       rm " S- S.\j5      rn\" S 5       " S/ S0\i\n5      5       roS>S1 jrp\hR                  \plq            S?     S@S2 jjrr\" S 5       " S3 S4\:5      5       rs\        SAS5 j5       rt\        SBS6 j5       rt        SCS7 jrt   SD               SES8 jjru   SD             SFS9 jjrv          SGS: jrw    SH               SIS; jjrx    SJ     SKS< jjrySLS= jrzg)M    )annotationsN)TYPE_CHECKINGConcatenateLiteralSelfcastfinalno_type_checkoverload)lib)
BaseOffsetIncompatibleFrequencyNaTPeriod	Timedelta	Timestamp	to_offset)NDFrameT)AbstractMethodErrorPandas4Warning)
set_module)find_stack_level)
ArrowDtypePeriodDtype)ABCDataFrame	ABCSeries)ResamplerWindowApply)ArrowExtensionArray)PandasObjectSelectionMixin)NDFrame)BaseGroupByGroupByget_groupby)Grouper)
BinGrouper)
MultiIndex)Index)DatetimeIndex
date_range)PeriodIndexperiod_range)TimedeltaIndextimedelta_range)concat)is_subperiodis_superperiod)DayTick)CallableHashable)AnyAnyArrayLikeAxis
FreqIndexT	Frequency
IndexLabelInterpolateOptionsPTTimedeltaConvertibleTypesTimeGrouperOriginTimestampConvertibleTypesTimeUnitnpt)	DataFrameSerieszdict[str, str]_shared_docs_kwargszpandas.api.typingc                  F  ^  \ 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
SSSS.           S;S jjr\S<S j5       r\S=S j5       r\\S>S j5       5       rS?S jrS r\S 5       r\        S@S j5       r\        SAS j5       r\        SBU 4S jj5       r\SCS j5       r\r\r\S 5       rS rSDSES jjrSCSFS jjrS r\  SGS  j5       rS! r\SCSES" jj5       r \SCSES# jj5       r!\SCSES$ jj5       r"\ SHS%SS&SS'.       SIS( jjj5       r#\SCS) j5       r$\  SJ   SKS* jj5       r%\  SJ   SKS+ jj5       r&\  SJ   SKS, jj5       r'\  SJ   SKS- jj5       r(\   SL     SMS. jj5       r)\   SL     SMS/ jj5       r*\SNSOS0 jj5       r+\ SN SOS1 jj5       r,\  SP   SQS2 jj5       r-\  SP   SQS3 jj5       r.\  SP   SQS4 jj5       r/\S5 5       r0\S6 5       r1\S7 5       r2\S8 5       r3\SRSSS9 jj5       r4S:r5U =r6$ )T	Resamplerw   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

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closedlabel
conventionoriginoffsetFN)
group_keys	selectioninclude_groupsc                  U(       a  [        S5      eX l        S U l        SU l        X@l        SU l        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 )Nz)include_groups=True is no longer allowed.T)sort	gpr_index)
ValueErrorrL   keysr\   rX   as_index_set_grouper_convert_objrP   rO   rQ   _get_binnerrM   rJ   
_selectionkey	frozensetrN   )selfrP   timegrouperr]   rX   rY   rZ   s          S/var/www/html/land-tabula/venv/lib/python3.13/site-packages/pandas/core/resample.py__init__Resampler.__init__   s     HII'		$+/+<+<+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=)getattrrL   ).0krg   s     ri   	<genexpr>$Resampler.__str__.<locals>.<genexpr>   sE      
%t((!T2 3qc74,,a012%s
   A"Az [z, ])_attributestype__name__join)rg   attrss   ` ri   __str__Resampler.__str__   sB    

%%

 t*%%&b5)9(:!<<rl   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__rv   rp   rL   rP   )rg   attrs     ri   __getattr__Resampler.__getattr__   sa    +++**466###4,,d3388:&&t22rl   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)rL   re   levelrg   s    ri   _from_selectionResampler._from_selection   sG       , 
!!-T1B1B1H1HPT1T	
rl   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)rg   rP   s     ri   rb   Resampler._convert_obj   s     !!rl   c                    [        U 5      er~   r   r   s    ri   _get_binner_for_timeResampler._get_binner_for_time       !$''rl   c                   U R                  5       u  pn[        U5      [        U5      :X  d   eU R                  R                  b%  UR	                  U R                  R                  5      n[        X#U R                  S9nX4$ )zS
Create the BinGrouper, assume that self.set_grouper(obj)
has already been called.
)indexer)r   lenrL   _arrow_dtypeastyper&   rQ   )rg   rM   bins	binlabelsbin_groupers        ri   rc   Resampler._get_binner   st     #'";";"=i4yC	N***))5!(():):)G)GHI $--H""rl   c                    g r~    rg   funcargskwargss       ri   pipeResampler.pipe        rl   c                    g r~   r   r   s       ri   r   r     r   rl   c                ,   > [         TU ]  " U/UQ70 UD6$ )a  
Apply a ``func`` with arguments to this Resampler object and return its result.

Use `.pipe` when you want to improve readability by chaining together
functions that expect Series, DataFrames, GroupBy or Resampler objects.
Instead of writing

>>> h = lambda x, arg2, arg3: x + 1 - arg2 * arg3
>>> g = lambda x, arg1: x * 5 / arg1
>>> f = lambda x: x**4
>>> df = pd.DataFrame([["a", 4], ["b", 5]], columns=["group", "value"])
>>> h(g(f(df.groupby("group")), arg1=1), arg2=2, arg3=3)  # doctest: +SKIP

You can write

>>> (
...     df.groupby("group").pipe(f).pipe(g, arg1=1).pipe(h, arg2=2, arg3=3)
... )  # doctest: +SKIP

which is much more readable.

Parameters
----------
func : callable or tuple of (callable, str)
    Function to apply to this Resampler object or, alternatively,
    a `(callable, data_keyword)` tuple where `data_keyword` is a
    string indicating the keyword of `callable` that expects the
    Resampler object.
*args : iterable, optional
    Positional arguments passed into `func`.
**kwargs : dict, optional
        A dictionary of keyword arguments passed into `func`.

Returns
-------
any
    The result of applying ``func`` to the Resampler object.

See Also
--------
Series.pipe : Apply a function with arguments to a series.
DataFrame.pipe: Apply a function with arguments to a dataframe.
apply : Apply function to each group instead of to the
    full Resampler object.

Notes
-----
See more `here
<https://pandas.pydata.org/pandas-docs/stable/user_guide/groupby.html#piping-function-calls>`_

Examples
--------
>>> 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
)superr   )rg   r   r   r   	__class__s       ri   r   r   
  s    Z w|D242622rl   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$ )aR  
Aggregate using one or more operations over the specified axis.

Parameters
----------
func : function, str, list or dict
    Function to use for aggregating the data. If a function, must either
    work when passed a DataFrame or when passed to DataFrame.apply.

    Accepted combinations are:

    - function
    - string function name
    - list of functions and/or function names, e.g. ``[np.sum, 'mean']``
    - dict of axis labels -> functions, function names or list of such.
*args
    Positional arguments to pass to `func`.
**kwargs
    Keyword arguments to pass to `func`.

Returns
-------
scalar, Series or DataFrame

    The return can be:

    * scalar : when Series.agg is called with single function
    * Series : when DataFrame.agg is called with a single function
    * DataFrame : when DataFrame.agg is called with several functions

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.

Notes
-----
The aggregation operations are always performed over an axis, either the
index (default) or the column axis. This behavior is different from
`numpy` aggregation functions (`mean`, `median`, `prod`, `sum`, `std`,
`var`), where the default is to compute the aggregation of the flattened
array, e.g., ``numpy.mean(arr_2d)`` as opposed to
``numpy.mean(arr_2d, axis=0)``.

`agg` is an alias for `aggregate`. Use the alias.

Functions that mutate the passed object can produce unexpected
behavior or errors and are not supported. See :ref:`gotchas.udf-mutation`
for more details.

A passed user-defined-function will be passed a Series for evaluation.

If ``func`` defines an index relabeling, ``axis`` must be ``0`` or ``index``.

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
)r   r   )r   agg_groupby_and_aggregate)rg   r   r   r   resulthows         ri   	aggregateResampler.aggregateY  sC    F &dtKOOQ>C00FtFvFFrl   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.
*args, **kwargs
    Additional arguments and keywords.

Returns
-------
Series
    A Series with the transformed values, maintaining the same index as
    the original object.

See Also
--------
core.resample.Resampler.apply : Apply a function along each group.
core.resample.Resampler.aggregate : Aggregate using one or more operations
    over the specified axis.

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groupbyrL   	transform)rg   argr   r   s       ri   r   Resampler.transform  sB    P !!))$*;*;<FF

 
 	
rl   c                    [        U 5      er~   r   )rg   r   r   s      ri   _downsampleResampler._downsample  r   rl   c                    [        U 5      er~   r   )rg   flimit
fill_values       ri   	_upsampleResampler._upsample  r   rl   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                  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grouperrX   )rJ   rP   ndimr$   rX   )rg   re   r   subsetr   groupeds         ri   _gotitemResampler._gotitem  sp     -->XXF {{a'''19;;!###tW
 rl   c                  ^^^ U R                   nU R                  n[        USX@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R                  " T/TQ70 TD6n N9[         a1  n	S[        U	5      ;   a  Oe UR                  " T/TQ70 TD6n Sn	A	NnS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~   r   )xr   r   r   s    ri   <lambda>2Resampler._groupby_and_aggregate.<locals>.<lambda>#  s    Q!8!8!8rl   zMust produce aggregated value)rJ   _obj_with_exclusionsr$   rX   callabler   AttributeErrorKeyErrorapplyr^   str_wrap_result)
rg   r   r   r   r   rP   r   r   r   errs
    ```      ri   r    Resampler._groupby_and_aggregate  s     -- ''cdGX	9}} 9 **40 **3@@@.   ((- ) 	9 ]]3888F 
	9.#c(:  ]]3888F
	9s#   )B B &C&,	C&5'C!!C&c                $    U R                  UUU S9$ )z7
Return the correct class for resampling with groupby.
)r   re   parent)_resampler_for_grouping)rg   r   re   s      ri   _get_resampler_for_grouping%Resampler._get_resampler_for_grouping?  s%     ++ , 
 	
rl   c                4   [        U[        5      (       a  U R                  b  U R                  Ul        [        U[        5      (       aU  UR                  (       aD  U R
                  n[        UR                  SS U R                  S9Ul        [        USS5      Ul        U R                  R                  bc  UR                  R                  U R                  R                  5      Ul        U R
                  R                  R                  UR                  l        U$ )z
Potentially wrap any results.
Nr   rR   name)
isinstancer   rd   r   emptyrP   _asfreq_compatindexrR   rp   rL   r   r   )rg   r   rP   s      ri   r   Resampler._wrap_resultN  s     fi((T__-H//FKfi((V\\((C)#))BQ-diiHFL!#vt4FK))5!<<..t/@/@/M/MNFL $ 3 3FLLrl   c                "    U R                  SUS9$ )aa  
Forward fill the values.

This method fills missing values by propagating the last valid
observation forward, up to the next valid observation. It is commonly
used in time series analysis when resampling data to a higher frequency
(upsampling) and filling gaps in the resampled output.

Parameters
----------
limit : int, optional
    Limit of how many values to fill.

Returns
-------
Series
    The resampled data with missing values filled forward.

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   rg   r   s     ri   r   Resampler.ffilla  s    Z ~~gU~33rl   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
--------
bfill : Backward fill the new missing values in the resampled data.
ffill : 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     ri   r   Resampler.nearest  s    p ~~iu~55rl   c                "    U R                  SUS9$ )as
  
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
--------
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_%28statistics%29

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     ri   r   Resampler.bfill  s    H ~~gU~33rl   r   forward)axisr   limit_direction
limit_areac          
        SU;   a\  [         R                  " S[        U 5      R                   S3[        [        5       S9  UR                  S5      nU(       a  [        S5      eU R                  S5      nU R                  n	[        U	R                  [        5      n
U
(       d}  UR                  n[        U[        5      (       a  [        S5      eU	R                  R                  U5      n[!        U5      S:  a'  [#        XR$                  U   /5      R'                  5       nUR(                  " SUUUS	UUS
.UD6nU
(       a  U$ UR$                  W   nXl        U$ )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.
limit_direction : {{'forward', 'backward', 'both'}}, Optional
    Consecutive NaNs will be filled in this direction.

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

**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.
DataFrame.bfill : Backward fill NaN values in the resampled data.
DataFrame.ffill : Forward fill NaN values.

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

Downsample 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

Upsample 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 of the reindexed timestamps
(anchors). It is assured that all available datapoints from original
series become anchors, so it also works for resampling-cases that lead
to non-aligned timestamps, as in the following example:

>>> series.resample("400ms").interpolate("linear")
2023-03-01 07:00:00.000    1.000000
2023-03-01 07:00:00.400    0.333333
2023-03-01 07:00:00.800   -0.333333
2023-03-01 07:00:01.200    0.000000
2023-03-01 07:00:01.600    1.000000
2023-03-01 07:00:02.000    2.000000
2023-03-01 07:00:02.400    1.666667
2023-03-01 07:00:02.800    1.333333
2023-03-01 07:00:03.200    1.666667
2023-03-01 07:00:03.600    2.333333
2023-03-01 07:00:04.000    3.000000
Freq: 400ms, dtype: float64

Note that the series correctly decreases between two anchors
``07:00:00`` and ``07:00:02``.
inplacezThe 'inplace' keyword in zo.interpolate is deprecated and will be removed in a future version. resample(...).interpolate is never inplace.
stacklevelz1Cannot interpolate inplace on a resampled object.asfreqa-  Direct interpolation of MultiIndex data frames is not supported. If you tried to resample and interpolate on a grouped data frame, please use:
`df.groupby(...).apply(lambda x: x.resample(...).interpolate(...))`
instead, as resampling and interpolation has to be performed for each group independently.r   F)methodr   r   r   r   r   r   )warningswarnrw   rx   r   r   popr^   r   r   r   r   r+   r'   NotImplementedError
differencer   r/   loc
sort_indexinterpolate)rg   r   r   r   r   r   r   r   r   rP   is_period_indexfinal_indexmissing_data_points_indexresult_interpolateds                 ri   r  Resampler.interpolateP  sa   ` MM+DJ,?,?+@ A> > +- jj+G !TUU)   $SYY<  ,,K+z22)>  ),		(<(<[(I%,-1WW%>?@*,  %00 
+!
 
 && 255kB %0!""rl   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   )rg   r   s     ri   r   Resampler.asfreq   s    R ~~h:~>>rl   c                "    U R                  SXS9$ )a  
Compute sum of group values.

This method provides a simple way to compute the sum of values within each
resampled group, particularly useful for aggregating time-based data into
daily, monthly, or yearly sums.

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.

See Also
--------
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
core.resample.Resampler.count : Compute count of group, excluding missing
    values.
DataFrame.resample : Resample time-series data.
Series.sum : Return the sum of the values over the requested axis.

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r   rg   r  r  s      ri   r
  Resampler.sumK  s    t LVVrl   c                "    U R                  SXS9$ )aE  
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.

See Also
--------
core.resample.Resampler.sum : Compute sum of groups, excluding missing values.
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
core.resample.Resampler.median : Compute median of groups, excluding missing
    values.

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      ri   r  Resampler.prod  s    j \WWrl   c                "    U R                  SXS9$ )a>  
Compute min value of group.

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
    Compute the minimum value in the given Series or DataFrame.

See Also
--------
core.resample.Resampler.max : Compute max value of group.
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
core.resample.Resampler.median : Compute median of groups, excluding missing
    values.

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      ri   r  Resampler.min      j LVVrl   c                "    U R                  SXS9$ )a?  
Compute max value of group.

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
    Computes the maximum value in the given Series or Dataframe.

See Also
--------
core.resample.Resampler.min : Compute min value of group.
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
core.resample.Resampler.median : Compute median of groups, excluding missing
    values.

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      ri   r  Resampler.max  r  rl   c                $    U R                  SXUS9$ )a  
Compute the first non-null entry of each column.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.
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.
skipna : bool, default True
    Exclude NA/null values. If an entire group is NA, the result will be NA.

Returns
-------
Series or DataFrame
    First values within each group.

See Also
--------
core.resample.Resampler.last : Compute the last non-null value in each group.
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.

Examples
--------
>>> s = pd.Series(
...     [1, 2, 3, 4],
...     index=pd.DatetimeIndex(
...         ["2023-01-01", "2023-01-15", "2023-02-01", "2023-02-15"]
...     ),
... )
>>> s
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    4
dtype: int64
>>> s.resample("MS").first()
2023-01-01    1
2023-02-01    3
Freq: MS, dtype: int64
firstr  r  skipnar  rg   r  r  r  s       ri   r  Resampler.first,  s$    b ,F   
 	
rl   c                $    U R                  SXUS9$ )a  
Compute the last non-null entry of each column.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.
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.
skipna : bool, default True
    Exclude NA/null values. If an entire group is NA, the result will be NA.

Returns
-------
Series or DataFrame
    Last of values within each group.

See Also
--------
core.resample.Resampler.first : Compute the first non-null value in each group.
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.

Examples
--------
>>> s = pd.Series(
...     [1, 2, 3, 4],
...     index=pd.DatetimeIndex(
...         ["2023-01-01", "2023-01-15", "2023-02-01", "2023-02-15"]
...     ),
... )
>>> s
2023-01-01    1
2023-01-15    2
2023-02-01    3
2023-02-15    4
dtype: int64
>>> s.resample("MS").last()
2023-01-01    2
2023-02-01    4
Freq: MS, dtype: int64
lastr  r  r  s       ri   r"  Resampler.lasta  s$    b 6   
 	
rl   c                "    U R                  SUS9$ )a  
Compute median of groups, excluding missing values.

For multiple groupings, the result index will be a MultiIndex

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

    .. versionchanged:: 2.0.0

        numeric_only no longer accepts ``None`` and defaults to False.

Returns
-------
Series or DataFrame
    Median of values within each group.

See Also
--------
Series.groupby : Apply a function groupby to a Series.
DataFrame.groupby : Apply a function groupby to each row or column of a
    DataFrame.

Examples
--------

>>> ser = pd.Series(
...     [1, 2, 3, 3, 4, 5],
...     index=pd.DatetimeIndex(
...         [
...             "2023-01-01",
...             "2023-01-10",
...             "2023-01-15",
...             "2023-02-01",
...             "2023-02-10",
...             "2023-02-15",
...         ]
...     ),
... )
>>> ser.resample("MS").median()
2023-01-01    2.0
2023-02-01    4.0
Freq: MS, dtype: float64
medianr  r  rg   r  s     ri   r%  Resampler.median  s    ` |DDrl   c                "    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.

See Also
--------
core.resample.Resampler.median : Compute median of groups, excluding missing
    values.
core.resample.Resampler.sum : Compute sum of groups, excluding missing values.
core.resample.Resampler.std : Compute standard deviation of groups, excluding
    missing values.
core.resample.Resampler.var : Compute variance of groups, excluding missing
    values.

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     ri   r*  Resampler.mean  s    h \BBrl   c                "    U R                  SXS9$ )aD  
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.

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

Returns
-------
DataFrame or Series
    Standard deviation of values within each group.

See Also
--------
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
core.resample.Resampler.median : Compute median of groups, excluding missing
    values.
core.resample.Resampler.var : Compute variance of groups, excluding missing
    values.

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  rg   r/  r  s      ri   r-  Resampler.std      l DLLrl   c                "    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.

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

Returns
-------
DataFrame or Series
    Variance of values within each group.

See Also
--------
core.resample.Resampler.std : Compute standard deviation of groups, excluding
    missing values.
core.resample.Resampler.mean : Compute mean of groups, excluding missing values.
core.resample.Resampler.median : Compute median of groups, excluding missing
    values.

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
varr.  r  r0  s      ri   r4  Resampler.var6  s    x DLLrl   c                "    U R                  SXS9$ )a0  
Compute standard error of the mean of groups, excluding missing values.

For multiple groupings, the result index will be a MultiIndex.

Parameters
----------
ddof : int, default 1
    Degrees of freedom.

numeric_only : bool, default False
    Include only `float`, `int` or `boolean` data.

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

Returns
-------
Series or DataFrame
    Standard error of the mean of values within each group.

See Also
--------
DataFrame.sem : Return unbiased standard error of the mean over requested axis.
Series.sem : Return unbiased standard error of the mean over requested axis.

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").sem()
2023-01-01    0.577350
2023-02-01    1.527525
Freq: MS, dtype: float64
semr.  r  r0  s      ri   r7  Resampler.semt  r2  rl   c                   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      $ )aP  
Compute open, high, low and close values of a group, excluding missing values.

Returns
-------
DataFrame
    Open, high, low and close values within each group.

See Also
--------
DataFrame.agg : Aggregate using one or more operations over the specified axis.
DataFrame.resample : Resample time-series data.
DataFrame.groupby : Group DataFrame using a mapper or by a Series of columns.

Examples
--------
>>> ser = pd.Series(
...     [1, 3, 2, 4, 3, 5],
...     index=pd.DatetimeIndex(
...         [
...             "2023-01-01",
...             "2023-01-10",
...             "2023-01-15",
...             "2023-02-01",
...             "2023-02-10",
...             "2023-02-15",
...         ]
...     ),
... )
>>> ser.resample("MS").ohlc()
            open  high  low  close
2023-01-01     1     3    1      2
2023-02-01     4     5    3      5
r   r   )openhighlowclose)r   ohlc)rO   r   r   copyr   r   rR   r   to_framereindexr'   from_productcolumnsr   )rg   rO   rP   mis       ri   r>  Resampler.ohlc  s    H WW''r7a<((*C&syy$))<CIxx1}llnkk"BkK J	  ,,[["BC kk"1k-J''rl   c                $    U R                  S5      $ )a2  
Return number of unique elements in the group.

Returns
-------
Series
    Number of unique values within each group.

See Also
--------
core.groupby.SeriesGroupBy.nunique : Method nunique for SeriesGroupBy.

Examples
--------
>>> ser = pd.Series(
...     [1, 2, 3, 3],
...     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    3
dtype: int64
>>> ser.resample("MS").nunique()
2023-01-01    2
2023-02-01    1
Freq: MS, dtype: int64
nuniquer  r   s    ri   rG  Resampler.nunique  s    B 	**rl   c                `   U R                  S5      n[        U[        5      (       a!  UR                  (       d  UR	                  5       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$ )a  
Compute group sizes.

Returns
-------
Series
    Number of rows in each group.

See Also
--------
Series.groupby : Apply a function groupby to a Series.
DataFrame.groupby : Apply a function groupby to each row
    or column of a DataFrame.

Examples
--------
>>> ser = pd.Series(
...     [1, 2, 3],
...     index=pd.DatetimeIndex(["2023-01-01", "2023-01-15", "2023-02-01"]),
... )
>>> ser
2023-01-01    1
2023-01-15    2
2023-02-01    3
dtype: int64
>>> ser.resample("MS").size()
2023-01-01    2
2023-02-01    1
Freq: MS, dtype: int64
sizer   )rE   r   Nint64r   dtyper   )r   r   r   r   stackr   rO   pandasrE   r   r   r   r   )rg   r   rE   r   s       ri   rJ  Resampler.size  s    @ !!&) fl++FLL\\^F477||%!!&&!+))..Bfll'MFrl   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$ )a  
Compute count of group, excluding missing values.

Returns
-------
Series or DataFrame
    Count of values within each group.

See Also
--------
Series.groupby : Apply a function groupby to a Series.
DataFrame.groupby : Apply a function groupby to each row
    or column of a 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").count()
2023-01-01    2
2023-02-01    2
Freq: MS, dtype: int64
countr   rK  rL  r   )rD   )r   rC  rM  )r   r   rO   r   r   rw   r   r   rO  rD   rC  )rg   r   rD   s      ri   rR  Resampler.count6  s    F !!'*477||!!&&!+d001fll'@R@R@W@W  -"fllFNN' rl   c                *    U R                   " SSU0UD6$ )a  
Return value at the given quantile.

Computes the quantile of values within each resampled group.

Parameters
----------
q : float or array-like, default 0.5 (50% quantile)
    Value between 0 <= q <= 1, the quantile(s) to compute.
**kwargs
    Additional keyword arguments to be passed to the function.

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(0.25)
2023-01-01    1.5
2023-02-01    3.5
Freq: MS, dtype: float64
q)quantiler  )rg   rU  r   s      ri   rV  Resampler.quantileh  s    p :a:6::rl   )rJ   rQ   rd   rL   r`   rO   rM   rN   rX   r_   rP   r\   )rP   r!   rh   rK   r]   r(   rX   boolrZ   rX  returnNone)rY  r   )r   r   )rY  rX  rP   r   rY  r   )r   z!Callable[Concatenate[Self, P], T]r   zP.argsr   zP.kwargsrY  r>   )r   ztuple[Callable[..., T], str]r   r6   r   r6   rY  r>   )r   z@Callable[Concatenate[Self, P], T] | tuple[Callable[..., T], str]r   r6   r   r6   rY  r>   r~   NNr   
int | None)r   int)r   r#   )linear)r   r<   r   r8   r   r^  r   z&Literal['forward', 'backward', 'both'])Fr   )r  rX  r  r_  )Fr   T)r  rX  r  r_  r  rX  F)r  rX  )r   F)r/  r_  r  rX  )g      ?)rU  z"float | list[float] | AnyArrayLike)7rx   
__module____qualname____firstlineno____doc____annotations__rf   rN   setr   rv   rj   r	   r{   r   propertyr   rb   r   rc   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-  r4  r7  r>  rG  rJ  rR  rV  __static_attributes____classcell__r   s   @ri   rH   rH   w   s=   ( 88&/kJ#178K !$** !*
 * * * 
*8 	= 	= 3 3 
  
"( 
# 
# /  	
 
  *  	
 
  L3NL3 L3 	L3
 
L3 L3\ g gR CE
)
 )
V((8))V 

 
& L4 L4\ 76 76r c4 c4J  &.M#  BKM#"M# 	M#
 M# @M# M#^ (? (?T  #9W9W 9W 9Wv  #4X4X 4X 4Xl  #4W4W 4W 4Wl  #4W4W 4W 4Wl  #	2
2
 2
 	2
 2
h  #	2
2
 2
 	2
 2
h /E /Eb  #3C3C 3Cj  "5M5M 5M 5Mn  ";M;M ;M ;Mz  "5M5M 5M 5Mn 3( 3(j  +  +D . .` / /b 7; 7;rl   rH   c                      \ rS rSr% SrS\S'   Sr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)_GroupByMixini  z!
Provide the groupby facilities.
z	list[str]rv   NIndexLabel | Nonerd   r#   _groupbyrK   rL   )re   rY   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        g r~   )r   r#   rw   rH   rv   setattrrp   rd   rM   re   ro  r?  rL   rO   rP   )rg   r   r   re   rY   r   s         ri   rj   _GroupByMixin.__init__  s     '7++:T']:+ &),,:d6l:, $$DD 56 %#mm IIf&9&9:))::rl   c                l  ^ ^^^ UUUU 4S jnT R                   R                  U5      n[        U[        5      (       ag  [	        U5      S:X  aX  [        UR
                  [        5      (       d9  UR                  [        T R                  R
                  SS T R                  S9S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)rh   r]   r   )_resampler_clsrL   rO   r   r   rp   r   )r   r   r   r   rg   s    ri   r   "_GroupByMixin._apply.<locals>.func  sa    ##A43D3DPTPWPW#XA!S!!q!}.v..771.t.v..rl   r   Nr   T)append)ro  r   r   r   r   r   r+   	set_indexr   rP   rR   r   )rg   r   r   r   r   r   s   ````  ri   _apply_GroupByMixin._apply  s    	/ 	/ $$T* v|,,Fq v||[99%%txx~~bq1		B4 & F   ((rl   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   rY   )rP   r   r   listre   rw  ro  
IndexError_infer_selectionrw   r   rH   )rg   re   r   r   r   rY   new_rss          ri   r   _GroupByMixin._gotitem  s     >XXF {{a'''	$#t$$)<AU

488$mmC(G ))#6	d	4(

   	$mmG	$s   AB9 9CC)ro  rd   rL   rO   rM   re   rP   )r   rH   r   r#   rY   rn  rY  rZ  r~   )rx   rb  rc  rd  re  rf  rd   rj   r
   ry  r   r   r   r	   r   ri  r   rl   ri   rm  rm    s     $(J!( '+  	 % 
< ) )8 IK#
$ $rl   rm  c                  h   ^  \ rS rSr% S\S'   \SS j5       rS rS rS r	SSS jjr
U 4S	 jrS
rU =r$ )DatetimeIndexResampleri  r)   rO   c                    [         $ r~   )DatetimeIndexResamplerGroupbyr   s    ri   r   .DatetimeIndexResampler._resampler_for_grouping  s    ,,rl   c                L    U R                   R                  U R                  5      $ r~   )rL   _get_time_binsrO   r   s    ri   r   +DatetimeIndexResampler._get_binner_for_time  s      //88rl   c                   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                  U R                  5      R                  " U40 UD6nU R                  U5      $ )
Downsample the cython defined function.

Parameters
----------
how : string / cython mapped function
**kwargs : kw args passed to how function
)rO   r   r   r?  r   
_with_freqrR   r   rJ   r   r   )rg   r   r   rO   rP   r   s         ri   r   "DatetimeIndexResampler._downsample  s     WW ''2ww((*C		,,TYY7CI99>>TYY.K0KK.J T]]+55cDVD  ((rl   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)rS   rg   rM   s     ri   _adjust_binner_for_upsample2DatetimeIndexResampler._adjust_binner_for_upsample9  s4     ;;'!ABZF  CR[Frl   c                   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  aO  [        U5      [        U5      :X  a7  UR                  R                  U5      (       a  UR                  5       nXxl
        OUS:X  a  SnUR                  XqX#S9nU R                  U5      $ )z
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
zvUpsampling from level= or on= selection is not supported, use .set_index(...) to explicitly set index to datetime-likeNr   )r   r   r   )r   r^   rO   r   rM   r  r   inferred_freqrR   r   r   equalsr?  rA  r   )	rg   r   r   r   rO   rP   rM   	res_indexr   s	            ri   r    DatetimeIndexResampler._upsampleE  s     ;  WW  44V<	 M"**+tyy8CC	N*		  ++XXZF$L![[ ! F   ((rl   c                2  > [         TU ]  U5      n[        U R                  [        5      (       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   rO   r+   r   r'   levels	to_periodrR   
set_levels)rg   r   	new_levelr   s      ri   r   #DatetimeIndexResampler._wrap_resultn  s    %f- dgg{++JLL+5
 5
 &,,
33!&,,"5"5b"9;GG & 3 3B 7 A A$)) LI#)<<#:#:9B#:#OFL   &||55dii@rl   r   )rY  z#type[DatetimeIndexResamplerGroupby]r\  r]  )rx   rb  rc  rd  rf  rh  r   r   r   r  r   r   ri  rj  rk  s   @ri   r  r    s:    - -9)4
')R rl   r  c                  (    \ rS rSrSr\S 5       rSrg)r  i  z1
Provides a resample of a groupby implementation
c                    [         $ r~   )r  r   s    ri   ru  ,DatetimeIndexResamplerGroupby._resampler_cls  s    %%rl   r   Nrx   rb  rc  rd  re  rh  ru  ri  r   rl   ri   r  r    s     & &rl   r  c                  b   ^  \ rS rSr% S\S'   \S 5       rS rS
U 4S jjrS r	SSS jjr
S	rU =r$ )PeriodIndexResampleri  r+   rO   c                    [         $ r~   )PeriodIndexResamplerGroupbyr   s    ri   r   ,PeriodIndexResampler._resampler_for_grouping  s    **rl   c                L    U R                   R                  U R                  5      $ r~   )rL   _get_period_binsrO   r   s    ri   r   )PeriodIndexResampler._get_binner_for_time  s      11$''::rl   c                b   > [         TU ]  U5      nU R                  (       a  Sn[        U5      eU$ )NzResampling from level= or on= selection with a PeriodIndex is not currently supported, use .set_index(...) to explicitly set index)r   rb   r   r   )rg   rP   msgr   s      ri   rb   !PeriodIndexResampler._convert_obj  s7    g"3'> 
 &c**
rl   c                   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>  z
Frequency z cannot be resampled to z&, as they are not sub or super periods)rO   r0   rR   r   r1   r   r   )rg   r   r   rO   s       ri   r    PeriodIndexResampler._downsample  s     WW++..s=f==BGGTYY//f} 22377;;= WW		!;;= #	!9$)) E3 3
 	
rl   c                    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5      n	U R                  U	5      $ )z
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.
r   r   N)r   r   )	rO   rP   rM   r   rR   rU   get_indexer_take_new_indexr   )
rg   r   r   r   rO   rP   	new_indexmembr   new_objs
             ri   r   PeriodIndexResampler._upsample  s     WWhhKK	 yyy8 XF""95"I!

   ))rl   r   r[  r\  r]  )rx   rb  rc  rd  rf  rh  r   r   rb   r   r   ri  rj  rk  s   @ri   r  r    s5     	O+ +;
>* *rl   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    ri   ru  *PeriodIndexResamplerGroupby._resampler_cls  s    ##rl   r   Nr  r   rl   ri   r  r    s     $ $rl   r  c                  <    \ rS rSr% S\S'   \S 5       rS rS rSr	g)	TimedeltaIndexResampleri  r-   rO   c                    [         $ r~   )TimedeltaIndexResamplerGroupbyr   s    ri   r   /TimedeltaIndexResampler._resampler_for_grouping  s    --rl   c                L    U R                   R                  U R                  5      $ r~   )rL   _get_time_delta_binsrO   r   s    ri   r   ,TimedeltaIndexResampler._get_binner_for_time  s      55dgg>>rl   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     ri   r  3TimedeltaIndexResampler._adjust_binner_for_upsample	  s	     rl   r   N)
rx   rb  rc  rd  rf  rh  r   r   r  ri  r   rl   ri   r  r    s&     	. .?rl   r  c                  (    \ rS rSrSr\S 5       rSrg)r  i	  r  c                    [         $ r~   )r  r   s    ri   ru  -TimedeltaIndexResamplerGroupby._resampler_cls	  s    &&rl   r   Nr  r   rl   ri   r  r  	  s     ' 'rl   r  c                <    [        U 40 UD6nUR                  U 5      $ )z0
Create a TimeGrouper and return our resampler.
)rK   _get_resampler)rP   kwdstgs      ri   get_resamplerr  	  s$     
S	!D	!BS!!rl   c                    [        SXS.UD6nUR                  U R                  5      nUR                  XR                  S9$ )z9
Return our appropriate resampler when grouping as well.
rR   re   )r   re   r   )rK   r  rP   r   re   )	r   ruler   fill_methodr   onr   r  	resamplers	            ri   get_resampler_for_groupingr  %	  sB     
	1$	1&	1B!!'++.I00ff0MMrl   c                  N  ^  \ rS rSr% Sr/ \R                  QSPSPSPSPSPSP7rS	\S'               S                       SU 4S jjjrSS 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$ )!rK   i7	  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
rS   rT   r   rU   rV   rW   r@   Nc                F  > 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[        U[        5      (       dM  Ub"  [        R                  " S[        [        5       S9  U
S:w  a"  [        R                  " S[        [        5       S9  1 SknUR                  nX;   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        U	b  U	OSU l        X`l        Xpl        Xl        Xl        S U l        U
S;   a  Xl        O [-        U
5      U l         Ub  [1        U5      OS U l        S	US'   [4        TU ]l  " SX#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`rM  periodT)	is_periodzsThe 'offset' keyword does not take effect when resampling with a 'freq' that is not Tick-like (h, m, s, ms, us, ns)r   	start_dayzsThe 'origin' keyword does not take effect when resampling with a 'freq' that is not Tick-like (h, m, s, ms, us, ns)>   WMEQEYEBMEBQEBYE-r  r  end_dayr  r  )epochr  r  r  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 'r\   r  r   )r^   r   r   r+   rp   r   r3   r   r   RuntimeWarningr   	rule_codefindrS   rT   rU   r   r  r   rX   r   rV   r   	TypeErrorr   rW   r   rj   )rg   rP   rR   re   rS   rT   r   r  r   rU   rV   rW   rX   r   	end_typesr  r   r   s                    ri   rj   TimeGrouper.__init__Q	  s~   * //1%EFF001&GHH==1*=NOPPKCO
399k0R0RO'40H<TT2DT?D$%%!P"/1	 $P"/1	 A	~~6F		#1G91T~ } ))~ }~}
(2(>*C&
$/3FF !K'/	/5/A)F+tDK v6d6v6% 	*  DDJ8:W 	 I& 	xz+ 	s0   G &G; G8#G33G8;H HH c                n   U R                  USS9u  p#n[        U[        5      (       a  [        UU U R                  US9$ [        U[
        5      (       a  [        UU U R                  US9$ [        U[        5      (       a  [        UU 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

Returns
-------
Resampler

Raises
------
TypeError if incompatible axis

Nr]   )rh   rX   r]   zVOnly valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of '')ra   r   r)   r  rX   r+   r  r-   r  r  rw   rx   )rg   rP   _rO   s       ri   r  TimeGrouper._get_resampler	  s    " $$SD$9qb-(() ??	  K((' ??	  N++* ??	  ''+Bx'8'8&9<
 	
rl   c                p    U R                  U5      nUR                  [        [        UR                  5      4$ )aF  
Parameters
----------
obj : Series or DataFrame
    Object being grouped.
validate : bool, default True
    Unused. Only for compatibility with ``Grouper._get_grouper``.
observed : bool, default True
    Unused. Only for compatibility with ``Grouper._get_grouper``.

Returns
-------
A tuple of grouper, obj (possibly sorted)
)r  rJ   r   r   rP   )rg   rP   validateobservedrs        ri   _get_grouperTimeGrouper._get_grouper	  s.    $ $zz4!%%000rl   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   datarR   r   rM  unitrS   rV   rW   Tshift_forward)rR   r  r  tzr   	ambiguousnonexistentr  )hasnansr  r   )r   r)   r  rw   rx   r   rR   r   rM  _get_timestamp_range_edgesr  r  r  rS   rV   rW   r*   r  asi8_adjust_bin_edgesr   generate_bins_dt64r  rT   insertr   )	rg   rO   rM   labelsr  r"  	ax_values	bin_edgesr   s	            ri   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##rl   c                @   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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   )daysr  r  )rR   r   splitrS   tz_localizer   as_unitr  r  r  r  )rg   rM   r  	edges_dtir  s        ri   r  TimeGrouper._adjust_bin_edgesK
  s   
 99>>//499>>3G3G3LQ3O T
 4
 {{g%"..t4	Q'//	?@	7??	OP 
 &11&))<AA	"KK	 }y}}.%crN	    I  rl   c                   [        U[        5      (       d!  [        S[        U5      R                   35      e[        U R
                  [        [        4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  rR   r   r  r  r  rR   r   r  side)r   r-   r  rw   rx   rR   r3   r2   r^   r   r   r  r  rS   r.   searchsortedrW   )rg   rO   rM   r
  r  r  
end_stampsr   s           ri   r   TimeGrouper._get_time_delta_binso
  s8   "n--""&r("3"3!46 
 $))dC[11++/99+7 
 2ww,"499277SSF2v%%VVXrvvxs;;'!99C)tyyrww
 	
 
;;& ))#Jz<;;kk!FV##rl   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   r)   r  rw   rx   rR   r   r+   r   rM  r,   r   to_timestampr  r  r  )rg   rO   rR   rM   r
  r  r   s          ri   _get_time_period_bins!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##rl   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   )rM  r  r  )rS   rV   rW   r  r  r  r  ) r   r+   r  rw   rx   r   rR   rU   r  npr
  _isnanr   arrayrK  r   _insert_nat_binnr  r  r3   _get_period_range_edgesrS   rV   rW   r   r,   r  arange_datarM  r  )rg   rO   r  	nat_countr   rM   r
  	freq_multr  r  	bin_shiftp_startstart_offseti8expected_bins_count	i8_extendrngprngs                     ri   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##rl   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   ra   r   rM  r   kindr   r(   r   r   r&  _maybe_convert_datelike_array)rg   rP   r\   r]   rO   r   r   s         ri   ra   TimeGrouper._set_grouper
  sy     !7/Y/Obhh
++0E "D("((3QQSB rl   )
r   rS   rU   r  rX   r   rT   r   rW   rV   )NMinNNNr*  NNNr  NF)rP   zGrouper | NonerR   r:   re   z
str | NonerS   Literal['left', 'right'] | NonerT   r=  r   r   r   r^  rU   z(Literal['start', 'end', 'e', 's'] | NonerV   zTLiteral['epoch', 'start', 'start_day', 'end', 'end_day'] | TimestampConvertibleTypesrW   z TimedeltaConvertibleTypes | NonerX   rX  rY  rZ  )rP   r!   rY  rH   )TT)rP   r   r  rX  r  rX  rY  ztuple[BinGrouper, NDFrameT])rO   r)   )rM   r)   r  znpt.NDArray[np.int64]rY  z+tuple[DatetimeIndex, npt.NDArray[np.int64]])rO   r-   )rO   r+   ra  )rP   r   r\   rX  r]   zIndex | NonerY  z3tuple[NDFrameT, Index, npt.NDArray[np.intp] | None])rx   rb  rc  rd  re  r%   rv   rf  rj   r  r  r  r  r  r!  r  ra   ri  rj  rk  s   @ri   rK   rK   7	  s   
			 	 		
 	 	 	K  #2615 ?C 37 !r7r7 r7 	r7
 0r7 /r7 r7 r7 =r7(r7 1r7  !r7$ 
%r7 r7h,
^ FJ11'+1>B1	$1*A$F"!#"!0E"!	4"!H%$N$0I$X +0	 NR	 	 #'	 ?K	 	<	  	 rl   rK   c                    g r~   r   rP   r   r  s      ri   r  r    s     rl   c                    g r~   r   r?  s      ri   r  r    s     rl   c                H   [        U [        5      (       a;  [        R                  " U R                  U5      nU R                  X2U R                  S9$ [        U [        5      (       a3  U R                  R                  X!SS9nU R                  XDR                  S9$ [        S5      e)N)r   r   r   )new_axisr   r   )axesz.'obj' should be either a Series or a DataFrame)r   r   algostake_nd_values_constructorr   r   _mgrreindex_indexer_constructor_from_mgrrC  r^   )rP   r   r  
new_valuesnew_mgrs        ri   r  r    s    
 #y!!]]3;;8

#((KK	C	&	&((**IUV*W((||(DDIJJrl   c           
        [        U[        5      (       ad  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 UUUUUUS9u  p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  )rS   rV   rW   r  r  )r   r3   r  r   r^   _adjust_dates_anchored	normalizerollback)r  r"  rR   r  rS   rV   rW   index_tzs           ri   r  r     s    R $88fi((fii4.?XQUEU-VSTTW |9F,
( ; !~~VdmmE23Eel+E%;rl   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   )rq   rP   s     ri   rs   *_get_period_range_edges.<locals>.<genexpr>  s     @-3z#v&&-s   z3'first' and 'last' must be instances of type Periodnsr  )allr  r   is_on_offsetr  r_  r  )
r  r"  rR   rS   rV   rW   first_tslast_tsadjust_firstadjust_lasts
             ri   r)  r)  i  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;rl   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   )rM   r   r
  r,  s       ri   r'  r'    sY    
 q==D99T1i(D ]]1c"F ]]1c"Frl   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   _valuerO  r   r   ceiltzinfo
tz_convertr  )r  r"  rR   rS   rV   rW   r  
freq_valueorigin_timestamporigin_lastsub_freq_timesfirst_tzinfolast_tzinfofoffsetloffsetfresult_intlresult_intfresultlresults                      ri   rN  rN    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rl   c                R   [        U R                  [        5      (       a~  Ub  [        S5      eUc  Sn[        U[        5      (       a&  [        US5      (       a  [        U5      R                  n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.
z"'method' argument is not supportedE_period_dtype_coder  r   rU  )rR   r  )r   r   )r   r   r+   r   r   hasattrr   _freqstrr?  r   r   r   r)   r  r*   r  r  r   rA  rO  )	rP   rR   r   r   rO  r   r  r  dtis	            ri   r   r     sA    #))[))%&JKK;CdJ''t122"4(11((*		(((7" N 
SYY1	((*&syy$7 N cii//99>>D#))--/P99>>++cZ+H#MM335GMNrl   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   )rM  rR   r   )r   r^   r   r+   r   r)   rM  r   r-   r  rw   )r   rR   r  s      ri   r   r   4  s     5zQS
 	
 %%%LLdL+	  
E=	)	)!"EKKdT	
 	 
E>	*	*"2U[[t**U	  U$$rl   )rP   zSeries | DataFramerY  rH   )NNNN)r   r#   r   r^  rY  rH   )rP   rD   r   npt.NDArray[np.intp]r  r(   rY  rD   )rP   rE   r   rw  r  r(   rY  rE   )rP   DataFrame | Seriesr   rw  r  r(   rY  rx  )r  r  N)r  r   r"  r   rR   r   r  rB   rS   Literal['right', 'left']rV   r@   rW   Timedelta | NonerY  tuple[Timestamp, Timestamp])r  r   r"  r   rR   r   rS   ry  rV   r@   rW   rz  rY  ztuple[Period, Period])
rM   r+   r   z
np.ndarrayr
  r+   r,  r_  rY  z+tuple[PeriodIndex, np.ndarray, PeriodIndex])r  r  NrU  )r  r   r"  r   rR   r3   rS   ry  rV   r@   rW   rz  r  rB   rY  r{  )NNFN)rP   r   rO  rX  rY  r   )r   r9   rY  r9   ){
__future__r   r?  typingr   r   r   r   r   r	   r
   r   r   numpyr$  pandas._libsr   pandas._libs.tslibsr   r   r   r   r   r   r   pandas._typingr   pandas.errorsr   r   pandas.util._decoratorsr   pandas.util._exceptionsr   pandas.core.dtypes.dtypesr   r   pandas.core.dtypes.genericr   r   pandas.core.algorithmscore
algorithmsrD  pandas.core.applyr   pandas.core.arraysr   pandas.core.baser   r    pandas.core.genericr!   pandas.core.groupby.groupbyr"   r#   r$   pandas.core.groupby.grouperr%   pandas.core.groupby.opsr&   pandas.core.indexes.apir'   pandas.core.indexes.baser(   pandas.core.indexes.datetimesr)   r*   pandas.core.indexes.periodr+   r,   pandas.core.indexes.timedeltasr-   r.   pandas.core.reshape.concatr/   pandas.tseries.frequenciesr0   r1   pandas.tseries.offsetsr2   r3   collections.abcr4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rO  rD   rE   rF   rf  rH   rm  r  r  r  r  r  r  r  re  r  rK   r  r  r)  r'  rN  r   r   r   rl   ri   <module>r     s+   " 	 	 	      $ / 4
 ' & 2 2 
 0 . . * .
 
   " ,&( ^ (  h;\ h; !h;V9nL. nbiY iX  	&)	& !	&T*1 T*n  	$'	$ !	$4 ,  	'*	' !	'" "))  	NN
 N N$  J ' J  !J Z 
	1>C 

 
	.;@ 

K	K!K K 	K( (. +#FF
F F 	F
 %F F F !FZ (. +#55
5 5 %	5
 5 5 5p  ) 3> KN 0 , (/ +#QQ
Q Q %	Q
 Q Q Q !Qn *	*
 * *Zrl   