
    Mh                   &   S r SSKJr  SSKJrJrJrJr  SSKrSSK	J
r
Jr  SSKrSSKJr  SSKJrJrJrJrJrJrJr  SSKrSSKrSSKJr  SS	KJrJr  SS
KJ r   SSK!J"s  J#r$  SSK%J&r&  SSK'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4  SSK5J6r7  SSK8J9r9J:r:  SSK;J<r<J=r=J>r>J?r?  SSK@JArA  SSKBJCrCJDrD  SSKEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrP  SSKQJRrRJSrSJTrT  SSKUJVrVJWrW  SSKXJYrY  SSKZJ[r[  SSK\J]r]J^r^J_r_J`r`JaraJbrbJcrc  SSKdJere  SSKfJgrgJhrh  SSKiJjrjJkrk  SSKlJms  Jnro  SSKpJqrq  SSKrJsrs  SSKtJuruJvrvJwrw  SSKxJyry  SSKzJ{r{J|r|  SS K}J~r~JrJrJrJr  SS!KJr  SS"KJr  SS#KJr  SS$KJrJr  \(       a  SS%KJr  SS&KJr  SS'KJrJrJr  S(rS)S*S+S,.rS-rS.rS/rS0rS1rS2r\ " S3 S4\j5      5       r\\\\   \\/\4   \\\/\4      \\\4   4   r " S5 S6\j\k\/   \{5      r\" S7\sS89r " S9 S:\\/   5      r\?" \5          S>           S?S; jj5       rS@S< jrS=rg)Aa  
Provide the groupby split-apply-combine paradigm. Define the GroupBy
class providing the base-class of operations.

The SeriesGroupBy and DataFrameGroupBy sub-class
(defined in pandas.core.groupby.generic)
expose these user-facing objects to provide specific functionality.
    )annotations)HashableIteratorMappingSequenceN)partialwraps)dedent)TYPE_CHECKINGCallableLiteralTypeVarUnioncastfinal)option_context)	Timestamplib)rank_1d)NA)AnyArrayLike	ArrayLikeAxisAxisIntDtypeObjFillnaOptions
IndexLabelNDFrameTPositionalIndexerRandomStateScalarTnpt)function)AbstractMethodError	DataError)AppenderSubstitutioncache_readonlydoc)find_stack_level)coerce_indexer_dtypeensure_dtype_can_hold_na)is_bool_dtypeis_float_dtypeis_hashable
is_integeris_integer_dtypeis_list_likeis_numeric_dtypeis_object_dtype	is_scalarneeds_i8_conversionpandas_dtype)isnana_value_for_dtypenotna)
algorithmssample)executor)warn_alias_replacement)ArrowExtensionArrayBaseMaskedArrayCategoricalExtensionArrayFloatingArrayIntegerArraySparseArray)StringDtype)ArrowStringArrayArrowStringArrayNumpySemantics)PandasObjectSelectionMixin)	DataFrame)NDFrame)basenumba_ops)get_grouper)GroupByIndexingMixinGroupByNthSelector)CategoricalIndexIndex
MultiIndex
RangeIndexdefault_index)ensure_block_shape)Series)get_group_index_sorter)get_jit_argumentsmaybe_use_numba)Any)	Resampler)ExpandingGroupbyExponentialMovingWindowGroupbyRollingGroupbyz
        See Also
        --------
        Series.%(name)s : Apply a function %(name)s to a Series.
        DataFrame.%(name)s : Apply a function %(name)s
            to each row or column of a DataFrame.
al	  
    Apply function ``func`` group-wise and combine the results together.

    The function passed to ``apply`` must take a {input} as its first
    argument and return a DataFrame, Series or scalar. ``apply`` will
    then take care of combining the results back together into a single
    dataframe or series. ``apply`` is therefore a highly flexible
    grouping method.

    While ``apply`` is a very flexible method, its downside is that
    using it can be quite a bit slower than using more specific methods
    like ``agg`` or ``transform``. Pandas offers a wide range of method that will
    be much faster than using ``apply`` for their specific purposes, so try to
    use them before reaching for ``apply``.

    Parameters
    ----------
    func : callable
        A callable that takes a {input} as its first argument, and
        returns a dataframe, a series or a scalar. In addition the
        callable may take positional and keyword arguments.
    include_groups : bool, default True
        When True, will attempt to apply ``func`` to the groupings in
        the case that they are columns of the DataFrame. If this raises a
        TypeError, the result will be computed with the groupings excluded.
        When False, the groupings will be excluded when applying ``func``.

        .. versionadded:: 2.2.0

        .. deprecated:: 2.2.0

           Setting include_groups to True is deprecated. Only the value
           False will be allowed in a future version of pandas.

    args, kwargs : tuple and dict
        Optional positional and keyword arguments to pass to ``func``.

    Returns
    -------
    Series or DataFrame

    See Also
    --------
    pipe : Apply function to the full GroupBy object instead of to each
        group.
    aggregate : Apply aggregate function to the GroupBy object.
    transform : Apply function column-by-column to the GroupBy object.
    Series.apply : Apply a function to a Series.
    DataFrame.apply : Apply a function to each row or column of a DataFrame.

    Notes
    -----

    .. versionchanged:: 1.3.0

        The resulting dtype will reflect the return value of the passed ``func``,
        see the examples below.

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

    Examples
    --------
    {examples}
    a?  
    >>> df = pd.DataFrame({'A': 'a a b'.split(),
    ...                    'B': [1, 2, 3],
    ...                    'C': [4, 6, 5]})
    >>> g1 = df.groupby('A', group_keys=False)
    >>> g2 = df.groupby('A', group_keys=True)

    Notice that ``g1`` and ``g2`` have two groups, ``a`` and ``b``, and only
    differ in their ``group_keys`` argument. Calling `apply` in various ways,
    we can get different grouping results:

    Example 1: below the function passed to `apply` takes a DataFrame as
    its argument and returns a DataFrame. `apply` combines the result for
    each group together into a new DataFrame:

    >>> g1[['B', 'C']].apply(lambda x: x / x.sum())
              B    C
    0  0.333333  0.4
    1  0.666667  0.6
    2  1.000000  1.0

    In the above, the groups are not part of the index. We can have them included
    by using ``g2`` where ``group_keys=True``:

    >>> g2[['B', 'C']].apply(lambda x: x / x.sum())
                B    C
    A
    a 0  0.333333  0.4
      1  0.666667  0.6
    b 2  1.000000  1.0

    Example 2: The function passed to `apply` takes a DataFrame as
    its argument and returns a Series.  `apply` combines the result for
    each group together into a new DataFrame.

    .. versionchanged:: 1.3.0

        The resulting dtype will reflect the return value of the passed ``func``.

    >>> g1[['B', 'C']].apply(lambda x: x.astype(float).max() - x.min())
         B    C
    A
    a  1.0  2.0
    b  0.0  0.0

    >>> g2[['B', 'C']].apply(lambda x: x.astype(float).max() - x.min())
         B    C
    A
    a  1.0  2.0
    b  0.0  0.0

    The ``group_keys`` argument has no effect here because the result is not
    like-indexed (i.e. :ref:`a transform <groupby.transform>`) when compared
    to the input.

    Example 3: The function passed to `apply` takes a DataFrame as
    its argument and returns a scalar. `apply` combines the result for
    each group together into a Series, including setting the index as
    appropriate:

    >>> g1.apply(lambda x: x.C.max() - x.B.min(), include_groups=False)
    A
    a    5
    b    2
    dtype: int64a  
    >>> s = pd.Series([0, 1, 2], index='a a b'.split())
    >>> g1 = s.groupby(s.index, group_keys=False)
    >>> g2 = s.groupby(s.index, group_keys=True)

    From ``s`` above we can see that ``g`` has two groups, ``a`` and ``b``.
    Notice that ``g1`` have ``g2`` have two groups, ``a`` and ``b``, and only
    differ in their ``group_keys`` argument. Calling `apply` in various ways,
    we can get different grouping results:

    Example 1: The function passed to `apply` takes a Series as
    its argument and returns a Series.  `apply` combines the result for
    each group together into a new Series.

    .. versionchanged:: 1.3.0

        The resulting dtype will reflect the return value of the passed ``func``.

    >>> g1.apply(lambda x: x * 2 if x.name == 'a' else x / 2)
    a    0.0
    a    2.0
    b    1.0
    dtype: float64

    In the above, the groups are not part of the index. We can have them included
    by using ``g2`` where ``group_keys=True``:

    >>> g2.apply(lambda x: x * 2 if x.name == 'a' else x / 2)
    a  a    0.0
       a    2.0
    b  b    1.0
    dtype: float64

    Example 2: The function passed to `apply` takes a Series as
    its argument and returns a scalar. `apply` combines the result for
    each group together into a Series, including setting the index as
    appropriate:

    >>> g1.apply(lambda x: x.max() - x.min())
    a    1
    b    0
    dtype: int64

    The ``group_keys`` argument has no effect here because the result is not
    like-indexed (i.e. :ref:`a transform <groupby.transform>`) when compared
    to the input.

    >>> g2.apply(lambda x: x.max() - x.min())
    a    1
    b    0
    dtype: int64)templatedataframe_examplesseries_examplesa   
Compute {fname} of group values.

Parameters
----------
numeric_only : bool, default {no}
    Include only float, int, boolean columns.

    .. versionchanged:: 2.0.0

        numeric_only no longer accepts ``None``.

min_count : int, default {mc}
    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 {fname} of values within each group.

Examples
--------
{example}
a:  
Compute {fname} of group values.

Parameters
----------
numeric_only : bool, default {no}
    Include only float, int, boolean columns.

    .. versionchanged:: 2.0.0

        numeric_only no longer accepts ``None``.

min_count : int, default {mc}
    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.

engine : str, default None {e}
    * ``'cython'`` : Runs rolling apply through C-extensions from cython.
    * ``'numba'`` : Runs rolling apply through JIT compiled code from numba.
        Only available when ``raw`` is set to ``True``.
    * ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba``

engine_kwargs : dict, default None {ek}
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
        and ``parallel`` dictionary keys. The values must either be ``True`` or
        ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
        ``{{'nopython': True, 'nogil': False, 'parallel': False}}`` and will be
        applied to both the ``func`` and the ``apply`` groupby aggregation.

Returns
-------
Series or DataFrame
    Computed {fname} of values within each group.

Examples
--------
{example}
a  
Apply a ``func`` with arguments to this %(klass)s 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 %(klass)s object or, alternatively,
    a `(callable, data_keyword)` tuple where `data_keyword` is a
    string indicating the keyword of `callable` that expects the
    %(klass)s object.
args : iterable, optional
       Positional arguments passed into `func`.
kwargs : dict, optional
         A dictionary of keyword arguments passed into `func`.

Returns
-------
the return type of `func`.

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 %(klass)s object.

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

Examples
--------
%(examples)s
a  
Call function producing a same-indexed %(klass)s on each group.

Returns a %(klass)s having the same indexes as the original object
filled with the transformed values.

Parameters
----------
f : function, str
    Function to apply to each group. See the Notes section below for requirements.

    Accepted inputs are:

    - String
    - Python function
    - Numba JIT function with ``engine='numba'`` specified.

    Only passing a single function is supported with this engine.
    If the ``'numba'`` engine is chosen, the function must be
    a user defined function with ``values`` and ``index`` as the
    first and second arguments respectively in the function signature.
    Each group's index will be passed to the user defined function
    and optionally available for use.

    If a string is chosen, then it needs to be the name
    of the groupby method you want to use.
*args
    Positional arguments to pass to func.
engine : str, default None
    * ``'cython'`` : Runs the function through C-extensions from cython.
    * ``'numba'`` : Runs the function through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or the global setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{'nopython': True, 'nogil': False, 'parallel': False}`` and will be
      applied to the function

**kwargs
    Keyword arguments to be passed into func.

Returns
-------
%(klass)s

See Also
--------
%(klass)s.groupby.apply : Apply function ``func`` group-wise and combine
    the results together.
%(klass)s.groupby.aggregate : Aggregate using one or more
    operations over the specified axis.
%(klass)s.transform : Call ``func`` on self producing a %(klass)s with the
    same axis shape as self.

Notes
-----
Each group is endowed the attribute 'name' in case you need to know
which group you are working on.

The current implementation imposes three requirements on f:

* f must return a value that either has the same shape as the input
  subframe or can be broadcast to the shape of the input subframe.
  For example, if `f` returns a scalar it will be broadcast to have the
  same shape as the input subframe.
* if this is a DataFrame, f must support application column-by-column
  in the subframe. If f also supports application to the entire subframe,
  then a fast path is used starting from the second chunk.
* f must not mutate groups. Mutation is not supported and may
  produce unexpected results. See :ref:`gotchas.udf-mutation` for more details.

When using ``engine='numba'``, there will be no "fall back" behavior internally.
The group data and group index will be passed as numpy arrays to the JITed
user defined function, and no alternative execution attempts will be tried.

.. versionchanged:: 1.3.0

    The resulting dtype will reflect the return value of the passed ``func``,
    see the examples below.

.. versionchanged:: 2.0.0

    When using ``.transform`` on a grouped DataFrame and the transformation function
    returns a DataFrame, pandas now aligns the result's index
    with the input's index. You can call ``.to_numpy()`` on the
    result of the transformation function to avoid alignment.

Examples
--------
%(example)saP  
Aggregate using one or more operations over the specified axis.

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

    Accepted combinations are:

    - function
    - string function name
    - list of functions and/or function names, e.g. ``[np.sum, 'mean']``
    - None, in which case ``**kwargs`` are used with Named Aggregation. Here the
      output has one column for each element in ``**kwargs``. The name of the
      column is keyword, whereas the value determines the aggregation used to compute
      the values in the column.

      Can also accept a Numba JIT function with
      ``engine='numba'`` specified. Only passing a single function is supported
      with this engine.

      If the ``'numba'`` engine is chosen, the function must be
      a user defined function with ``values`` and ``index`` as the
      first and second arguments respectively in the function signature.
      Each group's index will be passed to the user defined function
      and optionally available for use.

    .. deprecated:: 2.1.0

        Passing a dictionary is deprecated and will raise in a future version
        of pandas. Pass a list of aggregations instead.
*args
    Positional arguments to pass to func.
engine : str, default None
    * ``'cython'`` : Runs the function through C-extensions from cython.
    * ``'numba'`` : Runs the function through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{{'nopython': True, 'nogil': False, 'parallel': False}}`` and will be
      applied to the function

**kwargs
    * If ``func`` is None, ``**kwargs`` are used to define the output names and
      aggregations via Named Aggregation. See ``func`` entry.
    * Otherwise, keyword arguments to be passed into func.

Returns
-------
{klass}

See Also
--------
{klass}.groupby.apply : Apply function func group-wise
    and combine the results together.
{klass}.groupby.transform : Transforms the Series on each group
    based on the given function.
{klass}.aggregate : Aggregate using one or more
    operations over the specified axis.

Notes
-----
When using ``engine='numba'``, there will be no "fall back" behavior internally.
The group data and group index will be passed as numpy arrays to the JITed
user defined function, and no alternative execution attempts will be tried.

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

.. versionchanged:: 1.3.0

    The resulting dtype will reflect the return value of the passed ``func``,
    see the examples below.
{examples}a  
Aggregate using one or more operations over the specified axis.

Parameters
----------
func : function, str, list, dict or None
    Function to use for aggregating the data. If a function, must either
    work when passed a {klass} or when passed to {klass}.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.
    - None, in which case ``**kwargs`` are used with Named Aggregation. Here the
      output has one column for each element in ``**kwargs``. The name of the
      column is keyword, whereas the value determines the aggregation used to compute
      the values in the column.

      Can also accept a Numba JIT function with
      ``engine='numba'`` specified. Only passing a single function is supported
      with this engine.

      If the ``'numba'`` engine is chosen, the function must be
      a user defined function with ``values`` and ``index`` as the
      first and second arguments respectively in the function signature.
      Each group's index will be passed to the user defined function
      and optionally available for use.

*args
    Positional arguments to pass to func.
engine : str, default None
    * ``'cython'`` : Runs the function through C-extensions from cython.
    * ``'numba'`` : Runs the function through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or globally setting ``compute.use_numba``

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{{'nopython': True, 'nogil': False, 'parallel': False}}`` and will be
      applied to the function

**kwargs
    * If ``func`` is None, ``**kwargs`` are used to define the output names and
      aggregations via Named Aggregation. See ``func`` entry.
    * Otherwise, keyword arguments to be passed into func.

Returns
-------
{klass}

See Also
--------
{klass}.groupby.apply : Apply function func group-wise
    and combine the results together.
{klass}.groupby.transform : Transforms the Series on each group
    based on the given function.
{klass}.aggregate : Aggregate using one or more
    operations over the specified axis.

Notes
-----
When using ``engine='numba'``, there will be no "fall back" behavior internally.
The group data and group index will be passed as numpy arrays to the JITed
user defined function, and no alternative execution attempts will be tried.

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

.. versionchanged:: 1.3.0

    The resulting dtype will reflect the return value of the passed ``func``,
    see the examples below.
{examples}c                  2    \ rS rSrSrSS jrS rS	S jrSrg)
GroupByPloti  z=
Class implementing the .plot attribute for groupby objects.
c                    Xl         g N_groupby)selfgroupbys     M/var/www/html/env/lib/python3.13/site-packages/pandas/core/groupby/groupby.py__init__GroupByPlot.__init__  s        c                   ^^ UU4S jnSUl         U R                  R                  X0R                  R                  5      $ )Nc                (   > U R                   " T0 TD6$ ri   )plot)rl   argskwargss    rn   fGroupByPlot.__call__.<locals>.f  s    99d-f--rq   rt   )__name__rk   _python_apply_general_selected_obj)rl   ru   rv   rw   s    `` rn   __call__GroupByPlot.__call__  s0    	. 
}}221mm6Q6QRRrq   c                   ^ ^ UU 4S jnU$ )Nc                 x   >^ ^ U UU4S jnTR                   R                  UTR                   R                  5      $ )Nc                <   > [        U R                  T5      " T0 TD6$ ri   )getattrrt   )rl   ru   rv   names    rn   rw   0GroupByPlot.__getattr__.<locals>.attr.<locals>.f  s    tyy$/@@@rq   )rk   rz   r{   )ru   rv   rw   r   rl   s   `` rn   attr%GroupByPlot.__getattr__.<locals>.attr  s,    A ==66q$--:U:UVVrq    )rl   r   r   s   `` rn   __getattr__GroupByPlot.__getattr__  s    	W rq   rj   N)rm   GroupByreturnNoner   str)	ry   
__module____qualname____firstlineno____doc__ro   r|   r   __static_attributes__r   rq   rn   rg   rg     s     Srq   rg   c                     \ rS rSr% \R
                  1 Sk-  rS\S'   S\S'   SrS\S	'   SrS
\S'   S\S'   \	SS j5       r
\	S S j5       r\	\S!S j5       5       r\	\S"S j5       5       r\	\SS j5       5       r\	\S#S j5       5       r\	S 5       r\	S 5       r\	\S 5       5       r\	S$S j5       r\" S\" S5      S9\" \5          S%S j5       5       r\	S&S'S jj5       r\	S(S j5       rSrg))BaseGroupByi  >   objaxiskeyssortleveldropnagrouperas_indexobserved
exclusions
group_keysr   r   ops.BaseGrouper_grouperN_KeysArgType | Noner   IndexLabel | Noner   boolr   c                ,    [        U R                  5      $ ri   )lengroupsrl   s    rn   __len__BaseGroupBy.__len__  s    4;;rq   c                ,    [         R                  U 5      $ ri   )object__repr__r   s    rn   r   BaseGroupBy.__repr__  s     t$$rq   c                    [         R                  " [        U 5      R                   S3[        [        5       S9  U R                  $ )NzI.grouper is deprecated and will be removed in a future version of pandas.)category
stacklevel)warningswarntypery   FutureWarningr+   r   r   s    rn   r   BaseGroupBy.grouper  s?     	Dz""# $( ("')		
 }}rq   c                .    U R                   R                  $ )a1  
Dict {group name -> group labels}.

Examples
--------

For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([1, 2, 3], index=lst)
>>> ser
a    1
a    2
b    3
dtype: int64
>>> ser.groupby(level=0).groups
{'a': ['a', 'a'], 'b': ['b']}

For DataFrameGroupBy:

>>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"])
>>> df
   a  b  c
0  1  2  3
1  1  5  6
2  7  8  9
>>> df.groupby(by=["a"]).groups
{1: [0, 1], 7: [2]}

For Resampler:

>>> 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').groups
{Timestamp('2023-01-01 00:00:00'): 2, Timestamp('2023-02-01 00:00:00'): 4}
)r   r   r   s    rn   r   BaseGroupBy.groups%  s    \ }}###rq   c                .    U R                   R                  $ ri   )r   ngroupsr   s    rn   r   BaseGroupBy.ngroupsU  s     }}$$$rq   c                .    U R                   R                  $ )a  
Dict {group name -> group indices}.

Examples
--------

For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([1, 2, 3], index=lst)
>>> ser
a    1
a    2
b    3
dtype: int64
>>> ser.groupby(level=0).indices
{'a': array([0, 1]), 'b': array([2])}

For DataFrameGroupBy:

>>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["owl", "toucan", "eagle"])
>>> df
        a  b  c
owl     1  2  3
toucan  1  5  6
eagle   7  8  9
>>> df.groupby(by=["a"]).indices
{1: array([0, 1]), 7: array([2])}

For Resampler:

>>> 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').indices
defaultdict(<class 'list'>, {Timestamp('2023-01-01 00:00:00'): [0, 1],
Timestamp('2023-02-01 00:00:00'): [2, 3]})
)r   indicesr   s    rn   r   BaseGroupBy.indicesZ  s    ` }}$$$rq   c                  ^	^
 S n[        U5      S:X  a  / $ [        U R                  5      S:  a  [        [        U R                  5      5      nOSnUS   n[	        U[
        5      (       a  [	        U[
        5      (       d  Sn[        U5      e[        U5      [        U5      :X  d    U Vs/ s H  o`R                  U   PM     sn$ U Vs/ s H
  o" U5      PM     snm
U
4S jU 5       nOU" U5      m	U	4S jU 5       nU Vs/ s H  o`R                  R                  U/ 5      PM      sn$ s  snf ! [         a  nSn[        U5      UeSnAff = fs  snf s  snf )zL
Safe get multiple indices, translate keys for
datelike to underlying repr.
c                    [        U [        R                  5      (       a  S $ [        U [        R                  5      (       a  S $ S $ )Nc                    [        U 5      $ ri   )r   keys    rn   <lambda>ABaseGroupBy._get_indices.<locals>.get_converter.<locals>.<lambda>  s    9S>rq   c                ,    [        U 5      R                  $ ri   )r   asm8r   s    rn   r   r     s    9S>#6#6rq   c                    U $ ri   r   r   s    rn   r   r     s    3rq   )
isinstancedatetimenp
datetime64)ss    rn   get_converter/BaseGroupBy._get_indices.<locals>.get_converter  s:     !X..//11Ar}}--66&&rq   r   Nz<must supply a tuple to get_group with multiple grouping keyszHmust supply a same-length tuple to get_group with multiple grouping keysc              3  \   >#    U  H!  n[        S  [        TU5       5       5      v   M#     g7f)c              3  6   #    U  H  u  pU" U5      v   M     g 7fri   r   ).0rw   ns      rn   	<genexpr>5BaseGroupBy._get_indices.<locals>.<genexpr>.<genexpr>  s     B,ADA1Q44,As   N)tuplezip)r   r   
converterss     rn   r   +BaseGroupBy._get_indices.<locals>.<genexpr>  s&     UutUBC
D,ABBBus   ),c              3  4   >#    U  H  nT" U5      v   M     g 7fri   r   )r   r   	converters     rn   r   r     s     7Yt__s   )	r   r   nextiterr   r   
ValueErrorKeyErrorget)rl   namesr   index_samplename_samplemsgr   errr   r   r   s            @@rn   _get_indicesBaseGroupBy._get_indices  s@   	' u:?It||q T\\ 23LLAhlE**k511T o%{#s<'88	3;@A54LL.5AA 5AALq-*LAJUuUE &l3I77E7<=ut  r*u==! B 36  %S/s23 B >s6   &D/ *D*D/ 	E%E*D/ /
E9EEc                ,    U R                  U/5      S   $ )zA
Safe get index, translate keys for datelike to underlying repr.
r   )r   )rl   r   s     rn   
_get_indexBaseGroupBy._get_index  s    
   $(++rq   c                   [        U R                  [        5      (       a  U R                  $ U R                  b?  [	        U R                  5      (       a  U R                  U R                     $ U R
                  $ U R                  $ ri   )r   r   rZ   
_selectionr0   _obj_with_exclusionsr   s    rn   r{   BaseGroupBy._selected_obj  sc     dhh''88O??&4??++ xx00
 ,,,xxrq   c                6    U R                   R                  5       $ ri   )r   _dir_additionsr   s    rn   r   BaseGroupBy._dir_additions  s    xx&&((rq   r   a          >>> df = pd.DataFrame({'A': 'a b a b'.split(), 'B': [1, 2, 3, 4]})
        >>> df
           A  B
        0  a  1
        1  b  2
        2  a  3
        3  b  4

        To get the difference between each groups maximum and minimum value in one
        pass, you can do

        >>> df.groupby('A').pipe(lambda x: x.max() - x.min())
           B
        A
        a  2
        b  2)klassexamplesc                6    [         R                  " X/UQ70 UD6$ ri   )compipe)rl   funcru   rv   s       rn   r   BaseGroupBy.pipe  s    : xx4T4V44rq   c                   U R                   nU R                  n[        U5      (       a  [        U5      S:X  d  [        U5      (       ap  [        U5      S:X  aa  [	        U[
        5      (       a  [        U5      S:X  a  US   nO7[	        U[
        5      (       d"  [        R                  " S[        [        5       S9  U R                  U5      n[        U5      (       d  [        U5      eUc8  U R                  S:X  a  UO[        S5      U4nU R                  R                  U   $ [        R                  " S[        [        5       S9  UR!                  XPR                  S9$ )ay  
Construct DataFrame from group with provided name.

Parameters
----------
name : object
    The name of the group to get as a DataFrame.
obj : DataFrame, default None
    The DataFrame to take the DataFrame out of.  If
    it is None, the object groupby was called on will
    be used.

    .. deprecated:: 2.1.0
        The obj is deprecated and will be removed in a future version.
        Do ``df.iloc[gb.indices.get(name)]``
        instead of ``gb.get_group(name, obj=df)``.

Returns
-------
same type as obj

Examples
--------

For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([1, 2, 3], index=lst)
>>> ser
a    1
a    2
b    3
dtype: int64
>>> ser.groupby(level=0).get_group("a")
a    1
a    2
dtype: int64

For DataFrameGroupBy:

>>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["owl", "toucan", "eagle"])
>>> df
        a  b  c
owl     1  2  3
toucan  1  5  6
eagle   7  8  9
>>> df.groupby(by=["a"]).get_group((1,))
        a  b  c
owl     1  2  3
toucan  1  5  6

For Resampler:

>>> 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').get_group('2023-01-01')
2023-01-01    1
2023-01-15    2
dtype: int64
   r   zWhen grouping with a length-1 list-like, you will need to pass a length-1 tuple to get_group in a future version of pandas. Pass `(name,)` instead of `name` to silence this warning.r   Nzobj is deprecated and will be removed in a future version. Do ``df.iloc[gb.indices.get(name)]`` instead of ``gb.get_group(name, obj=df)``.r   )r   r   r3   r   r   r   r   r   r   r+   r   r   r   slicer{   iloc_take_with_is_copy)rl   r   r   r   r   indsindexers          rn   	get_groupBaseGroupBy.get_group  s   L yy

CJ!O3t9> $&&3t9>Awe,,$ "/1 t$4yy4. ;"ii1nd5;2EG%%**733MM= +- ))$YY)??rq   c                n   U R                   nU R                  nU R                  R                  U R                  U R
                  S9n[        U5      (       a1  [        U5      S:X  a"  [        R                  " S[        [        5       S9  [        U[        5      (       a  [        U5      S:X  a	  S U 5       nU$ )aZ  
Groupby iterator.

Returns
-------
Generator yielding sequence of (name, subsetted object)
for each group

Examples
--------

For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([1, 2, 3], index=lst)
>>> ser
a    1
a    2
b    3
dtype: int64
>>> for x, y in ser.groupby(level=0):
...     print(f'{x}\n{y}\n')
a
a    1
a    2
dtype: int64
b
b    3
dtype: int64

For DataFrameGroupBy:

>>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"])
>>> df
   a  b  c
0  1  2  3
1  1  5  6
2  7  8  9
>>> for x, y in df.groupby(by=["a"]):
...     print(f'{x}\n{y}\n')
(1,)
   a  b  c
0  1  2  3
1  1  5  6
(7,)
   a  b  c
2  7  8  9

For Resampler:

>>> 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
>>> for x, y in ser.resample('MS'):
...     print(f'{x}\n{y}\n')
2023-01-01 00:00:00
2023-01-01    1
2023-01-15    2
dtype: int64
2023-02-01 00:00:00
2023-02-01    3
2023-02-15    4
dtype: int64
r   r   zCreating a Groupby object with a length-1 list-like level parameter will yield indexes as tuples in a future version. To keep indexes as scalars, create Groupby objects with a scalar level parameter instead.r   c              3  0   #    U  H  u  pU4U4v   M     g 7fri   r   )r   r   groups      rn   r   'BaseGroupBy.__iter__.<locals>.<genexpr>  s     ?*#vuos   )r   r   r   get_iteratorr{   r   r3   r   r   r   r   r+   r   list)rl   r   r   results       rn   __iter__BaseGroupBy.__iter__i  s    P yy

++D,>,>TYY+O3u:?MM4 +- dD!!c$i1n??Frq   r   )r   int)r   r   )r   r   )r   zdict[Hashable, np.ndarray])r   z$dict[Hashable, npt.NDArray[np.intp]])r   zset[str])r   z/Callable[..., T] | tuple[Callable[..., T], str]r   r"   ri   r   DataFrame | Series)r   z#Iterator[tuple[Hashable, NDFrameT]])ry   r   r   r   rJ   _hidden_attrs__annotations__r   r   r   r   r   propertyr   r   r   r   r   r   r)   r{   r   r(   r
   r'   _pipe_templater   r  r  r   r   rq   rn   r   r     s    .. 2 M M $D
$#E#
    % %    ,$  ,$\ %  % .%  .%` 0> 0>d , ,   & ) ) 
, n5=5
 
5 -.5 h@ h@T X Xrq   r   OutputFrameOrSeries)boundc                     \ rS rSr% SrS\S'   S\S'   \SSSSSSS	S	S	\R                  S	4                         SkS
 jj5       r	SlS jr
\SmS j5       r\SnS j5       r\  So   SpS jj5       r\    SqS j5       r\SrS j5       r\SsS j5       r\ St   SuS jj5       r  So     SvS jjr\SwS j5       r      SxS jr\SS.S j5       r\SS.S j5       r\" \S   R3                  S\S   S95      S	S.SyS jj5       r\   Sz           S{S  jj5       r\  S|SS".       S}S# jjj5       r          S~S$ jr\   S       SS% jj5       r S     SS& jjr\SSS'.S( j5       r \SsS) j5       r!\S* 5       r"\SSS+ jj5       r#\\$SS, j5       5       r%\\&" S-S.9\&" \'S/9SSS0 jj5       5       5       r(\\&" S-S.9\&" \'S/9SSS1 jj5       5       5       r)\\&" S-S.9\&" \'S/9SS2 j5       5       5       r*\\&" S-S.9\&" \'S/9   S     SS3 jj5       5       5       r+\SSS4 jj5       r,\\&" S-S.9\&" \'S/9    S       SS6 jj5       5       5       r-\\&" S-S.9\&" \'S/9    S       SS7 jj5       5       5       r.\     S           SS8 jj5       r/\SSS9 jj5       r0\\&" S-S.9\&" \'S/9SS: j5       5       5       r1\\2" \3S;SSSS\4" S<5      S=9    S       SS> jj5       5       r5\\2" \6S?SS\4" S@5      SA9SSSB jj5       5       r7\\2" \3SCSS!SS\4" SD5      S=9    S       SSE jj5       5       r8\\2" \3SFSS!SS\4" SG5      S=9    S       SSH jj5       5       r9\ S       SSI jj5       r:\ S       SSJ jj5       r;\SSK j5       r<\2" \=R|                  5         S SSL jj5       r>\S	S.SSM jj5       r?\SSN j5       r@\\&" S-S.9\" \'5      SSO j5       5       5       rA\\&" S-S.9\" \'5      SSP j5       5       5       rB\StSSQ jj5       rC\\&" S-S.9StSSR jj5       5       rD\\&" S-S.9StSSS jj5       5       rE\\$\&" S-S.9\&" \'S/9SST j5       5       5       5       rF St     SSU jjrG\   S     SSV jj5       rH\\&" S-S.9SSSW jj5       5       rI\\&" S-S.9SSSX jj5       5       rJ\\&" S-S.9\&" \'S/9SYS	SZS\R                  4           SS[ jj5       5       5       rK\\&" S-S.9\&" \'S/9\R                  4   SS\ jj5       5       5       rL\\&" S-S.9\&" \'S/9\R                  4   SS] jj5       5       5       rM\\&" S-S.9\&" \'S/9\R                  S4     SS^ jj5       5       5       rN\\&" S-S.9\&" \'S/9\R                  S4     SS_ jj5       5       5       rO\\&" S-S.9S5S\R                  \R                  S4     SS` jj5       5       rP\\&" S-S.9\&" \'S/9S5\R                  4     SSa jj5       5       5       rQ\\&" S-S.9\&" \'S/9S5\R                  \R                  S\R                  4       SSb jj5       5       5       rR\\&" S-S.9\&" \'S/9SSSc jj5       5       5       rS\\&" S-S.9\&" \'S/9SSSd jj5       5       5       rT\SSe j5       rU\\VR                  S4       SSf jj5       rX\     S         SSg jj5       rYS\R                  S	S4           SSh jjrZSSi jr[Sjr\g)r   i  a  
Class for grouping and aggregating relational data.

See aggregate, transform, and apply functions on this object.

It's easiest to use obj.groupby(...) to use GroupBy, but you can also do:

::

    grouped = groupby(obj, ...)

Parameters
----------
obj : pandas object
axis : int, default 0
level : int, default None
    Level of MultiIndex
groupings : list of Grouping objects
    Most users should ignore this
exclusions : array-like, optional
    List of columns to exclude
name : str
    Most users should ignore this

Returns
-------
**Attributes**
groups : dict
    {group name -> group labels}
len(grouped) : int
    Number of groups

Notes
-----
After grouping, see aggregate, apply, and transform functions. Here are
some other brief notes about usage. When grouping by multiple groups, the
result index will be a MultiIndex (hierarchical) by default.

Iteration produces (key, group) tuples, i.e. chunking the data by group. So
you can write code like:

::

    grouped = obj.groupby(keys, axis=axis)
    for key, group in grouped:
        # do something with the data

Function calls on GroupBy, if not specially implemented, "dispatch" to the
grouped data. So if you group a DataFrame and wish to invoke the std()
method on each group, you can simply do:

::

    df.groupby(mapper).std()

rather than

::

    df.groupby(mapper).aggregate(np.std)

You can pass arguments to these "wrapped" functions, too.

See the online documentation for full exposition on these topics and much
more
r   r   r   r   Nr   Tc           
        Xpl         [        U[        5      (       d   [        U5      5       eX@l        U(       d  US:w  a  [        S5      eXl        X l        Xl        Xl	        Xl
        Uc1  [        UUUUU	U[        R                  L a  SOUU R                  S9u  pVnU[        R                  L aE  [        S UR                   5       5      (       a"  [         R"                  " S[$        ['        5       S9  SnXl        Xl        UR-                  U5      U l        XPl        U(       a  [3        U5      U l        g [3        5       U l        g )Nr   z$as_index=False only valid for axis=0F)r   r   r   r   r   c              3  8   #    U  H  oR                   v   M     g 7fri   _passed_categoricalr   pings     rn   r   #GroupBy.__init__.<locals>.<genexpr><  s     J8I++8I   zThe default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.r   )r   r   rM   r   r   r   r   r   r   r   r   rQ   r   
no_defaultany	groupingsr   r   r   r+   r   r   _get_axis_numberr   r   	frozensetr   )rl   r   r   r   r   r   r   	selectionr   r   r   r   r   s                rn   ro   GroupBy.__init__  s     $#w''2c2'
qy !GHH 		$?'2"*cnn"<({{($G s~~%J8I8IJJJ8 "/1 H ((.	3=)J/9;rq   c                    XR                   ;   a  [        R                  X5      $ XR                  ;   a  X   $ [	        S[        U 5      R                   SU S35      e)N'z' object has no attribute ')_internal_names_setr   __getattribute__r   AttributeErrorr   ry   )rl   r   s     rn   r   GroupBy.__getattr__M  s\    +++**46688:T
##$$?vQG
 	
rq   c                    US:X  a<  [         R                  " [        U 5      R                   SU S3[        [        5       S9  g [         R                  " S[        U 5      R                   SU S3[        [        5       S9  g )Nr   .zo with axis=1 is deprecated and will be removed in a future version. Operate on the un-grouped DataFrame insteadr   zThe 'axis' keyword in z\ is deprecated and will be removed in a future version. Call without passing 'axis' instead.)r   r   r   ry   r   r+   )rl   r   r   s      rn   _deprecate_axisGroupBy._deprecate_axisW  s|    19MM:&&'q /$ $ +- MM(d)<)<(=Qtf E7 7 +-rq   c                :  ^^^	 [        [        U R                  5      U5      m	[        R                  " T	5      nST;   aF  TS   [
        R                  La0  U R                  R                  TS   5      nU R                  XQ5        OST;   a  US:X  a  OUS:X  a  STS'   OSTS'   SUR                  ;   aD  TR                  SS5      b"  TR                  S5      [
        R                  L a  U R                  TS'   UU	U4S jnXl        U[        R                  ;   a  U R!                  X`R"                  5      $ U[        R$                  ;   nU R!                  UU R                  UU(       + S9nU R&                  R(                  (       a  U(       a  U R+                  U5      nU$ )z<Compute the result of an operation by using GroupBy's apply.r   skewfillnaNr   c                   > T" U /TQ70 TD6$ ri   r   )xru   rw   rv   s    rn   curried&GroupBy._op_via_apply.<locals>.curried  s    Q((((rq   )is_transformnot_indexed_same)r   r   r   inspect	signaturer   r  r   r"  r.  
parametersr   r   ry   rN   plotting_methodsrz   r{   transformation_kernelsr   has_dropped_na_set_result_index_ordered)
rl   r   ru   rv   sigr   r5  r7  r
  rw   s
     ``     @rn   _op_via_applyGroupBy._op_via_applyj  sm    D223T:"Vvcnn D88,,VF^<D  ,v v~!!%v!"v S^^#zz&$'/6::f3E3W!%v	)
   4(((--g7I7IJJt:::++%%%!--	 , 
 ==''L 33F;Frq   Fc           	        SSK Jn  U R                  (       a  U(       d  U R                  (       aY  U R                  R
                  nU R                  R                  nU R                  R                  nU" UU R                  UUUSS9nGO`[        [        [        U5      5      5      n	U" XR                  U	S9nGO0U(       Gd  U" XR                  S9nU R                  R                  U R                  5      n
U R                  (       a"  U R                  R                  S   nUS:g  nX   n
U
R                   (       a  UR"                  U R                     R%                  U
5      (       dW  [&        R(                  " U
R*                  5      nUR,                  R/                  U5      u  pUR1                  XR                  S9nO+UR3                  XR                  SS9nOU" XR                  S9nU R4                  R6                  S	:X  a  U R4                  R8                  nO)[;        U R<                  5      (       a  U R<                  nOS n[?        U[@        5      (       a
  Ub  UUl        U$ )
Nr   concatF)r   r   levelsr   r   )r   r   r   r   copyr   )!pandas.core.reshape.concatrE  r   r   r   result_indexrF  r   r   r	  ranger   r{   	_get_axisr   
group_infohas_duplicatesaxesequalsr<   unique1d_valuesindexget_indexer_non_uniquetakereindexr   ndimr   r0   r   r   rZ   )rl   valuesr8  r7  rE  r   group_levelsgroup_namesr
  r   axlabelsmasktargetr  _r   s                    rn   _concat_objectsGroupBy._concat_objects  s    	6??<}}!]]77
#}}33"mm11#'% E#f+./YYTB!F3F##--dii8B{{11!4|X   TYY)?)F)Fr)J)J#,,RZZ8#\\@@H
W99=G F3F88==A88==D))??DDff%%$*:FKrq   c                b   U R                   R                  U R                  5      nU R                  R                  (       a7  U R                  R
                  (       d  UR                  X R                  SS9nU$ [        U R                  R                  5       5      nUR                  X0R                  SS9nUR                  U R                  S9nU R                  R
                  (       a,  UR                  [        [        U5      5      U R                  S9nUR                  X R                  SS9nU$ )NFrH  r   )r   rM  r   r   is_monotonicr>  set_axisrU   result_ilocs
sort_indexrW  rW   r   )rl   r
  obj_axisoriginal_positionss       rn   r?  !GroupBy._set_result_index_ordered  s     88%%dii0==%%dmm.J.J__XIIE_JFM #4==#=#=#?@!3))%P""		"2=='' ^^Js8}$=DII^NF		Frq   c           
        [        U[        5      (       a  UR                  5       nUR                  n[	        [        U R                  R                  5      [        U R                  R                  5       5      [        U R                  R                   Vs/ s H  o3R                  PM     sn5      5       HL  u  pEnXB;  d  M  U(       a  UR                  SXE5        M(  Sn[        R                  " U[        [        5       S9  MN     U$ s  snf )Nr   zA grouping was used that is not in the columns of the DataFrame and so was excluded from the result. This grouping will be included in a future version of pandas. Add the grouping as a column of the DataFrame to silence this warning.messager   r   )r   rZ   to_framecolumnsr   reversedr   r   get_group_levelsr!  in_axisinsertr   r   r   r+   )rl   r
  ro  grpr   levrr  r   s           rn   _insert_inaxis_grouperGroupBy._insert_inaxis_grouper  s    ff%%__&F .."%T]](()T]]3356T]]-D-DE-Dckk-DEF#
Dw "MM!T/Y  MM #!.#3#5##
. ) Fs   Dc                    U R                   S:X  ai  UR                  nUR                  R                  U R                  R                  5      (       a)  U R                  R                  R                  5       Ul        U$ )Nr   )r   r"   rT  rQ  r   rI  )rl   r
  s     rn   _maybe_transpose_resultGroupBy._maybe_transpose_result  sR    99>XXF||""488>>22  $xx~~224rq   c                L   U R                   (       dJ  U R                  U5      nUR                  5       n[        [	        U R
                  R                  5      5      nOU R
                  R                  nUb  [        X25      nX1l	        U R                  U5      nU R                  XBS9$ )z
Wraps the output of GroupBy aggregations into the expected result.

Parameters
----------
result : Series, DataFrame

Returns
-------
Series or DataFrame
qs)r   rv  _consolidaterU   rL  r   r   rK  _insert_quantile_levelrT  ry  _reindex_output)rl   r
  r}  rT  ress        rn   _wrap_aggregated_outputGroupBy._wrap_aggregated_output*  s    ( }} 008F((*F% 5 567E MM..E> +55E **62##C#//rq   c                    [        U 5      eri   r%   )rl   datarY  r8  r7  s        rn   _wrap_applied_outputGroupBy._wrap_applied_outputT  s     "$''rq   c                Z   U R                   R                  u  p#nU R                   R                  nU R                   R                  nUR	                  XPR
                  S9R                  5       nUR                  n[        U[        5      (       ab  [        U R                   R                  5      S:  a  [        S5      eU R                   R                  S   R                  n	UR                  U	5      nUR	                  U5      R                  5       n
[        R                   " Xd5      u  pUUU
U4$ )Nr   r   z_Grouping with more than 1 grouping labels and a MultiIndex is not supported with engine='numba'r   )r   rN  	_sort_idx_sorted_idsrV  r   to_numpyrT  r   rV   r   r!  NotImplementedErrorr   get_level_valuesr   generate_slices)rl   r  idsr`  r   sorted_index
sorted_idssorted_data
index_data	group_keysorted_index_datastartsendss                rn   _numba_prepGroupBy._numba_prep`  s    --22}}..]]..
ii99i=FFHZZ
j*--4==**+a/)H  //277I#44Y?J&OOL9BBD**:?	
 	
rq   c                   U R                   (       d  [        S5      eU R                  S:X  a  [        S5      eU R                  nUR                  S:X  a  UOUR                  5       n[        R                  " UUS40 [        U5      D6nU R                  R                  u  n  n	U R                  R                  n
UR                  R                  " U4XS.UD6nU R                  R                  UR                  S'   UR!                  XR                  S9nUR                  S:X  a$  UR#                  S5      nUR$                  Ul        U$ UR&                  Ul        U$ )	zX
Perform groupby with a standard numerical aggregation function (e.g. mean)
with Numba.
z<as_index=False is not supported. Use .reset_index() instead.r   zaxis=1 is not supported.   T)r]  r   )rP  ro  )r   r  r   r   rX  rn  r>   generate_shared_aggregatorr\   r   rN  r   _mgrapplyrK  rP  _constructor_from_mgrsqueezer   ro  )rl   r   dtype_mappingengine_kwargsaggregator_kwargsr  df
aggregatorr  r`  r   res_mgrr
  s                rn   _numba_agg_generalGroupBy._numba_agg_general{  s6    }}%N  99>%&@AA((YY!^T88
  .	

 MM,,	Q--''''--
"
7H
 --44Q))')E99>^^I.F))FK  "\\FNrq   )r  c          	     6   U R                   nUR                  S:X  a  UOUR                  5       nU R                  U5      u  pxp[        R
                  " U5        [        R                  " U40 [        X$5      D6nU" U
U	UU[        UR                  5      /UQ76 nUR                  [        R                  " U	5      SS9nUR                  nUR                  S:X  a  SUR                  0nUR                  5       nOSUR                  0nUR                   " U4SU0UD6$ )a   
Perform groupby transform routine with the numba engine.

This routine mimics the data splitting routine of the DataSplitter class
to generate the indices of each group in the sorted data and then passes the
data and indices into a Numba jitted function.
r  r   r   r   r   ro  rT  )r   rX  rn  r  rO   validate_udfgenerate_numba_transform_funcr\   r   ro  rV  r   argsortrT  r   ravel_constructor)rl   r   r  ru   rv   r  r  r  r  r  r  numba_transform_funcr
  rT  result_kwargss                  rn   _transform_with_numbaGroupBy._transform_with_numba  s
    ((YY!^T262B2B22F/lD!%CC 
%m< 
 &

O
 
 RZZ5A>

99>#TYY/M\\^F&5M  FuFFFrq   c          	     |   U R                   nUR                  S:X  a  UOUR                  5       nU R                  U5      u  pxp[        R
                  " U5        [        R                  " U40 [        X$5      D6nU" U
U	UU[        UR                  5      /UQ76 nU R                  R                  nUR                  S:X  a  SUR                  0nUR                  5       nOSUR                  0nUR                  " U4SU0UD6nU R                  (       d*  U R!                  U5      n[#        [        U5      5      Ul        U$ )a  
Perform groupby aggregation routine with the numba engine.

This routine mimics the data splitting routine of the DataSplitter class
to generate the indices of each group in the sorted data and then passes the
data and indices into a Numba jitted function.
r  r   r   ro  rT  )r   rX  rn  r  rO   r  generate_numba_agg_funcr\   r   ro  r   rK  r   r  r  r   rv  rX   rT  )rl   r   r  ru   rv   r  r  r  r  r  r  numba_agg_funcr
  rT  r  r  s                   rn   _aggregate_with_numbaGroupBy._aggregate_with_numba  s    ((YY!^T262B2B22F/lD!77
%m<
  

O
 
 **99>#TYY/M\\^F&5MEeE}E}}--c2C%c#h/CI
rq   rc   	dataframerd   )inputr   )include_groupsc               p  ^^^ Tn[         R                  " T5      mUT:w  a  [         R                  U   n[        XU5        [	        T[
        5      (       ab  [        U T5      (       aB  [        U T5      n[        U5      (       a  U" T0 TD6$ T(       d  T(       a  [        ST 35      eU$ [        ST S35      eT(       d  T(       a2  [        T5      (       a  [        T5      UUU4S j5       nO[        S5      eTnU(       d  U R                  XR                  5      $ [        SS 5          U R                  XR                  5      n	[	        U R                   ["        5      (       d  U R$                  cw  U R                  R&                  U R                  R&                  :w  aI  [(        R*                  " [,        R/                  [1        U 5      R2                  S5      [4        [7        5       S9  S S S 5        U	$ ! [         a'    U R                  XR                  5      s sS S S 5        $ f = f! , (       d  f       W	$ = f)	Nz"Cannot pass arguments to property z$apply func should be callable, not 'r'  c                   > T" U /TQ70 TD6$ ri   r   )gru   r   rv   s    rn   rw   GroupBy.apply.<locals>.f  s    3D3F33rq   z6func must be a callable if args or kwargs are suppliedzmode.chained_assignmentr  rl  )r   is_builtin_func_builtin_table_aliasr?   r   r   hasattrr   callabler   	TypeErrorr	   rz   r   r   r{   r   rZ   r   shaper   r   _apply_groupings_deprformatr   ry   DeprecationWarningr+   )
rl   r   r  ru   rv   	orig_funcaliasr  rw   r
  s
    ` ``     rn   r  GroupBy.apply  s    	""4(,,Y7E"4E:dC  tT""dD)C==///V$'I$%PQQ
  "FtfA NOOV~~t4 4 !L  A--a1J1JKK 5t<P33A7I7IJ"488V44/**00D4M4M4S4SSMM 5 < < J//! "4#3#5 =4   	P 11!5N5NOO1 =<	P =<4 s+   (H&*B>G22%H#H&"H##H&&
H5c                    U R                   R                  XU R                  5      u  pgUc  UnU R                  UUUU5      $ )a  
Apply function f in python space

Parameters
----------
f : callable
    Function to apply
data : Series or DataFrame
    Data to apply f to
not_indexed_same: bool, optional
    When specified, overrides the value of not_indexed_same. Apply behaves
    differently when the result index is equal to the input index, but
    this can be coincidental leading to value-dependent behavior.
is_transform : bool, default False
    Indicator for whether the function is actually a transform
    and should not have group keys prepended.
is_agg : bool, default False
    Indicator for whether the function is an aggregation. When the
    result is empty, we don't want to warn for this case.
    See _GroupBy._python_agg_general.

Returns
-------
Series or DataFrame
    data after applying f
)r   apply_groupwiser   r  )rl   rw   r  r8  r7  is_aggrY  mutateds           rn   rz   GroupBy._python_apply_general:  sL    F --77K#&((	
 	
rq   rG  )npfuncc               d    U R                   " SUUUUS.UD6nUR                  U R                  SS9$ )N)howaltnumeric_only	min_countrm   methodr   _cython_agg_general__finalize__r   )rl   r  r  r  r  rv   r
  s          rn   _agg_generalGroupBy._agg_generalh  sK     )) 
%	

 
 ""488I">>rq   c                   Uc   eUR                   S:X  a  [        USS9nOF[        UR                  UR                  S9nUR
                  S   S:X  d   eUR                  SS2S4   n U R                  R                  XTSS9nUR                  [        :X  a  UR                  [        SS9n[        XsS9$ ! [         a*  nS	U S
UR                   S3n	[        U5      " U	5      UeSnAff = f)zV
Fallback to pure-python aggregation if _cython_operation raises
NotImplementedError.
Nr   FrI  dtyper   T)preserve_dtypezagg function failed [how->z,dtype->])rX  )rX  rZ   rL   r"   r  r  r   r   
agg_series	Exceptionr   r   astyperY   )
rl   r  rY  rX  r  serr  
res_valuesr   r   s
             rn   _agg_py_fallbackGroupBy._agg_py_fallback{  s     ;;!e,C 6886<<8B 88A;!### ''!Q$-C
	*11#41PJ 99#**6*>J "*88  	*.se8CII;aHCs)C.c)	*s   (B3 3
C'=%C""C'c                  ^ ^^^^^
 T R                  UTS9m
SUU
UUUU 4S jjnT
R                  U5      nT R                  U5      nTS;   a  T R                  U5      nT R	                  U5      n	T R
                  S:X  a  U	R                  SS9n	U	$ )Nr  r   c                  >  TR                   R                  " SU T4TR                  S-
  TS.TD6nU$ ! [         a*    TS;   a  [	        U [
        5      (       a   OTb  TS;   a  e  Of = fTc   eTR                  TU TR                  TS9nU$ )N	aggregater   r   r  r   all)r   r  stdsem)rX  r  )r   _cython_operationrX  r  r   rF   r  )rY  r
  r  r  r  rv   r  rl   s     rn   
array_func/GroupBy._cython_agg_general.<locals>.array_func  s    88 Q' &  ' 	 .(Z-L-L[C+G$G %H	 ?"?**3TYYC*PFMs   /4 %A(
A('A(idxminidxmaxr   Fr  rY  r   r   r   )_get_data_to_aggregategrouped_reduce_wrap_agged_manager_wrap_idxmax_idxminr  r   infer_objects)rl   r  r  r  r  rv   r  new_mgrr  outr  s   ``` ``    @rn   r  GroupBy._cython_agg_general  s     **3*O	 	6 %%j1&&w/&&**3/C**3/99>###/C
rq   c                    [        U 5      eri   r  )rl   r  r  r   rv   s        rn   _cython_transformGroupBy._cython_transform  s     "$''rq   )enginer  c                  Un[         R                  " U5      =(       d    UnXa:w  a  [        XU5        [        U[        5      (       d  U R
                  " XU/UQ70 UD6$ U[        R                  ;  a  SU S3n[        U5      eU[        R                  ;   d  U[        R                  ;   a  Ub  X%S'   X5S'   [        X5      " U0 UD6$ [         R                  " U SS5         US;   a+  [        [        S   U5      nU R                  " US/UQ70 UD6nOUb  X%S'   X5S'   [        X5      " U0 UD6nS S S 5        U R!                  W5      $ ! , (       d  f       N= f)Nr'  z2' is not a valid function name for transform(name)r  r  r   Tr  )r   get_cython_funcr?   r   r   _transform_generalrN   transform_kernel_allowlistr   cythonized_kernelsr=  r   temp_setattrr   r   _idxmax_idxmin_wrap_transform_fast_result)	rl   r   r  r  ru   rv   r  r   r
  s	            rn   
_transformGroupBy._transform  s^    	""4(0D"4D9$$$**4XXQWXX888dVMNCS/!T,,,8S8S0S!#)x *7'4&777 !!$
D9 //(: ;TBD!00tMdMfMF)+1x(2?/$T0$A&AF : 33F;; :9s    AE
Ec                d   U R                   nU R                  R                  u  n  nUR                  U R                  R                  U R
                  SS9nU R                  R                  S:X  aG  [        R                  " UR                  U5      nUR                  XRR                  UR                  S9nU$ UR                  S:X  a  SOU R
                  nUR                  U   R                  U5      nUR!                  XxU40SSS9nUR#                  UR%                  U R
                  5      US9nU$ )	z'
Fast transform path for aggregations.
FrH  r   rT  r   r   T)
allow_dupsrI  r   )r   r   rN  rW  rK  r   r   rX  r<   take_ndrS  r  rT  r   rP  rV  _reindex_with_indexersre  rM  )	rl   r
  r   r  r`  r  outputr   new_axs	            rn   r  #GroupBy._wrap_transform_fast_result  s   
 '' MM,,	Q : :QVW88==A$$V^^S9C%%c%JF  q(1diiD [[&++C0F22}%$U 3 F __S]]499%=D_IFrq   c                x   [        U5      S:X  a  [        R                  " / SS9nO*[        R                  " [        R                  " U5      5      nU(       a%  U R
                  R                  XR                  S9nU$ [        R                  " [        U R
                  R                  5      [        S9nUR                  S5        SXAR                  [        5      '   [        R                  " U[        U R
                  R                   SS  5      S/-   5      R"                  nU R
                  R%                  U5      nU$ )Nr   int64r  r   FTr   )r   r   arrayr   concatenater{   rV  r   emptyrT  r   fillr  r  tiler	  r  r"   where)rl   r   r   filteredr^  s        rn   _apply_filterGroupBy._apply_filter%  s    w<1hhr1GggbnnW56G))..wYY.GH  88C 2 2 8 89FDIIe(,D$%774d&8&8&>&>qr&B!Cqc!IJLLD))//5Hrq   c           	        U R                   R                  u  p#n[        X$5      nX%   [        U5      pbUS:X  a#  [        R
                  " S[        R                  S9$ [        R                  SUSS USS :g  4   n[        R                  " [        R                  [        R                  " U5      S   U4   5      nU) R                  5       n	U(       a  U	[        R                  " X   U5      -  n	O3[        R                  " U	[        R                  USS S4      U5      U	-
  n	U R                   R                  (       aF  [        R                  " US:H  [        R                  U	R                  [        R                   SS95      n	OU	R                  [        R                  SS9n	[        R
                  " U[        R"                  S9n
[        R$                  " U[        R"                  S9X'   X   $ )	z
Parameters
----------
ascending : bool, default True
    If False, number in reverse, from length of group - 1 to 0.

Notes
-----
this is currently implementing sort=False
(though the default is sort=True) for groupby in general
r   r  TNrG  r   Fr  )r   rN  r[   r   r   r  r  r_diffnonzerocumsumrepeatr>  r   nanr  float64intparange)rl   	ascendingr  r`  r   sortercountrunrepr  revs              rn   _cumcount_arrayGroupBy._cumcount_array6  sj    --22'5[#c(UA:88ARXX..eeD#cr(c!"g--.ggbeeBJJsOA.567tmmo299SXs++C))Cc!"gtm 45s;cAC==''((3"9bffcjj%j.PQC**RXXE*2ChhuBGG,iiRWW5xrq   c                    [        U R                  [        5      (       a  U R                  R                  $ [        U R                  [        5      (       d   eU R                  R
                  $ ri   )r   r   rL   _constructor_slicedrZ   r  r   s    rn   _obj_1d_constructorGroupBy._obj_1d_constructor^  sL     dhh	**88///$((F++++xx$$$rq   rm   r   )see_alsoc                .   ^ U R                  SU4S jTS9$ )a  
Return True if any value in the group is truthful, else False.

Parameters
----------
skipna : bool, default True
    Flag to ignore nan values during truth testing.

Returns
-------
Series or DataFrame
    DataFrame or Series of boolean values, where a value is True if any element
    is True within its respective group, False otherwise.
%(see_also)s
Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([1, 2, 0], index=lst)
>>> ser
a    1
a    2
b    0
dtype: int64
>>> ser.groupby(level=0).any()
a     True
b    False
dtype: bool

For DataFrameGroupBy:

>>> data = [[1, 0, 3], [1, 0, 6], [7, 1, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["ostrich", "penguin", "parrot"])
>>> df
         a  b  c
ostrich  1  0  3
penguin  1  0  6
parrot   7  1  9
>>> df.groupby(by=["a"]).any()
       b      c
a
1  False   True
7   True   True
r   c                2   > [        U SS9R                  TS9$ NFr  )skipna)rZ   r   r4  r?  s    rn   r   GroupBy.any.<locals>.<lambda>      &/3363Brq   r  r?  r  rl   r?  s    `rn   r   GroupBy.anyg  s'    d ''B ( 
 	
rq   c                .   ^ U R                  SU4S jTS9$ )a  
Return True if all values in the group are truthful, else False.

Parameters
----------
skipna : bool, default True
    Flag to ignore nan values during truth testing.

Returns
-------
Series or DataFrame
    DataFrame or Series of boolean values, where a value is True if all elements
    are True within its respective group, False otherwise.
%(see_also)s
Examples
--------

For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([1, 2, 0], index=lst)
>>> ser
a    1
a    2
b    0
dtype: int64
>>> ser.groupby(level=0).all()
a     True
b    False
dtype: bool

For DataFrameGroupBy:

>>> data = [[1, 0, 3], [1, 5, 6], [7, 8, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["ostrich", "penguin", "parrot"])
>>> df
         a  b  c
ostrich  1  0  3
penguin  1  5  6
parrot   7  8  9
>>> df.groupby(by=["a"]).all()
       b      c
a
1  False   True
7   True   True
r  c                2   > [        U SS9R                  TS9$ r>  )rZ   r  r@  s    rn   r   GroupBy.all.<locals>.<lambda>  rB  rq   rC  rD  rE  s    `rn   r  GroupBy.all  s'    f ''B ( 
 	
rq   c                  ^^^	^
 U R                  5       nU R                  R                  u  mnm
TS:g  m	UR                  S:H  mS	UUU	U
4S jjnUR	                  U5      nU R                  U5      n[        R                  " U SS5         U R                  U5      nSSS5        U R                  WSS9$ ! , (       d  f       N= f)
a  
Compute count of group, excluding missing values.

Returns
-------
Series or DataFrame
    Count of values within each group.
%(see_also)s
Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([1, 2, np.nan], index=lst)
>>> ser
a    1.0
a    2.0
b    NaN
dtype: float64
>>> ser.groupby(level=0).count()
a    2
b    0
dtype: int64

For DataFrameGroupBy:

>>> data = [[1, np.nan, 3], [1, np.nan, 6], [7, 8, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["cow", "horse", "bull"])
>>> df
        a         b     c
cow     1       NaN     3
horse   1       NaN     6
bull    7       8.0     9
>>> df.groupby("a").count()
    b   c
a
1   0   2
7   1   1

For Resampler:

>>> 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
rG  r   c                n  > U R                   S:X  a   T[        U 5      R                  SS5      ) -  nOT[        U 5      ) -  n[        R                  " UTTS9n[        U [        5      (       a;  [        US   [        R                  " UR                  S   [        R                  S9S9$ [        U [        5      (       aF  [        U R                  [        5      (       d'  [        S5      n[!        U 5      R#                  US   US9$ T(       a,  UR                   S:X  d   eUR                  S   S:X  d   eUS   $ U$ )	Nr   rG  )r]  max_binr   r  )r^  zint64[pyarrow]r  )rX  r9   reshaper   count_level_2dr   rA   rE   r   zerosr  bool_r@   r  rG   r8   r   _from_sequence)bvaluesmaskedcountedr  r  	is_seriesr^  r   s       rn   hfuncGroupBy.count.<locals>.hfunc	  s   ||q g!6!6q"!= ==g.((WMG'?33#AJRXXgmmA.>bhh%O  G%899*{C C %%56G}33GAJe3LL||q(((}}Q'1,,,qz!Nrq   r   TNr   
fill_value)rS  r   r   r   )
r  r   rN  rX  r  r  r   r  r  r  )rl   r  r`  rW  r   new_objr
  r  rV  r^  r   s          @@@@rn   r0  GroupBy.count  s    v **,--22QbyIIN		 	0 %%e,**73 dJ511':F 6 ##Fq#99 65s   B22
C c                   ^ [        U5      (       a&  SSKJn  U R                  U[        R
                  USS9$ U R                  SU4S jTS9nUR                  U R                  SS9$ )	a  
Compute mean of groups, excluding missing values.

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

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or globally setting
      ``compute.use_numba``

    .. versionadded:: 1.4.0

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{{'nopython': True, 'nogil': False, 'parallel': False}}``

    .. versionadded:: 1.4.0

Returns
-------
pandas.Series or pandas.DataFrame
%(see_also)s
Examples
--------
>>> df = pd.DataFrame({'A': [1, 1, 2, 1, 2],
...                    'B': [np.nan, 2, 3, 4, 5],
...                    'C': [1, 2, 1, 1, 2]}, columns=['A', 'B', 'C'])

Groupby one column and return the mean of the remaining columns in
each group.

>>> df.groupby('A').mean()
     B         C
A
1  3.0  1.333333
2  4.0  1.500000

Groupby two columns and return the mean of the remaining column.

>>> df.groupby(['A', 'B']).mean()
         C
A B
1 2.0  2.0
  4.0  1.0
2 3.0  1.0
  5.0  2.0

Groupby one column and return the mean of only particular column in
the group.

>>> df.groupby('A')['B'].mean()
A
1    3.0
2    4.0
Name: B, dtype: float64
r   )grouped_meanmin_periodsmeanc                2   > [        U SS9R                  TS9$ NFr  )r  )rZ   ra  r4  r  s    rn   r   GroupBy.mean.<locals>.<lambda>	  s    fQU388l8Srq   r  r  rm   r  )	r]   pandas.core._numba.kernelsr^  r  r>   float_dtype_mappingr  r  r   )rl   r  r  r  r^  r
  s    `    rn   ra  GroupBy.mean=	  sz    Z 6""?**,,	 +   --S) . F
 &&txx	&BBrq   c                b   ^ U R                  SU4S jTS9nUR                  U R                  S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.

Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'a', 'b', 'b', 'b']
>>> ser = pd.Series([7, 2, 8, 4, 3, 3], index=lst)
>>> ser
a     7
a     2
a     8
b     4
b     3
b     3
dtype: int64
>>> ser.groupby(level=0).median()
a    7.0
b    3.0
dtype: float64

For DataFrameGroupBy:

>>> data = {'a': [1, 3, 5, 7, 7, 8, 3], 'b': [1, 4, 8, 4, 4, 2, 1]}
>>> df = pd.DataFrame(data, index=['dog', 'dog', 'dog',
...                   'mouse', 'mouse', 'mouse', 'mouse'])
>>> df
         a  b
  dog    1  1
  dog    3  4
  dog    5  8
mouse    7  4
mouse    7  4
mouse    8  2
mouse    3  1
>>> df.groupby(level=0).median()
         a    b
dog    3.0  4.0
mouse  7.0  3.0

For Resampler:

>>> 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
medianc                2   > [        U SS9R                  TS9$ rc  )rZ   rk  rd  s    rn   r    GroupBy.median.<locals>.<lambda>	  s    &/66L6Qrq   rf  rm   r  r  )rl   r  r
  s    ` rn   rk  GroupBy.median	  s@    R ))Q% * 

 ""488I">>rq   r   c           
        ^ [        U5      (       a;  SSKJn  [        R                  " U R                  U[        R                  USTS95      $ U R                  SU4S jUTS9$ )a  
Compute standard deviation of groups, excluding missing values.

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

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

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or globally setting
      ``compute.use_numba``

    .. versionadded:: 1.4.0

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{{'nopython': True, 'nogil': False, 'parallel': False}}``

    .. versionadded:: 1.4.0

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

    .. versionadded:: 1.5.0

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

Returns
-------
Series or DataFrame
    Standard deviation of values within each group.
%(see_also)s
Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'a', 'b', 'b', 'b']
>>> ser = pd.Series([7, 2, 8, 4, 3, 3], index=lst)
>>> ser
a     7
a     2
a     8
b     4
b     3
b     3
dtype: int64
>>> ser.groupby(level=0).std()
a    3.21455
b    0.57735
dtype: float64

For DataFrameGroupBy:

>>> data = {'a': [1, 3, 5, 7, 7, 8, 3], 'b': [1, 4, 8, 4, 4, 2, 1]}
>>> df = pd.DataFrame(data, index=['dog', 'dog', 'dog',
...                   'mouse', 'mouse', 'mouse', 'mouse'])
>>> df
         a  b
  dog    1  1
  dog    3  4
  dog    5  8
mouse    7  4
mouse    7  4
mouse    8  2
mouse    3  1
>>> df.groupby(level=0).std()
              a         b
dog    2.000000  3.511885
mouse  2.217356  1.500000
r   grouped_varr`  ddofr  c                2   > [        U SS9R                  TS9$ NFr  )rs  )rZ   r  r4  rs  s    rn   r   GroupBy.std.<locals>.<lambda>S
      fQU377T7Brq   r  r  rs  )	r]   rg  rq  r   sqrtr  r>   rh  r  rl   rs  r  r  r  rq  s    `    rn   r  GroupBy.std	  ss    r 6"">77''00! ! (   ++B)	 ,  rq   c                   ^ [        U5      (       a'  SSKJn  U R                  U[        R
                  USTS9$ U R                  SU4S jUTS9$ )a  
Compute variance of groups, excluding missing values.

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

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

engine : str, default None
    * ``'cython'`` : Runs the operation through C-extensions from cython.
    * ``'numba'`` : Runs the operation through JIT compiled code from numba.
    * ``None`` : Defaults to ``'cython'`` or globally setting
      ``compute.use_numba``

    .. versionadded:: 1.4.0

engine_kwargs : dict, default None
    * For ``'cython'`` engine, there are no accepted ``engine_kwargs``
    * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil``
      and ``parallel`` dictionary keys. The values must either be ``True`` or
      ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is
      ``{{'nopython': True, 'nogil': False, 'parallel': False}}``

    .. versionadded:: 1.4.0

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

    .. versionadded:: 1.5.0

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

Returns
-------
Series or DataFrame
    Variance of values within each group.
%(see_also)s
Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'a', 'b', 'b', 'b']
>>> ser = pd.Series([7, 2, 8, 4, 3, 3], index=lst)
>>> ser
a     7
a     2
a     8
b     4
b     3
b     3
dtype: int64
>>> ser.groupby(level=0).var()
a    10.333333
b     0.333333
dtype: float64

For DataFrameGroupBy:

>>> data = {'a': [1, 3, 5, 7, 7, 8, 3], 'b': [1, 4, 8, 4, 4, 2, 1]}
>>> df = pd.DataFrame(data, index=['dog', 'dog', 'dog',
...                   'mouse', 'mouse', 'mouse', 'mouse'])
>>> df
         a  b
  dog    1  1
  dog    3  4
  dog    5  8
mouse    7  4
mouse    7  4
mouse    8  2
mouse    3  1
>>> df.groupby(level=0).var()
              a          b
dog    4.000000  12.333333
mouse  4.916667   2.250000
r   rp  rr  varc                2   > [        U SS9R                  TS9$ ru  )rZ   r~  rv  s    rn   r   GroupBy.var.<locals>.<lambda>
  rx  rq   ry  )r]   rg  rq  r  r>   rh  r  r{  s    `    rn   r~  GroupBy.varX
  sg    r 6"">**,, +   ++B)	 ,  rq   c           
     $
   U R                   S:X  a  [        S5      eU(       a  SOSnU R                  nU R                  nU R                  R
                   V	s1 s H!  oR                  (       d  M  U	R                  iM#     n
n	[        U[        5      (       a  UR                  nX;   a  / OU/nO[        UR                  5      nUbJ  [        U5      nU[        U
5      -  nU(       a  [        SU S35      eX-
  nU(       a  [        SU S35      eOUn[        UR                  5       VVs/ s H'  u  nnX;  d  M  X;   d  M  UR                  SS2U4   PM)     nnn[        U R                  R
                  5      nU HA  n[!        UUU R                   U R"                  S	US
9u  n  nU[        UR
                  5      -  nMC     UR%                  UU R"                  U R&                  U R(                  S9n[+        [        UR-                  5       5      nUUl        [/        S U 5       5      (       a\  U Vs/ s H  nUR0                  PM     nn[2        R4                  " UU Vs/ s H  nUR                  PM     snS9nUR7                  USS9nU(       a  UR9                  USS9nU R"                  (       a  UR:                  R<                  n[?        [A        U5      5      UR:                  l        [        [?        [A        U R                  R
                  5      5      5      nURC                  US	S9nUUR:                  l        U(       a  [        [?        [A        U R                  R
                  5      UR:                  RD                  5      5      nUR%                  UR:                  RG                  U5      U R"                  U R(                  S	S9RI                  S5      nUU-  nURK                  S5      nU RL                  (       a  UnOUR:                  n [N        RP                  " U R<                  5      n!UU!;   a  [        SU S35      eUUl        U RS                  [?        [A        U!5      5      5      Ul        URU                  5       n"U R                  R
                  S   R                  R                  RV                  n#[Y        U!U#S9R[                  [A        U!5      U5      n$U$U"l        U"nUR]                  U R                  SS9$ s  sn	f s  snnf s  snf s  snf )z
Shared implementation of value_counts for SeriesGroupBy and DataFrameGroupBy.

SeriesGroupBy additionally supports a bins argument. See the docstring of
DataFrameGroupBy.value_counts for a description of arguments.
r   z1DataFrameGroupBy.value_counts only handles axis=0
proportionr0  NzKeys z0 in subset cannot be in the groupby column keys.z) in subset do not exist in the DataFrame.F)r   r   r   r   r   )r   r   r   c              3     #    U  H=  n[        UR                  [        [        45      =(       a    UR                  (       + v   M?     g 7fri   )r   grouping_vectorrB   rT   	_observed)r   groupings     rn   r   (GroupBy._value_counts.<locals>.<genexpr>  sB      
 & x//+?O1PQ '&&&'%s   AAr   r   rY  stable)r.  kind)r   sort_remaining)r   r   r   sumg        zColumn label 'z' is duplicate of result columnr  value_countsr  )/r   r  r   r   r   r!  rr  r   r   rZ   setro  r   	enumerater   r	  rQ   r   rm   r   r   r   sizer   _result_indexrV   from_productrW  sort_valuesrT  r   rL  r   rg  nlevels	droplevel	transformr2  r   r   fill_missing_names	set_namesreset_indexr  rU   rs  r  )%rl   subset	normalizer   r.  r   r   r  r   r  in_axis_names_namer   unique_cols	subsettedclashingdoesnt_existidxr!  r   r   r`  gbresult_seriesr  levels_listmulti_indexr   index_levelrF  indexed_group_sizer
  rT  ro  result_frame
orig_dtypecolss%                                        rn   _value_countsGroupBy._value_counts
  s    99>%C   )|gXX'' +/--*A*A
*AhEUEUMHMM*A 	 
 c6""HHE/2cUDckk*K!K	$s='99$z *3 3   )6$~ .2 3    (	
 #,CKK"8 #9JC- !272D !C "8   001	C'YYYYMGQ g//00I  ZZ]];;	  
 VRWWY/!  
 &
 
 

 ;DD)$4--)KD$11)#D)$DII)#DK *11+!1LM)55#( 6 M 99!''--E(-c%j(9M%uS)@)@%ABCK)44!% 5 M ).M% c$--112M4G4G4O4OPF "/!6!6##--f5YY{{ "7 " i  //M *005M =="F "''E,,U[[9Gw >$7V!WXX!%M"'//%G2E"FM(446L00377??EEJ
3::3w<ND#'L !F""488N"CCm
2H E#Ds*   S=/S=)T9T T0TT
c                .  ^ U(       ax  U R                   R                  S:X  a^  [        U R                   R                  5      (       d:  [	        [        U 5      R                   SU SU R                   R                   35      eU R                  SU4S jUTS9$ )a[  
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.

    .. versionadded:: 1.5.0

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

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

Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'b', 'b']
>>> ser = pd.Series([5, 10, 8, 14], index=lst)
>>> ser
a     5
a    10
b     8
b    14
dtype: int64
>>> ser.groupby(level=0).sem()
a    2.5
b    3.0
dtype: float64

For DataFrameGroupBy:

>>> data = [[1, 12, 11], [1, 15, 2], [2, 5, 8], [2, 6, 12]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["tuna", "salmon", "catfish", "goldfish"])
>>> df
           a   b   c
    tuna   1  12  11
  salmon   1  15   2
 catfish   2   5   8
goldfish   2   6  12
>>> df.groupby("a").sem()
      b  c
a
1    1.5  4.5
2    0.5  2.0

For Resampler:

>>> 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
r   z.sem called with numeric_only=z and dtype r  c                2   > [        U SS9R                  TS9$ ru  )rZ   r  rv  s    rn   r   GroupBy.sem.<locals>.<lambda>  s    &/333>rq   ry  )r   rX  r4   r  r  r   ry   r  )rl   rs  r  s    ` rn   r  GroupBy.semS  s    T DHHMMQ.7G7W7W:&&' (  ,~[8HJ  ''>%	 ( 
 	
rq   c                   U R                   R                  5       nSn[        U R                  [        5      (       a  [        U R                  R
                  [        5      (       a[  [        U R                  R
                  [        5      (       a  SnOZ[        U R                  R
                  [        5      (       a  SnO.SnO+[        U R                  R
                  [        5      (       a  Sn[        U R                  [        5      (       a$  U R                  XR                  R                  S9nOU R                  U5      nUb  UR                  SSSSUS9n[        R                  " U SS5         U R                  US	S
9nSSS5        U R                   (       d  UR#                  S5      R%                  5       nU$ ! , (       d  f       N@= f)a  
Compute group sizes.

Returns
-------
DataFrame or Series
    Number of rows in each group as a Series if as_index is True
    or a DataFrame if as_index is False.
%(see_also)s
Examples
--------

For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([1, 2, 3], index=lst)
>>> ser
a     1
a     2
b     3
dtype: int64
>>> ser.groupby(level=0).size()
a    2
b    1
dtype: int64

>>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["owl", "toucan", "eagle"])
>>> df
        a  b  c
owl     1  2  3
toucan  1  5  6
eagle   7  8  9
>>> df.groupby("a").size()
a
1    2
7    1
dtype: int64

For Resampler:

>>> 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
Nnumpy_nullablepyarrowr:  F)r  convert_stringconvert_booleanconvert_floatingdtype_backendr   Tr   rY  r  )r   r  r   r   rZ   r  r@   rI   rH   rA   r8  r   convert_dtypesr   r  r  r   renamer  )rl   r
  r  s      rn   r  GroupBy.size  s`   t ##%EIdhh''$((..*=>>dhhnn.LMM$(M0@AA$4M$-MDHHNNO<< 0 dhh''--f88==-IF--f5F$**#$ %!&+ + F dJ5 ))&Q)?F 6 }} ]]6*668F 65s   -F88
Gr  a          For SeriesGroupBy:

        >>> lst = ['a', 'a', 'b', 'b']
        >>> ser = pd.Series([1, 2, 3, 4], index=lst)
        >>> ser
        a    1
        a    2
        b    3
        b    4
        dtype: int64
        >>> ser.groupby(level=0).sum()
        a    3
        b    7
        dtype: int64

        For DataFrameGroupBy:

        >>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]]
        >>> df = pd.DataFrame(data, columns=["a", "b", "c"],
        ...                   index=["tiger", "leopard", "cheetah", "lion"])
        >>> df
                  a  b  c
          tiger   1  8  2
        leopard   1  2  5
        cheetah   2  5  8
           lion   2  6  9
        >>> df.groupby("a").sum()
             b   c
        a
        1   10   7
        2   11  17)fnamenomceekexamplec                2   [        U5      (       a&  SSKJn  U R                  U[        R
                  UUS9$ [        R                  " U SS5         U R                  UUS[        R                  S9nS S S 5        U R                  WSS9$ ! , (       d  f       N= f)	Nr   )grouped_sumr_  r   Tr  r  r  r  r  rY  )r]   rg  r  r  r>   default_dtype_mappingr   r  r  r   r  r  )rl   r  r  r  r  r  r
  s          rn   r  GroupBy.sum
  s    d 6"">**..%	 +   !!$
D9**!-'66	 +  : ''1'== :9s   !B
Bproda          For SeriesGroupBy:

        >>> lst = ['a', 'a', 'b', 'b']
        >>> ser = pd.Series([1, 2, 3, 4], index=lst)
        >>> ser
        a    1
        a    2
        b    3
        b    4
        dtype: int64
        >>> ser.groupby(level=0).prod()
        a    2
        b   12
        dtype: int64

        For DataFrameGroupBy:

        >>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]]
        >>> df = pd.DataFrame(data, columns=["a", "b", "c"],
        ...                   index=["tiger", "leopard", "cheetah", "lion"])
        >>> df
                  a  b  c
          tiger   1  8  2
        leopard   1  2  5
        cheetah   2  5  8
           lion   2  6  9
        >>> df.groupby("a").prod()
             b    c
        a
        1   16   10
        2   30   72)r  r  r  r  c                @    U R                  XS[        R                  S9$ )Nr  r  )r  r   r  )rl   r  r  s      rn   r  GroupBy.prodS  s+    T   %&QSQXQX ! 
 	
rq   mina          For SeriesGroupBy:

        >>> lst = ['a', 'a', 'b', 'b']
        >>> ser = pd.Series([1, 2, 3, 4], index=lst)
        >>> ser
        a    1
        a    2
        b    3
        b    4
        dtype: int64
        >>> ser.groupby(level=0).min()
        a    1
        b    3
        dtype: int64

        For DataFrameGroupBy:

        >>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]]
        >>> df = pd.DataFrame(data, columns=["a", "b", "c"],
        ...                   index=["tiger", "leopard", "cheetah", "lion"])
        >>> df
                  a  b  c
          tiger   1  8  2
        leopard   1  2  5
        cheetah   2  5  8
           lion   2  6  9
        >>> df.groupby("a").min()
            b  c
        a
        1   2  2
        2   5  8c                    [        U5      (       a'  SSKJn  U R                  U[        R
                  UUSS9$ U R                  UUS[        R                  S9$ )Nr   grouped_min_maxFr`  is_maxr  r  )	r]   rg  r  r  r>   identity_dtype_mappingr  r   r  rl   r  r  r  r  r  s         rn   r  GroupBy.min  sj    d 6""B**//% +   $$)#vv	 %  rq   maxa          For SeriesGroupBy:

        >>> lst = ['a', 'a', 'b', 'b']
        >>> ser = pd.Series([1, 2, 3, 4], index=lst)
        >>> ser
        a    1
        a    2
        b    3
        b    4
        dtype: int64
        >>> ser.groupby(level=0).max()
        a    2
        b    4
        dtype: int64

        For DataFrameGroupBy:

        >>> data = [[1, 8, 2], [1, 2, 5], [2, 5, 8], [2, 6, 9]]
        >>> df = pd.DataFrame(data, columns=["a", "b", "c"],
        ...                   index=["tiger", "leopard", "cheetah", "lion"])
        >>> df
                  a  b  c
          tiger   1  8  2
        leopard   1  2  5
        cheetah   2  5  8
           lion   2  6  9
        >>> df.groupby("a").max()
            b  c
        a
        1   8  5
        2   6  9c                    [        U5      (       a'  SSKJn  U R                  U[        R
                  UUSS9$ U R                  UUS[        R                  S9$ )Nr   r  Tr  r  r  )	r]   rg  r  r  r>   r  r  r   r  r  s         rn   r  GroupBy.max  sj    d 6""B**//% +   $$)#vv	 %  rq   c                6    SSS jjnU R                  UUSUUS9$ )a=  
Compute the first entry of each column within each group.

Defaults to skipping NA elements.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.
min_count : int, default -1
    The required number of valid values to perform the operation. If fewer
    than ``min_count`` valid values are present the result will be NA.
skipna : bool, default True
    Exclude NA/null values. If an entire row/column is NA, the result
    will be NA.

    .. versionadded:: 2.2.1

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

See Also
--------
DataFrame.groupby : Apply a function groupby to each row or column of a
    DataFrame.
pandas.core.groupby.DataFrameGroupBy.last : Compute the last non-null entry
    of each column.
pandas.core.groupby.DataFrameGroupBy.nth : Take the nth row from each group.

Examples
--------
>>> df = pd.DataFrame(dict(A=[1, 1, 3], B=[None, 5, 6], C=[1, 2, 3],
...                        D=['3/11/2000', '3/12/2000', '3/13/2000']))
>>> df['D'] = pd.to_datetime(df['D'])
>>> df.groupby("A").first()
     B  C          D
A
1  5.0  1 2000-03-11
3  6.0  3 2000-03-13
>>> df.groupby("A").first(min_count=2)
    B    C          D
A
1 NaN  1.0 2000-03-11
3 NaN  NaN        NaT
>>> df.groupby("A").first(numeric_only=True)
     B  C
A
1  5.0  1
3  6.0  3
c                    SS jn[        U [        5      (       a  U R                  X!S9$ [        U [        5      (       a  U" U 5      $ [	        [        U 5      5      e)Nc                    U R                   [        U R                   5         n[        U5      (       d   U R                   R                  R                  $ US   $ )z-Helper function for first item that isn't NA.r   r  r;   r   r  na_valuer4  arrs     rn   first2GroupBy.first.<locals>.first_compat.<locals>.firstC  s>    ggeAGGn-3xx77==1111vrq   r   r4  rZ   r   rL   r  rZ   r  r   )r   r   r  s      rn   first_compat#GroupBy.first.<locals>.first_compatB  sM     #y))yyy22C((Sz!S	**rq   r  r  r  r  r  r?  r   r   r   r   r   r  )rl   r  r  r?  r  s        rn   r  GroupBy.first	  s1    r	+   % ! 
 	
rq   c                6    SSS jjnU R                  UUSUUS9$ )aC  
Compute the last entry of each column within each group.

Defaults to skipping NA elements.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns. If None, will attempt to use
    everything, then use only numeric data.
min_count : int, default -1
    The required number of valid values to perform the operation. If fewer
    than ``min_count`` valid values are present the result will be NA.
skipna : bool, default True
    Exclude NA/null values. If an entire row/column is NA, the result
    will be NA.

    .. versionadded:: 2.2.1

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

See Also
--------
DataFrame.groupby : Apply a function groupby to each row or column of a
    DataFrame.
pandas.core.groupby.DataFrameGroupBy.first : Compute the first non-null entry
    of each column.
pandas.core.groupby.DataFrameGroupBy.nth : Take the nth row from each group.

Examples
--------
>>> df = pd.DataFrame(dict(A=[1, 1, 3], B=[5, None, 6], C=[1, 2, 3]))
>>> df.groupby("A").last()
     B  C
A
1  5.0  2
3  6.0  3
c                    SS jn[        U [        5      (       a  U R                  X!S9$ [        U [        5      (       a  U" U 5      $ [	        [        U 5      5      e)Nc                    U R                   [        U R                   5         n[        U5      (       d   U R                   R                  R                  $ US   $ )z,Helper function for last item that isn't NA.rG  r  r  s     rn   last/GroupBy.last.<locals>.last_compat.<locals>.last  s>    ggeAGGn-3xx77==1112wrq   r   r  r  )r   r   r  s      rn   last_compat!GroupBy.last.<locals>.last_compat  sM     #y))yyy11C((Cy S	**rq   r  r  r  r  r  )rl   r  r  r?  r  s        rn   r  GroupBy.lastY  s1    \	+   % ! 
 	
rq   c                   U R                   R                  S:X  a  U R                  n[        UR                  5      nU(       d  [        S5      eU R                  R                  SUR                  SSSS9n/ SQnU R                   R                  X0R                  R                  US	9nU R                  U5      $ U R                  S
 5      nU$ )a  
Compute open, high, low and close values of a group, excluding missing values.

For multiple groupings, the result index will be a MultiIndex

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

Examples
--------

For SeriesGroupBy:

>>> lst = ['SPX', 'CAC', 'SPX', 'CAC', 'SPX', 'CAC', 'SPX', 'CAC',]
>>> ser = pd.Series([3.4, 9.0, 7.2, 5.2, 8.8, 9.4, 0.1, 0.5], index=lst)
>>> ser
SPX     3.4
CAC     9.0
SPX     7.2
CAC     5.2
SPX     8.8
CAC     9.4
SPX     0.1
CAC     0.5
dtype: float64
>>> ser.groupby(level=0).ohlc()
     open  high  low  close
CAC   9.0   9.4  0.5    0.5
SPX   3.4   8.8  0.1    0.1

For DataFrameGroupBy:

>>> data = {2022: [1.2, 2.3, 8.9, 4.5, 4.4, 3, 2 , 1],
...         2023: [3.4, 9.0, 7.2, 5.2, 8.8, 9.4, 8.2, 1.0]}
>>> df = pd.DataFrame(data, index=['SPX', 'CAC', 'SPX', 'CAC',
...                   'SPX', 'CAC', 'SPX', 'CAC'])
>>> df
     2022  2023
SPX   1.2   3.4
CAC   2.3   9.0
SPX   8.9   7.2
CAC   4.5   5.2
SPX   4.4   8.8
CAC   3.0   9.4
SPX   2.0   8.2
CAC   1.0   1.0
>>> df.groupby(level=0).ohlc()
    2022                 2023
    open high  low close open high  low close
CAC  2.3  4.5  1.0   1.0  9.0  9.4  1.0   1.0
SPX  1.2  8.9  1.2   2.0  3.4  8.8  3.4   8.2

For Resampler:

>>> 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   zNo numeric types to aggregater  ohlcr   rG  r  )openhighlowclose)rT  ro  c                "    U R                  5       $ ri   )r  )sgbs    rn   r   GroupBy.ohlc.<locals>.<lambda>  s
    CHHJrq   )r   rX  r{   r4   r  r&   r   r  rS  _constructor_expanddimrK  r  _apply_to_column_groupbys)rl   r   
is_numericr  	agg_namesr
  s         rn   r  GroupBy.ohlc  s    L 88==A$$C)#))4J ?@@88S[[&qB 9 J 9IXX44--"<"<i 5 F ''////0FGrq   c                X  ^^^ U R                   n[        U5      S:X  a[  UR                  TTTS9nUR                  S:X  a  UnOUR	                  5       nUR                  5       R                  R                  S S $ [        R                  " U SS5         U R                  UUU4S jUSS9nS S S 5        U R                  S:X  a  WR                  $ WR	                  5       nU R                  (       d*  U R                  U5      n[        [        U5      5      Ul        U$ ! , (       d  f       Nw= f)Nr   percentilesincludeexcluder   r   Tc                &   > U R                  TTTS9$ )Nr   )describe)r4  r  r  r  s    rn   r   "GroupBy.describe.<locals>.<lambda>  s    !** +Wg % rq   r8  )r   r   r  rX  unstackrn  r"   r   r   r  rz   r   r   rv  rX   rT  )rl   r  r  r  r   	describedr
  s    ```   rn   r  GroupBy.describe  s    ''s8q='' % I xx1}""**,??$&&++BQ//dJ5// !% 0 F 6 99>88O !}}008F(V5FL# 65s   D
D)c               *    SSK Jn  U" X/UQ7SU0UD6$ )aS  
Provide resampling when using a TimeGrouper.

Given a grouper, the function resamples it according to a string
"string" -> "frequency".

See the :ref:`frequency aliases <timeseries.offset_aliases>`
documentation for more details.

Parameters
----------
rule : str or DateOffset
    The offset string or object representing target grouper conversion.
*args
    Possible arguments are `how`, `fill_method`, `limit`, `kind` and
    `on`, and other arguments of `TimeGrouper`.
include_groups : bool, default True
    When True, will attempt to include the groupings in the operation in
    the case that they are columns of the DataFrame. If this raises a
    TypeError, the result will be computed with the groupings excluded.
    When False, the groupings will be excluded when applying ``func``.

    .. versionadded:: 2.2.0

    .. deprecated:: 2.2.0

       Setting include_groups to True is deprecated. Only the value
       False will be allowed in a future version of pandas.

**kwargs
    Possible arguments are `how`, `fill_method`, `limit`, `kind` and
    `on`, and other arguments of `TimeGrouper`.

Returns
-------
pandas.api.typing.DatetimeIndexResamplerGroupby,
pandas.api.typing.PeriodIndexResamplerGroupby, or
pandas.api.typing.TimedeltaIndexResamplerGroupby
    Return a new groupby object, with type depending on the data
    being resampled.

See Also
--------
Grouper : Specify a frequency to resample with when
    grouping by a key.
DatetimeIndex.resample : Frequency conversion and resampling of
    time series.

Examples
--------
>>> idx = pd.date_range('1/1/2000', periods=4, freq='min')
>>> df = pd.DataFrame(data=4 * [range(2)],
...                   index=idx,
...                   columns=['a', 'b'])
>>> df.iloc[2, 0] = 5
>>> df
                    a  b
2000-01-01 00:00:00  0  1
2000-01-01 00:01:00  0  1
2000-01-01 00:02:00  5  1
2000-01-01 00:03:00  0  1

Downsample the DataFrame into 3 minute bins and sum the values of
the timestamps falling into a bin.

>>> df.groupby('a').resample('3min', include_groups=False).sum()
                         b
a
0   2000-01-01 00:00:00  2
    2000-01-01 00:03:00  1
5   2000-01-01 00:00:00  1

Upsample the series into 30 second bins.

>>> df.groupby('a').resample('30s', include_groups=False).sum()
                    b
a
0   2000-01-01 00:00:00  1
    2000-01-01 00:00:30  0
    2000-01-01 00:01:00  1
    2000-01-01 00:01:30  0
    2000-01-01 00:02:00  0
    2000-01-01 00:02:30  0
    2000-01-01 00:03:00  1
5   2000-01-01 00:02:00  1

Resample by month. Values are assigned to the month of the period.

>>> df.groupby('a').resample('ME', include_groups=False).sum()
            b
a
0   2000-01-31  3
5   2000-01-31  1

Downsample the series into 3 minute bins as above, but close the right
side of the bin interval.

>>> (
...     df.groupby('a')
...     .resample('3min', closed='right', include_groups=False)
...     .sum()
... )
                         b
a
0   1999-12-31 23:57:00  1
    2000-01-01 00:00:00  2
5   2000-01-01 00:00:00  1

Downsample the series into 3 minute bins and close the right side of
the bin interval, but label each bin using the right edge instead of
the left.

>>> (
...     df.groupby('a')
...     .resample('3min', closed='right', label='right', include_groups=False)
...     .sum()
... )
                         b
a
0   2000-01-01 00:00:00  1
    2000-01-01 00:03:00  2
5   2000-01-01 00:03:00  1
r   )get_resampler_for_groupingr  )pandas.core.resampler  )rl   ruler  ru   rv   r  s         rn   resampleGroupBy.resample  s3    z 	D *

.<
@F
 	
rq   c                h    SSK Jn  U" U R                  /UQ7U R                  U R                  S.UD6$ )a  
Return a rolling grouper, providing rolling functionality per group.

Parameters
----------
window : int, timedelta, str, offset, or BaseIndexer subclass
    Size of the moving window.

    If an integer, the fixed number of observations used for
    each window.

    If a timedelta, str, or offset, the time period of each window. Each
    window will be a variable sized based on the observations included in
    the time-period. This is only valid for datetimelike indexes.
    To learn more about the offsets & frequency strings, please see `this link
    <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`__.

    If a BaseIndexer subclass, the window boundaries
    based on the defined ``get_window_bounds`` method. Additional rolling
    keyword arguments, namely ``min_periods``, ``center``, ``closed`` and
    ``step`` will be passed to ``get_window_bounds``.

min_periods : int, default None
    Minimum number of observations in window required to have a value;
    otherwise, result is ``np.nan``.

    For a window that is specified by an offset,
    ``min_periods`` will default to 1.

    For a window that is specified by an integer, ``min_periods`` will default
    to the size of the window.

center : bool, default False
    If False, set the window labels as the right edge of the window index.

    If True, set the window labels as the center of the window index.

win_type : str, default None
    If ``None``, all points are evenly weighted.

    If a string, it must be a valid `scipy.signal window function
    <https://docs.scipy.org/doc/scipy/reference/signal.windows.html#module-scipy.signal.windows>`__.

    Certain Scipy window types require additional parameters to be passed
    in the aggregation function. The additional parameters must match
    the keywords specified in the Scipy window type method signature.

on : str, optional
    For a DataFrame, a column label or Index level on which
    to calculate the rolling window, rather than the DataFrame's index.

    Provided integer column is ignored and excluded from result since
    an integer index is not used to calculate the rolling window.

axis : int or str, default 0
    If ``0`` or ``'index'``, roll across the rows.

    If ``1`` or ``'columns'``, roll across the columns.

    For `Series` this parameter is unused and defaults to 0.

closed : str, default None
    If ``'right'``, the first point in the window is excluded from calculations.

    If ``'left'``, the last point in the window is excluded from calculations.

    If ``'both'``, no points in the window are excluded from calculations.

    If ``'neither'``, the first and last points in the window are excluded
    from calculations.

    Default ``None`` (``'right'``).

method : str {'single', 'table'}, default 'single'
    Execute the rolling operation per single column or row (``'single'``)
    or over the entire object (``'table'``).

    This argument is only implemented when specifying ``engine='numba'``
    in the method call.

Returns
-------
pandas.api.typing.RollingGroupby
    Return a new grouper with our rolling appended.

See Also
--------
Series.rolling : Calling object with Series data.
DataFrame.rolling : Calling object with DataFrames.
Series.groupby : Apply a function groupby to a Series.
DataFrame.groupby : Apply a function groupby.

Examples
--------
>>> df = pd.DataFrame({'A': [1, 1, 2, 2],
...                    'B': [1, 2, 3, 4],
...                    'C': [0.362, 0.227, 1.267, -0.562]})
>>> df
      A  B      C
0     1  1  0.362
1     1  2  0.227
2     2  3  1.267
3     2  4 -0.562

>>> df.groupby('A').rolling(2).sum()
    B      C
A
1 0  NaN    NaN
  1  3.0  0.589
2 2  NaN    NaN
  3  7.0  0.705

>>> df.groupby('A').rolling(2, min_periods=1).sum()
    B      C
A
1 0  1.0  0.362
  1  3.0  0.589
2 2  3.0  1.267
  3  7.0  0.705

>>> df.groupby('A').rolling(2, on='B').sum()
    B      C
A
1 0  1    NaN
  1  2  0.589
2 2  3    NaN
  3  4  0.705
r   )rb   )r   	_as_index)pandas.core.windowrb   r{   r   r   )rl   ru   rv   rb   s       rn   rollingGroupBy.rolling  sE    D 	6

 ]]mm	

 
 	
rq   c                R    SSK Jn  U" U R                  /UQ7SU R                  0UD6$ )z
Return an expanding grouper, providing expanding
functionality per group.

Returns
-------
pandas.api.typing.ExpandingGroupby
r   )r`   r   )r  r`   r{   r   )rl   ru   rv   r`   s       rn   	expandingGroupBy.expanding/  s=     	8

 ]]
 	
 	
rq   c                R    SSK Jn  U" U R                  /UQ7SU R                  0UD6$ )z
Return an ewm grouper, providing ewm functionality per group.

Returns
-------
pandas.api.typing.ExponentialMovingWindowGroupby
r   )ra   r   )r  ra   r{   r   )rl   ru   rv   ra   s       rn   ewmGroupBy.ewmD  s>     	F-

 ]]
 	
 	
rq   c                *  ^ ^
 Uc  SnT R                   R                  u  n  n[        R                  " USS9R	                  [        R
                  SS9nUS:X  a  USSS2   n[        [        R                  UUUT R                  S9m
SU
U 4S	 jjnT R                  5       nUR                  U5      nT R                  U5      n	T R                  S
:X  a'  U	R                  n	T R                  R                   U	l        T R                  R"                  U	l        U	$ )a}  
Shared function for `pad` and `backfill` to call Cython method.

Parameters
----------
direction : {'ffill', 'bfill'}
    Direction passed to underlying Cython function. `bfill` will cause
    values to be filled backwards. `ffill` and any other values will
    default to a forward fill
limit : int, default None
    Maximum number of consecutive values to fill. If `None`, this
    method will convert to -1 prior to passing to Cython

Returns
-------
`Series` or `DataFrame` with filled values

See Also
--------
pad : Returns Series with minimum number of char in object.
backfill : Backward fill the missing values in the dataset.
NrG  	mergesort)r  Fr  bfill)r]  sorted_labelslimitr   c                  > [        U 5      nU R                  S:X  aI  [        R                  " U R                  [        R
                  S9nT" X!S9  [        R                  " X5      $ [        U [        R                  5      (       a\  U R                  nTR                  R                  (       a  [        U R                  5      n[        R                  " U R                  US9nO-[        U 5      R                  U R                  U R                  S9n[!        U 5       HZ  u  pV[        R                  " U R                  S   [        R
                  S9nT" X!U   S9  [        R                  " Xb5      XES S 24'   M\     U$ )Nr   r  )r  r^  )r9   rX  r   r  r  r,  r<   r  r   ndarrayr  r   r>  r-   r   _emptyr  )	rY  r^  r  r  r  ivalue_elementcol_funcrl   s	          rn   blk_funcGroupBy._fill.<locals>.blk_func  s   <D{{a((6<<rww?W0!))&::
 fbjj11"LLE}}33 8 F((6<<u=C v,--fll&,,-OC(1&(9$A hhv||AbggFGAw7 * 2 2= JC1I	 ):
 
rq   r   r  )r   rN  r   r  r  r,  r   
libgroupbygroup_fillna_indexerr   r  r  r  r   r"   r   ro  rT  )rl   	directionr   r  r`  r  r'  mgrr  r[  r&  s   `         @rn   _fillGroupBy._fillX  s    2 =EMM,,	Q

3[9@@u@U)$B$/M++';;
	 	< ))+))H%**7399>iiG"hh..GOrq   c                "    U R                  SUS9$ )a  
Forward fill the values.

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

Returns
-------
Series or DataFrame
    Object with missing values filled.

See Also
--------
Series.ffill: Returns Series with minimum number of char in object.
DataFrame.ffill: Object with missing values filled or None if inplace=True.
Series.fillna: Fill NaN values of a Series.
DataFrame.fillna: Fill NaN values of a DataFrame.

Examples
--------

For SeriesGroupBy:

>>> key = [0, 0, 1, 1]
>>> ser = pd.Series([np.nan, 2, 3, np.nan], index=key)
>>> ser
0    NaN
0    2.0
1    3.0
1    NaN
dtype: float64
>>> ser.groupby(level=0).ffill()
0    NaN
0    2.0
1    3.0
1    3.0
dtype: float64

For DataFrameGroupBy:

>>> df = pd.DataFrame(
...     {
...         "key": [0, 0, 1, 1, 1],
...         "A": [np.nan, 2, np.nan, 3, np.nan],
...         "B": [2, 3, np.nan, np.nan, np.nan],
...         "C": [np.nan, np.nan, 2, np.nan, np.nan],
...     }
... )
>>> df
   key    A    B   C
0    0  NaN  2.0 NaN
1    0  2.0  3.0 NaN
2    1  NaN  NaN 2.0
3    1  3.0  NaN NaN
4    1  NaN  NaN NaN

Propagate non-null values forward or backward within each group along columns.

>>> df.groupby("key").ffill()
     A    B   C
0  NaN  2.0 NaN
1  2.0  3.0 NaN
2  NaN  NaN 2.0
3  3.0  NaN 2.0
4  3.0  NaN 2.0

Propagate non-null values forward or backward within each group along rows.

>>> df.T.groupby(np.array([0, 0, 1, 1])).ffill().T
   key    A    B    C
0  0.0  0.0  2.0  2.0
1  0.0  2.0  3.0  3.0
2  1.0  1.0  NaN  2.0
3  1.0  3.0  NaN  NaN
4  1.0  1.0  NaN  NaN

Only replace the first NaN element within a group along rows.

>>> df.groupby("key").ffill(limit=1)
     A    B    C
0  NaN  2.0  NaN
1  2.0  3.0  NaN
2  NaN  NaN  2.0
3  3.0  NaN  2.0
4  3.0  NaN  NaN
ffillr   r-  rl   r   s     rn   r0  GroupBy.ffill  s    v zz'z//rq   c                "    U R                  SUS9$ )a  
Backward fill the values.

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

Returns
-------
Series or DataFrame
    Object with missing values filled.

See Also
--------
Series.bfill :  Backward fill the missing values in the dataset.
DataFrame.bfill:  Backward fill the missing values in the dataset.
Series.fillna: Fill NaN values of a Series.
DataFrame.fillna: Fill NaN values of a DataFrame.

Examples
--------

With Series:

>>> index = ['Falcon', 'Falcon', 'Parrot', 'Parrot', 'Parrot']
>>> s = pd.Series([None, 1, None, None, 3], index=index)
>>> s
Falcon    NaN
Falcon    1.0
Parrot    NaN
Parrot    NaN
Parrot    3.0
dtype: float64
>>> s.groupby(level=0).bfill()
Falcon    1.0
Falcon    1.0
Parrot    3.0
Parrot    3.0
Parrot    3.0
dtype: float64
>>> s.groupby(level=0).bfill(limit=1)
Falcon    1.0
Falcon    1.0
Parrot    NaN
Parrot    3.0
Parrot    3.0
dtype: float64

With DataFrame:

>>> df = pd.DataFrame({'A': [1, None, None, None, 4],
...                    'B': [None, None, 5, None, 7]}, index=index)
>>> df
          A         B
Falcon  1.0       NaN
Falcon  NaN       NaN
Parrot  NaN       5.0
Parrot  NaN       NaN
Parrot  4.0       7.0
>>> df.groupby(level=0).bfill()
          A         B
Falcon  1.0       NaN
Falcon  NaN       NaN
Parrot  4.0       5.0
Parrot  4.0       7.0
Parrot  4.0       7.0
>>> df.groupby(level=0).bfill(limit=1)
          A         B
Falcon  1.0       NaN
Falcon  NaN       NaN
Parrot  NaN       5.0
Parrot  4.0       7.0
Parrot  4.0       7.0
r  r1  r2  r3  s     rn   r  GroupBy.bfill	  s    \ zz'z//rq   c                    [        U 5      $ )a  
Take the nth row from each group if n is an int, otherwise a subset of rows.

Can be either a call or an index. dropna is not available with index notation.
Index notation accepts a comma separated list of integers and slices.

If dropna, will take the nth non-null row, dropna is either
'all' or 'any'; this is equivalent to calling dropna(how=dropna)
before the groupby.

Parameters
----------
n : int, slice or list of ints and slices
    A single nth value for the row or a list of nth values or slices.

    .. versionchanged:: 1.4.0
        Added slice and lists containing slices.
        Added index notation.

dropna : {'any', 'all', None}, default None
    Apply the specified dropna operation before counting which row is
    the nth row. Only supported if n is an int.

Returns
-------
Series or DataFrame
    N-th value within each group.
%(see_also)s
Examples
--------

>>> df = pd.DataFrame({'A': [1, 1, 2, 1, 2],
...                    'B': [np.nan, 2, 3, 4, 5]}, columns=['A', 'B'])
>>> g = df.groupby('A')
>>> g.nth(0)
   A   B
0  1 NaN
2  2 3.0
>>> g.nth(1)
   A   B
1  1 2.0
4  2 5.0
>>> g.nth(-1)
   A   B
3  1 4.0
4  2 5.0
>>> g.nth([0, 1])
   A   B
0  1 NaN
1  1 2.0
2  2 3.0
4  2 5.0
>>> g.nth(slice(None, -1))
   A   B
0  1 NaN
1  1 2.0
2  2 3.0

Index notation may also be used

>>> g.nth[0, 1]
   A   B
0  1 NaN
1  1 2.0
2  2 3.0
4  2 5.0
>>> g.nth[:-1]
   A   B
0  1 NaN
1  1 2.0
2  2 3.0

Specifying `dropna` allows ignoring ``NaN`` values

>>> g.nth(0, dropna='any')
   A   B
1  1 2.0
2  2 3.0

When the specified ``n`` is larger than any of the groups, an
empty DataFrame is returned

>>> g.nth(3, dropna='any')
Empty DataFrame
Columns: [A, B]
Index: []
)rS   r   s    rn   nthGroupBy.nthY  s    x "$''rq   c                   U(       dE  U R                  U5      nU R                  R                  u  n  nX4S:g  -  nU R                  U5      nU$ [	        U5      (       d  [        S5      eUS;  a  [        SU S35      e[        [        U5      nU R                  R                  X R                  S9n[        U5      [        U R                  5      :X  a  U R                  nOU R                  R                  n	U R                  R                  U	R                  UR                  5         nU R                  R                  (       a+  US:H  n
[         R"                  " U
[$        U5      n['        USS9nU R                  S	:X  a/  UR(                  R+                  XR,                  U R.                  S
9nO$UR+                  XR,                  U R.                  S
9nUR1                  U5      $ )NrG  z4dropna option only supported for an integer argumentr  z_For a DataFrame or Series groupby.nth, dropna must be either None, 'any' or 'all', (was passed z).)r  r   Int64r  r   )r   r   )"_make_mask_from_positional_indexerr   rN  _mask_selected_objr1   r   r   r  r{   r   r   r   
codes_infoisinrT  r>  r   r   r   rU   r"   rm   r   r   r8  )rl   r   r   r^  r  r`  r  droppedr   r   nullsrY  grbs                rn   _nthGroupBy._nth  s   
 ::1=D00ICA "9%D))$/CJ !}}STT'%hb*  aL$$++YY+G w<3t1122mmG
 ==%%Dmm..tyy/GHG}}++2 %W5g699>))##Gmm$))#TC//'MM		/RCwwqzrq   c           	       ^ ^^^^^^ T R                  USS9nT R                  U5      nT R                  S:X  aE  T R                  R	                  UR
                  T R                  S9nUR                  R
                  nO0T R                  R	                  UT R                  S9nUR                  n[        R                  " UR                  UR                  5      u  pSU 4S jjm          SU4S jjm[        R                  " U[        R                  S9n
U
n[        U5      (       a&  [        R                  " U/[        R                  S9n
SnT R                  R                  u  pm[!        U
5      m[#        [$        R&                  UU
TUU	S	9mSUUUUU4S
 jjnUR(                  R+                  U5      nT R                  U5      nT R-                  UUS9$ )a  
Return group values at the given quantile, a la numpy.percentile.

Parameters
----------
q : float or array-like, default 0.5 (50% quantile)
    Value(s) between 0 and 1 providing the quantile(s) to compute.
interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
    Method to use when the desired quantile falls between two points.
numeric_only : bool, default False
    Include only `float`, `int` or `boolean` data.

    .. versionadded:: 1.5.0

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

Returns
-------
Series or DataFrame
    Return type determined by caller of GroupBy object.

See Also
--------
Series.quantile : Similar method for Series.
DataFrame.quantile : Similar method for DataFrame.
numpy.percentile : NumPy method to compute qth percentile.

Examples
--------
>>> df = pd.DataFrame([
...     ['a', 1], ['a', 2], ['a', 3],
...     ['b', 1], ['b', 3], ['b', 5]
... ], columns=['key', 'val'])
>>> df.groupby('key').quantile()
    val
key
a    2.0
b    3.0
quantiler  r   r   c                  > [        U R                  5      (       a  [        S5      eS n[        U [        5      (       aK  [        U R                  5      (       a1  U R                  [        [        R                  S9nU R                  nX!4$ [        U R                  5      (       aa  [        U [        5      (       a#  U R                  [        [        R                  S9nOU n[        R                  " [        R                  5      nX!4$ [        U R                  5      (       a:  [        U [        5      (       a%  U R                  [        [        R                  S9nX!4$ [        U R                  5      (       aR  [        R                  " S[!        T5      R"                   S3[$        ['        5       S9  [        R(                  " U 5      nX!4$ [+        U R                  5      (       a  U R                  nX4$ [        U [        5      (       ac  [-        U R                  5      (       aI  [        R                  " [        R.                  5      nU R                  [        [        R                  S9nX!4$ [        R(                  " U 5      nX!4$ )Nz7'quantile' cannot be performed against 'object' dtypes!)r  r  zAllowing bool dtype in z.quantile is deprecated and will raise in a future version, matching the Series/DataFrame behavior. Cast to uint8 dtype before calling quantile instead.r   )r5   r  r  r   rA   r4   r  floatr   r*  r2   rC   r  r.   r   r   r   ry   r   r+   asarrayr7   r/   r+  )vals	inferencer  rl   s      rn   pre_processor'GroupBy.quantile.<locals>.pre_processor,  s   tzz**M  *.I$005Edjj5Q5Qmm%"&&mA JJ	F >!E "$**--dN33--ebff-ECCHHRXX.	: >!9 tzz**z$/O/Omm%"&&mA6 >!5 tzz**-d4j.A.A-B C0 0 "/1 jj&  >! %TZZ00 JJ	 &D.11nTZZ6P6PHHRZZ0	mm%"&&mA >! jj&>!rq   c                  > U(       Ga;  [        U[        5      (       a  Uc   eTS;   a  [        U5      (       d  [        X5      $ [        R
                  " 5          [        R                  " S[        S9  [        U5      " U R                  UR                  5      U5      sS S S 5        $ [        U5      (       a  TS;   d  [        U5      (       aE  U R                  S5      R                  UR                  R                  5      n UR!                  U 5      $ [        U["        R                  5      (       d   eU R                  U5      $ U $ ! , (       d  f       U $ = f)N>   linearmidpointignore)r   i8)r   rA   r/   rD   r   catch_warningsfilterwarningsRuntimeWarningr   r  numpy_dtyper2   r7   view_ndarrayr  _from_backing_datar   )rJ  rK  result_mask	orig_valsinterpolations       rn   post_processor(GroupBy.quantile.<locals>.post_processorZ  s4    i99&222$(>>~!H H  -T??
 &446$33H~V#'	? $$-$9$9!" !,	$ 76 %Y//%)??*955  ${{4055%..44 
  );;    &i::::;;y11K; 76: Ks   AE
Er  N)r]  r}  r\  r  r  c           	       > U n[        U [        5      (       a2  U R                  n[        R                  " TT4[        R
                  S9nO[        U 5      nS n[        U R                  5      nT" U 5      u  pVSnUR                  S:X  a  UR                  S   n[        R                  " UTT4[        R                  S9nU(       a  UR                  S5      nUR                  S:X  a  T
" US   UUUUS9  O"[        U5       H  n	T
" X   XY   X)   S US9  M     UR                  S:X  a&  UR                  S5      nUb  UR                  S5      nOUR!                  UTT-  5      nT" XX15      $ )Nr  r   r  r   rR  )rY  r^  rZ  is_datetimelikeK)r   rA   _maskr   rP  rQ  r9   r7   r  rX  r  r  r+  rW  rL  r  rN  )rY  r[  r^  rZ  r`  rJ  rK  ncolsr  r$  r   r   nqsr]  rL  s             rn   r'  "GroupBy.quantile.<locals>.blk_func  sK   I&/22|| hh~RXXFF|"1&,,?O+F3ODEyyA~

1((E7C0

CCyyyyA~F +$3 uA#w!W$((7 & yyA~iin*"-"3"3C"8Kkk%37!#+IIrq   r|  )rJ  r   r   z"tuple[np.ndarray, DtypeObj | None])
rJ  
np.ndarrayrK  zDtypeObj | NonerZ  znp.ndarray | Noner[  r   r   r   r  )r  r  r   r   _get_splitterr"   _sorted_datar   r  _slabelsr   r   r  r+  r6   rN  r   r   r)  group_quantiler  r  r  )rl   qr\  r  r,  r   splittersdatar  r  r}  pass_qsr  r`  r'  r  r  r   r   rd  r]  rL  s   ` `              @@@@@rn   rF  GroupBy.quantile  s   ` ))|*)U&&s+99>}}22355tyy2IH))++E}}223TYY2GH))E**8+<+<h>N>NO,	"\0	0	&0	 +0	 !	0	
 0	d XXarzz*%'Q<<1#RZZ0BG--22"g%%'
0	J 0	Jd **++H5&&w/++CG+<<rq   c                   U R                   nUR                  U R                  5      nU R                  R                  S   nU R                  R
                  (       a:  [        R                  " US:H  [        R                  U5      n[        R                  nO[        R                  n[        S U R                  R                   5       5      (       a  [        USS9S-
  nU R                  XCUS9nU(       d  U R                  S-
  U-
  nU$ )a`  
Number each group from 0 to the number of groups - 1.

This is the enumerative complement of cumcount.  Note that the
numbers given to the groups match the order in which the groups
would be seen when iterating over the groupby object, not the
order they are first observed.

Groups with missing keys (where `pd.isna()` is True) will be labeled with `NaN`
and will be skipped from the count.

Parameters
----------
ascending : bool, default True
    If False, number in reverse, from number of group - 1 to 0.

Returns
-------
Series
    Unique numbers for each group.

See Also
--------
.cumcount : Number the rows in each group.

Examples
--------
>>> df = pd.DataFrame({"color": ["red", None, "red", "blue", "blue", "red"]})
>>> df
   color
0    red
1   None
2    red
3   blue
4   blue
5    red
>>> df.groupby("color").ngroup()
0    1.0
1    NaN
2    1.0
3    0.0
4    0.0
5    1.0
dtype: float64
>>> df.groupby("color", dropna=False).ngroup()
0    1
1    2
2    1
3    0
4    0
5    1
dtype: int64
>>> df.groupby("color", dropna=False).ngroup(ascending=False)
0    1
1    0
2    1
3    2
4    2
5    1
dtype: int64
r   rG  c              3  8   #    U  H  oR                   v   M     g 7fri   r  r  s     rn   r   !GroupBy.ngroup.<locals>.<genexpr>   s     L4KD''4Kr  dense)ties_methodr   r  )r   rM  r   r   rN  r>  r   r   r*  r+  r  r   r!  r   r8  r   )rl   r.  r   rT  comp_idsr  r
  s          rn   ngroupGroupBy.ngroup  s    @ ''dii(==++A. ==''xxBAHJJEHHELDMM4K4KLLLxW=AH))()G\\A%.Frq   c                    U R                   R                  U R                  5      nU R                  US9nU R	                  X25      $ )a#  
Number each item in each group from 0 to the length of that group - 1.

Essentially this is equivalent to

.. code-block:: python

    self.apply(lambda x: pd.Series(np.arange(len(x)), x.index))

Parameters
----------
ascending : bool, default True
    If False, number in reverse, from length of group - 1 to 0.

Returns
-------
Series
    Sequence number of each element within each group.

See Also
--------
.ngroup : Number the groups themselves.

Examples
--------
>>> df = pd.DataFrame([['a'], ['a'], ['a'], ['b'], ['b'], ['a']],
...                   columns=['A'])
>>> df
   A
0  a
1  a
2  a
3  b
4  b
5  a
>>> df.groupby('A').cumcount()
0    0
1    1
2    2
3    0
4    1
5    3
dtype: int64
>>> df.groupby('A').cumcount(ascending=False)
0    3
1    2
2    1
3    1
4    0
5    0
dtype: int64
)r.  )r   rM  r   r4  r8  )rl   r.  rT  	cumcountss       rn   cumcountGroupBy.cumcount)  sC    n ))33DII>((9(=	''	99rq   averagekeepc                f  ^^	 US;  a  Sn[        U5      eT[        R                  La.  U R                  R	                  T5      mU R                  TS5        OSmUUUUS.m	TS:w  a7  T	R                  S5      T	S'   UU	4S jnU R                  XpR                  S	S
9nU$ U R                  "  SSTS.T	D6$ )a	  
Provide the rank of values within each group.

Parameters
----------
method : {'average', 'min', 'max', 'first', 'dense'}, default 'average'
    * average: average rank of group.
    * min: lowest rank in group.
    * max: highest rank in group.
    * first: ranks assigned in order they appear in the array.
    * dense: like 'min', but rank always increases by 1 between groups.
ascending : bool, default True
    False for ranks by high (1) to low (N).
na_option : {'keep', 'top', 'bottom'}, default 'keep'
    * keep: leave NA values where they are.
    * top: smallest rank if ascending.
    * bottom: smallest rank if descending.
pct : bool, default False
    Compute percentage rank of data within each group.
axis : int, default 0
    The axis of the object over which to compute the rank.

    .. deprecated:: 2.1.0
        For axis=1, operate on the underlying object instead. Otherwise
        the axis keyword is not necessary.

Returns
-------
DataFrame with ranking of values within each group
%(see_also)s
Examples
--------
>>> df = pd.DataFrame(
...     {
...         "group": ["a", "a", "a", "a", "a", "b", "b", "b", "b", "b"],
...         "value": [2, 4, 2, 3, 5, 1, 2, 4, 1, 5],
...     }
... )
>>> df
  group  value
0     a      2
1     a      4
2     a      2
3     a      3
4     a      5
5     b      1
6     b      2
7     b      4
8     b      1
9     b      5
>>> for method in ['average', 'min', 'max', 'dense', 'first']:
...     df[f'{method}_rank'] = df.groupby('group')['value'].rank(method)
>>> df
  group  value  average_rank  min_rank  max_rank  dense_rank  first_rank
0     a      2           1.5       1.0       2.0         1.0         1.0
1     a      4           4.0       4.0       4.0         3.0         4.0
2     a      2           1.5       1.0       2.0         1.0         2.0
3     a      3           3.0       3.0       3.0         2.0         3.0
4     a      5           5.0       5.0       5.0         4.0         5.0
5     b      1           1.5       1.0       2.0         1.0         1.0
6     b      2           3.0       3.0       3.0         2.0         3.0
7     b      4           4.0       4.0       4.0         3.0         4.0
8     b      1           1.5       1.0       2.0         1.0         2.0
9     b      5           5.0       5.0       5.0         4.0         5.0
>   topr}  bottomz3na_option must be one of 'keep', 'top', or 'bottom'rankr   )rt  r.  	na_optionpctrt  r  c                .   > U R                   " STSS.TD6$ )NF)r   r  r   r  r4  r   rv   s    rn   r   GroupBy.rank.<locals>.<lambda>  s    !&&IdI&Irq   Tr7  F)r  r   r  )
r   r   r  r   r"  r.  poprz   r{   r  )
rl   r  r.  r  r  r   r   rw   r
  rv   s
        `   @rn   r  GroupBy.rankd  s    X 55GCS/!s~~%88,,T2D  v.D """	
 19%zz-8F8IA//%%D 0 F M%%

 	
 	
rq   c                4  ^^ [         R                  " SUTSS/5        T[        R                  La.  U R                  R                  T5      mU R                  TS5        OSmTS:w  a!  UU4S jnU R                  X@R                  SS9$ U R                  " S0 TD6$ )	a  
Cumulative product for each group.

Returns
-------
Series or DataFrame
%(see_also)s
Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([6, 2, 0], index=lst)
>>> ser
a    6
a    2
b    0
dtype: int64
>>> ser.groupby(level=0).cumprod()
a    6
a   12
b    0
dtype: int64

For DataFrameGroupBy:

>>> data = [[1, 8, 2], [1, 2, 5], [2, 6, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["cow", "horse", "bull"])
>>> df
        a   b   c
cow     1   8   2
horse   1   2   5
bull    2   6   9
>>> df.groupby("a").groups
{1: ['cow', 'horse'], 2: ['bull']}
>>> df.groupby("a").cumprod()
        b   c
cow     8   2
horse  16  10
bull    6   9
cumprodr  r?  r   c                ,   > U R                   " SST0TD6$ Nr   r   r  r  s    rn   r   !GroupBy.cumprod.<locals>.<lambda>  s    !))888rq   Tr  r  
nvvalidate_groupby_funcr   r  r   r"  r.  rz   r{   r  rl   r   ru   rv   rw   s    ` ` rn   r  GroupBy.cumprod  s    ` 	  D&>8:TUs~~%88,,T2D  y1D198A--a1C1CRV-WW%%:6::rq   c                4  ^^ [         R                  " SUTSS/5        T[        R                  La.  U R                  R                  T5      mU R                  TS5        OSmTS:w  a!  UU4S jnU R                  X@R                  SS9$ U R                  " S0 TD6$ )	a  
Cumulative sum for each group.

Returns
-------
Series or DataFrame
%(see_also)s
Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'b']
>>> ser = pd.Series([6, 2, 0], index=lst)
>>> ser
a    6
a    2
b    0
dtype: int64
>>> ser.groupby(level=0).cumsum()
a    6
a    8
b    0
dtype: int64

For DataFrameGroupBy:

>>> data = [[1, 8, 2], [1, 2, 5], [2, 6, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["fox", "gorilla", "lion"])
>>> df
          a   b   c
fox       1   8   2
gorilla   1   2   5
lion      2   6   9
>>> df.groupby("a").groups
{1: ['fox', 'gorilla'], 2: ['lion']}
>>> df.groupby("a").cumsum()
          b   c
fox       8   2
gorilla  10   7
lion      6   9
r(  r  r?  r   c                ,   > U R                   " SST0TD6$ r  r(  r  s    rn   r    GroupBy.cumsum.<locals>.<lambda>E  s    !((777rq   Tr  r  r  r  s    ` ` rn   r(  GroupBy.cumsum  s    ` 	  4.(9STs~~%88,,T2D  x0D197A--a1C1CRV-WW%%9&99rq   c                L  ^ UR                  SS5      nT[        R                  La.  U R                  R	                  T5      mU R                  TS5        OSmTS:w  a9  U4S jnU R                  nU(       a  UR                  5       nU R                  XVSS9$ U R                  SX$S9$ )a  
Cumulative min for each group.

Returns
-------
Series or DataFrame
%(see_also)s
Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'a', 'b', 'b', 'b']
>>> ser = pd.Series([1, 6, 2, 3, 0, 4], index=lst)
>>> ser
a    1
a    6
a    2
b    3
b    0
b    4
dtype: int64
>>> ser.groupby(level=0).cummin()
a    1
a    1
a    1
b    3
b    0
b    0
dtype: int64

For DataFrameGroupBy:

>>> data = [[1, 0, 2], [1, 1, 5], [6, 6, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["snake", "rabbit", "turtle"])
>>> df
        a   b   c
snake   1   0   2
rabbit  1   1   5
turtle  6   6   9
>>> df.groupby("a").groups
{1: ['snake', 'rabbit'], 6: ['turtle']}
>>> df.groupby("a").cummin()
        b   c
snake   0   2
rabbit  0   2
turtle  6   9
r?  Tcumminr   c                D   > [         R                  R                  U T5      $ ri   )r   minimum
accumulater4  r   s    rn   r    GroupBy.cummin.<locals>.<lambda>      "**//48rq   r  r  r?  
r   r   r  r   r"  r.  r{   _get_numeric_datarz   r  rl   r   r  rv   r?  rw   r   s    `     rn   r  GroupBy.cumminJ      r Hd+s~~%88,,T2D  x0D198A$$C++---a4-HH%%< & 
 	
rq   c                L  ^ UR                  SS5      nT[        R                  La.  U R                  R	                  T5      mU R                  TS5        OSmTS:w  a9  U4S jnU R                  nU(       a  UR                  5       nU R                  XVSS9$ U R                  SX$S9$ )a  
Cumulative max for each group.

Returns
-------
Series or DataFrame
%(see_also)s
Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'a', 'b', 'b', 'b']
>>> ser = pd.Series([1, 6, 2, 3, 1, 4], index=lst)
>>> ser
a    1
a    6
a    2
b    3
b    1
b    4
dtype: int64
>>> ser.groupby(level=0).cummax()
a    1
a    6
a    6
b    3
b    3
b    4
dtype: int64

For DataFrameGroupBy:

>>> data = [[1, 8, 2], [1, 1, 0], [2, 6, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["cow", "horse", "bull"])
>>> df
        a   b   c
cow     1   8   2
horse   1   1   0
bull    2   6   9
>>> df.groupby("a").groups
{1: ['cow', 'horse'], 2: ['bull']}
>>> df.groupby("a").cummax()
        b   c
cow     8   2
horse   8   2
bull    6   9
r?  Tcummaxr   c                D   > [         R                  R                  U T5      $ ri   )r   maximumr  r  s    rn   r    GroupBy.cummax.<locals>.<lambda>  r  rq   r  r  r  r  s    `     rn   r  GroupBy.cummax  r  rq   c           	     p  ^^^^ T[         R                  La.  U R                  R                  T5      mU R	                  TS5        OSm[        U5      (       aD  TS:X  a  [        S5      e[        [        U5      n[        U5      S:X  a  [        S5      eSSK
Jn  SnOP[        U5      (       d  [        SU S	[        U5       S
35      eU(       a  [        S5      e[        [        U5      /nSn/ nU GH  m[        T5      (       d  [        ST S	[        T5       S
35      e[        [        T5      mTc  TS:w  a$  UUUU4S jn	U R!                  XR"                  SS9n
OT[         R                  L a  SmU R$                  R&                  u  pn[(        R*                  " [        U5      [(        R,                  S9n[.        R0                  " XUT5        U R2                  nUR5                  U R6                  UR8                  U R6                     U40TSS9n
U(       aU  [;        U
[<        5      (       a  [        [>        U
RA                  5       5      n
U
RC                  U(       a  U ST 3OST 35      n
URE                  [        [F        [<        [H        4   U
5      5        GM     [        U5      S:X  a  US   $ W" USS9$ )ai  
Shift each group by periods observations.

If freq is passed, the index will be increased using the periods and the freq.

Parameters
----------
periods : int | Sequence[int], default 1
    Number of periods to shift. If a list of values, shift each group by
    each period.
freq : str, optional
    Frequency string.
axis : axis to shift, default 0
    Shift direction.

    .. deprecated:: 2.1.0
        For axis=1, operate on the underlying object instead. Otherwise
        the axis keyword is not necessary.

fill_value : optional
    The scalar value to use for newly introduced missing values.

    .. versionchanged:: 2.1.0
        Will raise a ``ValueError`` if ``freq`` is provided too.

suffix : str, optional
    A string to add to each shifted column if there are multiple periods.
    Ignored otherwise.

Returns
-------
Series or DataFrame
    Object shifted within each group.

See Also
--------
Index.shift : Shift values of Index.

Examples
--------

For SeriesGroupBy:

>>> lst = ['a', 'a', 'b', 'b']
>>> ser = pd.Series([1, 2, 3, 4], index=lst)
>>> ser
a    1
a    2
b    3
b    4
dtype: int64
>>> ser.groupby(level=0).shift(1)
a    NaN
a    1.0
b    NaN
b    3.0
dtype: float64

For DataFrameGroupBy:

>>> data = [[1, 2, 3], [1, 5, 6], [2, 5, 8], [2, 6, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["tuna", "salmon", "catfish", "goldfish"])
>>> df
           a  b  c
    tuna   1  2  3
  salmon   1  5  6
 catfish   2  5  8
goldfish   2  6  9
>>> df.groupby("a").shift(1)
              b    c
    tuna    NaN  NaN
  salmon    2.0  3.0
 catfish    NaN  NaN
goldfish    5.0  8.0
shiftr   r   z:If `periods` contains multiple shifts, `axis` cannot be 1.z0If `periods` is an iterable, it cannot be empty.rD  TzPeriods must be integer, but z is r-  z/Cannot specify `suffix` if `periods` is an int.FNc                ,   > U R                  TTTT5      $ ri   )r  )r4  r   rZ  freqperiods    rn   r   GroupBy.shift.<locals>.<lambda>Y  s    aggD$
rq   r  r  )rZ  r  r`  r   )%r   r  r   r"  r.  r3   r   r   r   r   rJ  rE  r1   r  r   r  rz   r{   r   rN  r   rP  r  r)  group_shift_indexerr   r  r   rP  r   rZ   r   rn  
add_suffixappendr   rL   )rl   periodsr  r   rZ  suffixrE  r  shifted_dataframesrw   shiftedr  r`  r   res_indexerr   r  s     ```           @rn   r  GroupBy.shift  s   l s~~%88,,T2D  w/D  qy P  8W-G7|q  !STT9Jg&&3G9DgqQ   !RSSC)*GJFf%%3F84V~QO  #v&F419 44)) 5  /!%J"&--":": hhs3xrxx@..{&Q//44YY$))!4k BC)# 5  gv.."8W-=-=-?@G!,,,2vhax(!F8 %%d51B+CW&MNG N %&!+ q!	
 *3	
rq   c                X  ^^ T[         R                  La.  U R                  R                  T5      mU R	                  TS5        OSmTS:w  a  U R                  UU4S j5      $ U R                  nU R                  TS9nSS/nUR                  S:X  a%  UR                  U;   a  UR                  S5      nX4-
  $ UR                  R                  5        VVs/ s H  u  pgXu;   d  M  UPM     nnn[        U5      (       a"  UR                  U Vs0 s H  ofS_M     sn5      nX4-
  $ s  snnf s  snf )	aW  
First discrete difference of element.

Calculates the difference of each element compared with another
element in the group (default is element in previous row).

Parameters
----------
periods : int, default 1
    Periods to shift for calculating difference, accepts negative values.
axis : axis to shift, default 0
    Take difference over rows (0) or columns (1).

    .. deprecated:: 2.1.0
        For axis=1, operate on the underlying object instead. Otherwise
        the axis keyword is not necessary.

Returns
-------
Series or DataFrame
    First differences.
%(see_also)s
Examples
--------
For SeriesGroupBy:

>>> lst = ['a', 'a', 'a', 'b', 'b', 'b']
>>> ser = pd.Series([7, 2, 8, 4, 3, 3], index=lst)
>>> ser
a     7
a     2
a     8
b     4
b     3
b     3
dtype: int64
>>> ser.groupby(level=0).diff()
a    NaN
a   -5.0
a    6.0
b    NaN
b   -1.0
b    0.0
dtype: float64

For DataFrameGroupBy:

>>> data = {'a': [1, 3, 5, 7, 7, 8, 3], 'b': [1, 4, 8, 4, 4, 2, 1]}
>>> df = pd.DataFrame(data, index=['dog', 'dog', 'dog',
...                   'mouse', 'mouse', 'mouse', 'mouse'])
>>> df
         a  b
  dog    1  1
  dog    3  4
  dog    5  8
mouse    7  4
mouse    7  4
mouse    8  2
mouse    3  1
>>> df.groupby(level=0).diff()
         a    b
  dog  NaN  NaN
  dog  2.0  3.0
  dog  2.0  4.0
mouse  NaN  NaN
mouse  0.0  0.0
mouse  1.0 -2.0
mouse -5.0 -1.0
r&  r   c                $   > U R                  TTS9$ )N)r  r   )r&  )r4  r   r  s    rn   r   GroupBy.diff.<locals>.<lambda>  s    wT(Jrq   )r  int8int16r   float32)r   r  r   r"  r.  r  r   r  rX  r  r  dtypesitemsr   )	rl   r  r   r   r  dtypes_to_f32cr  	to_coerces	    ``      rn   r&  GroupBy.diff}  s   V s~~%88,,T2D  v.D19::JKK''**W*-  )88q=yyM)!..3 }	 ,/::+;+;+=X+=xqAW+=IX9~~!..	)J	1Y,	)JK}	 Y)Js   D!"D!
D'c                L  ^^^^^ T[         R                  S4;  d  T[         R                  La9  [        R                  " S[	        U 5      R
                   S3[        [        5       S9  T[         R                  L ae  T[         R                  L aP  [        S U  5       5      (       a9  [        R                  " S[	        U 5      R
                   S3[        [        5       S9  SmT[         R                  L a  SmT[         R                  La.  U R                  R                  T5      mU R                  TS	5        OS
mTc  TS
:w  a$  UUUUU4S jnU R                  X`R                  SS9$ Tc  SmS
m[        U T5      " TS9nU R                  S
:X  a/  UR!                  U R"                  R$                  U R&                  S9nO8UR(                  R!                  U R"                  R$                  U R&                  S9nUR+                  TTS9n	U R                  S:X  a  U	R(                  n	Xy-  S-
  $ )am  
Calculate pct_change of each value to previous entry in group.

Returns
-------
Series or DataFrame
    Percentage changes within each group.
%(see_also)s
Examples
--------

For SeriesGroupBy:

>>> lst = ['a', 'a', 'b', 'b']
>>> ser = pd.Series([1, 2, 3, 4], index=lst)
>>> ser
a    1
a    2
b    3
b    4
dtype: int64
>>> ser.groupby(level=0).pct_change()
a         NaN
a    1.000000
b         NaN
b    0.333333
dtype: float64

For DataFrameGroupBy:

>>> data = [[1, 2, 3], [1, 5, 6], [2, 5, 8], [2, 6, 9]]
>>> df = pd.DataFrame(data, columns=["a", "b", "c"],
...                   index=["tuna", "salmon", "catfish", "goldfish"])
>>> df
           a  b  c
    tuna   1  2  3
  salmon   1  5  6
 catfish   2  5  8
goldfish   2  6  9
>>> df.groupby("a").pct_change()
            b  c
    tuna    NaN    NaN
  salmon    1.5  1.000
 catfish    NaN    NaN
goldfish    0.2  0.125
NzDThe 'fill_method' keyword being not None and the 'limit' keyword in z.pct_change are deprecated and will be removed in a future version. Either fill in any non-leading NA values prior to calling pct_change or specify 'fill_method=None' to not fill NA values.r   c              3  v   #    U  H/  u  pUR                  5       R                  R                  5       v   M1     g 7fri   )r9   rY  r   )r   r`  rt  s      rn   r   %GroupBy.pct_change.<locals>.<genexpr>&  s-      /6:FA
!!%%''ds   79z#The default fill_method='ffill' in z.pct_change is deprecated and will be removed in a future version. Either fill in any non-leading NA values prior to calling pct_change or specify 'fill_method=None' to not fill NA values.r0  
pct_changer   c                *   > U R                  TTTTTS9$ )N)r  fill_methodr   r  r   )r  )r4  r   r  r  r   r  s    rn   r   $GroupBy.pct_change.<locals>.<lambda>?  s"    !,,' ' rq   Tr  r1  )r   )r  r  r   )r   r  r   r   r   ry   r   r+   r   r   r"  r.  rz   r{   r   r   rm   r   codesr   r"   r  )
rl   r  r  r   r  r   rw   filledfill_grpr  s
    `````    rn   r  GroupBy.pct_change  s   t s~~t44S^^8SMMV:&&' (
 +- #..(&3 /6:/ , , 9Dz**+ ,HH
 "/1 "KCNN"Es~~%88,,T2D  |4D tqy A --a1C1CRV-WW!KE{+%899>~~dmm&9&9doo~VHxx''(;(;'XH..t.<99>iiG A%%rq   c                Z    U R                  [        SU5      5      nU R                  U5      $ )a  
Return first n rows of each group.

Similar to ``.apply(lambda x: x.head(n))``, but it returns a subset of rows
from the original DataFrame with original index and order preserved
(``as_index`` flag is ignored).

Parameters
----------
n : int
    If positive: number of entries to include from start of each group.
    If negative: number of entries to exclude from end of each group.

Returns
-------
Series or DataFrame
    Subset of original Series or DataFrame as determined by n.
%(see_also)s
Examples
--------

>>> df = pd.DataFrame([[1, 2], [1, 4], [5, 6]],
...                   columns=['A', 'B'])
>>> df.groupby('A').head(1)
   A  B
0  1  2
2  5  6
>>> df.groupby('A').head(-1)
   A  B
0  1  2
Nr<  r   r=  rl   r   r^  s      rn   headGroupBy.headU  s,    F 66uT1~F&&t,,rq   c                    U(       a  U R                  [        U* S5      5      nOU R                  / 5      nU R                  U5      $ )a  
Return last n rows of each group.

Similar to ``.apply(lambda x: x.tail(n))``, but it returns a subset of rows
from the original DataFrame with original index and order preserved
(``as_index`` flag is ignored).

Parameters
----------
n : int
    If positive: number of entries to include from end of each group.
    If negative: number of entries to exclude from start of each group.

Returns
-------
Series or DataFrame
    Subset of original Series or DataFrame as determined by n.
%(see_also)s
Examples
--------

>>> df = pd.DataFrame([['a', 1], ['a', 2], ['b', 1], ['b', 2]],
...                   columns=['A', 'B'])
>>> df.groupby('A').tail(1)
   A  B
1  a  2
3  b  2
>>> df.groupby('A').tail(-1)
   A  B
1  a  2
3  b  2
Nr  r  s      rn   tailGroupBy.tail{  sA    H ::5!T?KD::2>D&&t,,rq   c                    U R                   R                  S   nXS:g  -  nU R                  S:X  a  U R                  U   $ U R                  R                  SS2U4   $ )z
Return _selected_obj with mask applied to the correct axis.

Parameters
----------
mask : np.ndarray[bool]
    Boolean mask to apply.

Returns
-------
Series or DataFrame
    Filtered _selected_obj.
r   rG  N)r   rN  r   r{   r   )rl   r^  r  s      rn   r=  GroupBy._mask_selected_obj  s[     mm&&q)by!99>%%d++%%**1d733rq   c                   U R                   R                  n[        U5      S:X  a  U$ U R                  (       a  U$ [	        S U 5       5      (       d  U$ U Vs/ s H  oUR
                  PM     nnU R                   R                  nUb  UR                  U5        US/-   n[        R                  " XgS9nU R                  (       a  UR                  5       nU R                  (       a=  U R                  R                  U R                  5      USSSU0n	UR                   " S0 U	D6$ [#        U5       V
Vs/ s H%  u  pUR$                  (       d  M  XR&                  4PM'     nn
n[        U5      S:  a#  [)        U6 u  pUR+                  [-        U5      SS	9nUR/                  U R                   R0                  5      R!                  USUS
9n[        U5      S:  a  UR3                  WS9nUR3                  SS9$ s  snf s  snn
f )a  
If we have categorical groupers, then we might want to make sure that
we have a fully re-indexed output to the levels. This means expanding
the output space to accommodate all values in the cartesian product of
our groups, regardless of whether they were observed in the data or
not. This will expand the output space if there are missing groups.

The method returns early without modifying the input if the number of
groupings is less than 2, self.observed == True or none of the groupers
are categorical.

Parameters
----------
output : Series or DataFrame
    Object resulting from grouping and applying an operation.
fill_value : scalar, default np.nan
    Value to use for unobserved categories if self.observed is False.
qs : np.ndarray[float64] or None, default None
    quantile values, only relevant for quantile.

Returns
-------
Series or DataFrame
    Object (potentially) re-indexed to include all possible groups.
r   c              3  b   #    U  H%  n[        UR                  [        [        45      v   M'     g 7fri   )r   r  rB   rT   r  s     rn   r   *GroupBy._reindex_output.<locals>.<genexpr>  s-      
! t++k;K-LMM!s   -/Nr  rI  FrZ  r   )r]  r   )rI  rZ  )r   T)dropr   )r   r!  r   r   r   _group_indexr   r  rV   r  r   r  r   r   _get_axis_namer   rW  r  rr  r   r   r  r	  	set_indexrK  r  )rl   r  rZ  r}  r!  r  r  r   rT  dr$  in_axis_grpsg_numsg_namess                 rn   r  GroupBy._reindex_output  s   @ MM++	y>QM ]]M  
!
 
 
 M5>?YT((Y?##> r"TFNE''A99%%'E== ''		2EjA
 >>&A&& -6i,@
,@yDLLNQ		N,@ 	 
 |q !<0OF[[WA[>F !!$--"<"<=EE* F 
 |q ''f'5F!!t!,,a @>
s   G20G7G7c           	        U R                   R                  (       a  U R                   $ [        R                  " XU5      nUb)  [        R                  " U R                   X@R
                  S9n[        R                  " U5      nU R                  R                  U R                   U R
                  5      n/ n	U Hj  u  pU R                  U
   n[        U5      nUb  UnOUc   e[        X--  5      n[        R                  " UUUUc  SOWU   US9nU	R                  X   5        Ml     [        R                  " U	5      n	U R                   R!                  XR
                  S9$ )a*	  
Return a random sample of items from each group.

You can use `random_state` for reproducibility.

Parameters
----------
n : int, optional
    Number of items to return for each group. Cannot be used with
    `frac` and must be no larger than the smallest group unless
    `replace` is True. Default is one if `frac` is None.
frac : float, optional
    Fraction of items to return. Cannot be used with `n`.
replace : bool, default False
    Allow or disallow sampling of the same row more than once.
weights : list-like, optional
    Default None results in equal probability weighting.
    If passed a list-like then values must have the same length as
    the underlying DataFrame or Series object and will be used as
    sampling probabilities after normalization within each group.
    Values must be non-negative with at least one positive element
    within each group.
random_state : int, array-like, BitGenerator, np.random.RandomState, np.random.Generator, optional
    If int, array-like, or BitGenerator, seed for random number generator.
    If np.random.RandomState or np.random.Generator, use as given.

    .. versionchanged:: 1.4.0

        np.random.Generator objects now accepted

Returns
-------
Series or DataFrame
    A new object of same type as caller containing items randomly
    sampled within each group from the caller object.

See Also
--------
DataFrame.sample: Generate random samples from a DataFrame object.
numpy.random.choice: Generate a random sample from a given 1-D numpy
    array.

Examples
--------
>>> df = pd.DataFrame(
...     {"a": ["red"] * 2 + ["blue"] * 2 + ["black"] * 2, "b": range(6)}
... )
>>> df
       a  b
0    red  0
1    red  1
2   blue  2
3   blue  3
4  black  4
5  black  5

Select one row at random for each distinct value in column a. The
`random_state` argument can be used to guarantee reproducibility:

>>> df.groupby("a").sample(n=1, random_state=1)
       a  b
4  black  4
2   blue  2
1    red  1

Set `frac` to sample fixed proportions rather than counts:

>>> df.groupby("a")["b"].sample(frac=0.5, random_state=2)
5    5
2    2
0    0
Name: b, dtype: int64

Control sample probabilities within groups by setting weights:

>>> df.groupby("a").sample(
...     n=1,
...     weights=[1, 1, 1, 0, 0, 1],
...     random_state=1,
... )
       a  b
5  black  5
2   blue  2
0    red  0
Nr   )r  replaceweightsrandom_state)r{   r  r=   process_sampling_sizepreprocess_weightsr   r   r  r   r  r   r   roundr  r   r  rV  )rl   r   fracr  r  r  r  weights_arrgroup_iteratorsampled_indicesr]  r   grp_indices
group_sizesample_size
grp_samples                   rn   r=   GroupBy.sample  s?   | ##%%%++AW= 33""G))K ''533D4F4F		R)KF,,v.K[)J"'''#D$56  '[5M)J "";#:;! *$ ..9!!&&YY&GGrq   c                  ^^^^ T[         R                  La=  Tc  U R                  mU R                  R	                  T5      mU R                  TT5        OU R                  mU R                  (       Gd  [        S U R                  R                   5       5      (       GaT  [        R                  " U R                  R                   Vs/ s H  n[        UR                  5      PM     sn5      n[        U R                  R                  5      S:X  a;  [        U R                  R                  S   R                  R                  5       5      nO[        U R                  R                   5      nX::  d   eX:  n	U(       + =(       a    U	n
U R"                  nU
(       aD  [%        U[&        5      (       a/  T(       a  UR)                  5       n[        UR*                  5      S:  n
U
(       a  [-        ST S35      eOoT(       dh  U R"                  R/                  5       R                  SS9(       a<  [0        R2                  " S[5        U 5      R6                   S	T S
3[8        [;        5       S9  TS:X  a-   UUUU4S jnTUl        U R=                  XR"                  SS9nU$ U RA                  TSTTS9nU$ s  snf ! [,         a3  nTS:X  a  SOSnSU S3[?        U5      ;   a  [-        ST S35      See SnAff = f)a
  Compute idxmax/idxmin.

Parameters
----------
how : {'idxmin', 'idxmax'}
    Whether to compute idxmin or idxmax.
axis : {{0 or 'index', 1 or 'columns'}}, default None
    The axis to use. 0 or 'index' for row-wise, 1 or 'columns' for column-wise.
    If axis is not provided, grouper's axis is used.
numeric_only : bool, default False
    Include only float, int, boolean columns.
skipna : bool, default True
    Exclude NA/null values. If an entire row/column is NA, the result
    will be NA.
ignore_unobserved : bool, default False
    When True and an unobserved group is encountered, do not raise. This used
    for transform where unobserved groups do not play an impact on the result.

Returns
-------
Series or DataFrame
    idxmax or idxmin for the groupby operation.
Nc              3  8   #    U  H  oR                   v   M     g 7fri   r  r  s     rn   r   )GroupBy._idxmax_idxmin.<locals>.<genexpr>  s      %
1H$$1Hr  r   r   z
Can't get zZ of an empty group due to unobserved categories. Specify observed=True in groupby instead.r   zThe behavior of r-  zn with all-NA values, or any-NA and skipna=False, is deprecated. In a future version this will raise ValueErrorr   c                ,   > [        U T5      nU" TTTS9$ )N)r   r?  r  )r   )r  r  r   r  r  r?  s     rn   r   $GroupBy._idxmax_idxmin.<locals>.func  s    $R-F!tFVVrq   Tr  r  argmaxargminzattempt to get z of an empty sequence)r  r  r  r?  )!r   r  r   r   r"  r.  r   r   r   r!  r   r  r   r  r  uniquerK  r   r   rL   r  ro  r   r9   r   r   r   ry   r   r+   rz   r   r  )rl   r  ignore_unobservedr   r?  r  r  expected_len
result_lenhas_unobserved	raise_errr  r   r
  r   r   s    ` ```          rn   r  GroupBy._idxmax_idxmin  s   > s~~%|yy88,,T2D  s+99D}}} %
151H1H%
 "
 "
 7748MM4K4KL4KDT&&'4KLL 4==**+q0 !8!8!;!K!K!R!R!TU
 !!;!;<
---'6N->)>)Q>I ,,DZi88113D-1	   &@ @  
 ((--/333>&tDz':':&;1SE B9 9 "/1 19W W !$3333d 4  M""%	 # 
 } M\  #&(?x$TF*?@CHL$$SE *P P    s   J))*J. .
K+8.K&&K+c                   U R                   R                  U R                  5      nUR                  S:X  a  UR	                  UR
                  5      nU$ [        U[        5      (       a  UR                  5       nUR                  n[        U[        R                  5      (       d   e[        UR
                  SS9n[        U[        5      (       a@  UR                  UR                  R!                  USUS9UR"                  UR$                  S9nU$ 0 n['        UR(                  5       H"  u  pxUR                  R!                  USUS9Xg'   M$     U R                   R                  XaR"                  S9nUR*                  Ul        U$ )Nr   F)compatT)
allow_fillrZ  r  )rT  )r   rM  r   r  r  r  r   rV   to_flat_indexrS  r   r"  r:   rZ   r  r  rV  rT  r   r  r"   ro  )	rl   r  rT  r
  rY  r  r  kcolumn_valuess	            rn   r  GroupBy._wrap_idxmax_idxmin  sG   ""499-88q=ZZ,F, ) %,,++-[[Ffbjj1111)%++eDH#v&&))KK$$V$R)) *   (1&(((;$A#kk..%$8 / DG )< ..t99.E!$rq   )r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   ops.BaseGrouper | Noner   zfrozenset[Hashable] | Noner$  r   r   r   r   r   r   r   r   zbool | lib.NoDefaultr   r   r   r   )r   r   )r   r  r   r   r   r   r   )FF)r8  r   r7  r   )r
  r  r   r  )r
  Series | DataFramer   rL   )r
  r   r   r   ri   )r
  r  r}  npt.NDArray[np.float64] | None)rY  r	  r8  r   r7  r   )r  rL   )r   r   r  zdict[np.dtype, Any]r  dict[str, bool] | None)r  r   r   r   )NFF)rw   r   r  r  r8  zbool | Noner7  r   r  r   r   r   )FrG  )r  r   r  r  r  r   r  Callable | None)
r  r   rY  r   rX  r  r  r   r   r   )NFrG  )r  r   r  r  r  r   r  r  )Fr   )r  r   r  r   r   r   )T)r.  r   r   rf  )r   r   )r?  r   r   r   )r   r   )FNN)r  r   r  !Literal['cython', 'numba'] | Noner  r  )F)r  r   r   r   )r   NNF)rs  r  r  r  r  r  r  r   )NFTFT)r  zSequence[Hashable] | Noner  r   r   r   r.  r   r   r   r   r  )r   F)rs  r  r  r   r   r   r  )Fr   NN)r  r   r  r  r  r  r  r  )r  r   r  r  r   r   )FrG  NN)FrG  T)r  r   r  r  r?  r   r   r   )r   rL   )NNN)r  r   r   r_   )r   rb   )r   r`   )r   ra   )r+  zLiteral['ffill', 'bfill']r   
int | None)r   r  )r   rS   )r   zPositionalIndexer | tupler   zLiteral['any', 'all', None]r   r   )g      ?rO  F)rk  zfloat | AnyArrayLiker\  r   r  r   )r.  r   )r  r   r.  r   r  r   r  r   r   AxisInt | lib.NoDefaultr   r   )r   Axis | lib.NoDefaultr   r   )r   r  r  r   r   r   )r  zint | Sequence[int]r   r  r  z
str | None)r  r  r   r  r   r   )r  r  r  z$FillnaOptions | None | lib.NoDefaultr   zint | None | lib.NoDefaultr   r  )   )r   r  r   r   )r^  znpt.NDArray[np.bool_]r   r   )r  r  rZ  r!   r}  r  r   r  )NNFNN)
r   r  r  zfloat | Noner  r   r  zSequence | Series | Noner  zRandomState | None)r  zLiteral['idxmax', 'idxmin']r  r   r   zAxis | None | lib.NoDefaultr?  r   r  r   r   r   )r  r   r   r   )]ry   r   r   r   r   r  r   r   r  ro   r   r.  rA  ra  r?  rv  ry  r  r  r  r  r  r  r'   _apply_docsr  r  rz   r  r  r  r  r  r  r"  r4  r  r8  r(   _common_see_alsor   r  r0  ra  rk  r  r~  r  r  r  r*   #_groupby_agg_method_engine_templater
   r  _groupby_agg_method_templater  r  r  r  r  r  rL   r  r  r  r  r  r-  r0  r  r8  rC  rF  rv  rz  r  r  r(  r  r  r  r&  r  r  r  r=  r   r*  r  r=   r  r  r   r   rq   rn   r   r     s   AF N
 %)#'*.15'+),:O:O ":O 	:O
 !:O (:O /:O %:O :O :O :O ':O :O 
:O :Ox
  $ 1 1l  "'"	A A 	A AF )	 2  >    .2'0"'0 +'0 '0Z "'"( ( 	(
 ( 
 
4++ ++ .	+Z ?C !G !GF ?C " "N J&&4H(I 	' 	

 9= ?
?B 
 )-"+
+
 !+
 &	+

 +
 +
 
+
 +
Z  #? #'?? ?
 ?  ? ?$(9(9 )(914(9;C(9	(9T   $"// / 	/
 / /d EF((&*(:A(
 -1 '< '<R  <    # #N %  % y!+,3
 - " 3
j y!+,4
 - " 4
l y!+,`: - " `:D y!+, #4804	YCYC 2YC .	YC - " YCv M? M?^ y!+, 4804"hh 2h .	h
 h - " hT y!+, 4804"ff 2f .	f
 f - " fP  -1MD)MD MD 	MD
 MD MD 
MD MD^ S
 S
j y!+,\ - " \| +
!
)X #4804>> > 2	>
 .>U) V>< $!
'P
Q' R

 +
!
)X #4804  2	
 .U) V2 +
!
)X #4804  2	
 .U) V2 NRM
 M
58M
GKM
	M
 M
^ NRB
 B
58B
GKB
	B
 B
H W Wr 			 	#
 
# #J ;? B
 B
H I
 I
V y!
   " 
$ y!
   " 
" Q Qf y!Y0 " Y0v y!L0 " L0\ y!+,X( - "  X(z /38$8 ,8 
	8t  #&%"	a=a= a= 	a= a=F y!P " Pd y!7: " 7:r y!+,  (+g
g
 g
 	g

 g
 &g
 
g
 - " g
R y!+,+.>>8;(8;	8; - " 8;t y!+,+.>>8:(8:	8: - " 8:t y!+, ),"F
%F
 F

 
F
 - " F
P y!+, ),"F
%F
 F

 
F
 - " F
P y! ()%(^^>>!Y
$Y
 #	Y
 Y
 " Y
v y!+,__&=_	_ - " _B y!+, <?NN,/NN%(^^o&o& :o& *	o& #o& - " o&b y!+,!- - " !-F y!+,&- - " &-P 4 4,   VV-1	_-#_- _- +	_-
 
_- _-B  !,0+/~H~H ~H 	~H
 *~H )~H ~HF #(,/NN"i(i  i *	i
 i i 
iVrq   r   c                    [        U [        5      (       a	  SSKJn  UnO,[        U [        5      (       a	  SSKJn  UnO[        SU  35      eU" U UUUUS9$ )Nr   )SeriesGroupBy)DataFrameGroupByzinvalid type: )r   r   r   r   r   )r   rZ   pandas.core.groupby.genericr  rL   r   r  )r   byr   r   r   r  r   r   s           rn   get_groupbyr#  '  s\     #v=	C	#	#@ ..// rq   c                   [        U5      n[        U5      R                  5       u  p4[        X45      nU R                  (       a  [        [        U 5      n [        U R                  5      U/-   nU R                   Vs/ s H  n[        R                  " Xb5      PM     sn[        R                  " U[        U 5      5      /-   n[        XWU R                  S/-   S9nU$ [        U 5      n	[        [        R                  " U	5      U 5      n
X/n[        R                  " X5      [        R                  " X95      /n[        XWU R                  S/S9nU$ s  snf )z
Insert the sequence 'qs' of quantiles as the inner-most level of a MultiIndex.

The quantile level in the MultiIndex is a repeated copy of 'qs'.

Parameters
----------
idx : Index
qs : np.ndarray[float64]

Returns
-------
MultiIndex
N)rF  r  r   )r   rU   	factorizer,   	_is_multir   rV   r	  rF  r  r   r)  r  r   r-  r   )r  r}  rd  	lev_codesru  rF  r4  r  minidx	idx_codess              rn   r  r  D  s    b'C2Y((*NI$Y4I
}}:s#cjj!SE),/II6Iq1"I6"'')SQTX:V9WWv#))tf:LM I 3x(4#>	9*BGGI,DEv388T:JKI 7s   : Ea-  {}.{} operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.)Nr   NT)r   rM   r"  r   r   r   r   r  r   r   r   r   )r  rU   r}  znpt.NDArray[np.float64]r   rV   )r   
__future__r   collections.abcr   r   r   r   r   	functoolsr   r	   r9  textwrapr
   typingr   r   r   r   r   r   r   r   numpyr   pandas._config.configr   pandas._libsr   r   pandas._libs.algosr   pandas._libs.groupby_libsrm   r)  pandas._libs.missingr   pandas._typingr   r   r   r   r   r   r   r   r   r    r!   r"   r#   pandas.compat.numpyr$   r  pandas.errorsr%   r&   pandas.util._decoratorsr'   r(   r)   r*   pandas.util._exceptionsr+   pandas.core.dtypes.castr,   r-   pandas.core.dtypes.commonr.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   pandas.core.dtypes.missingr9   r:   r;   pandas.corer<   r=   pandas.core._numbar>   pandas.core.applyr?   pandas.core.arraysr@   rA   rB   rC   rD   rE   rF   pandas.core.arrays.string_rG   pandas.core.arrays.string_arrowrH   rI   pandas.core.baserJ   rK   pandas.core.commoncorecommonr   pandas.core.framerL   pandas.core.genericrM   pandas.core.groupbyrN   rO   rP   pandas.core.groupby.grouperrQ   pandas.core.groupby.indexingrR   rS   pandas.core.indexes.apirT   rU   rV   rW   rX   pandas.core.internals.blocksrY   pandas.core.seriesrZ   pandas.core.sortingr[   pandas.core.util.numba_r\   r]   r^   r  r_   r  r`   ra   rb   r  r  r  r  r  _transform_template_agg_template_series_agg_template_framerg   r	  _KeysArgTyper   r  r   r#  r  r  r   rq   rn   <module>rW     s   #         0 ' ) ) #    /  5     ( 4   3 !   ' ' 
 4  < % 6
 .  AD@B2Iwr  4&' #P5n\ |P dM ` ,  2 NhZ!"8*h&	'(Hh	!F,x 8:N FT 37C [Ik(# [I|R W #&*	  $	
   8H rq   