+
    Ŝi                   N  a  0 t $ R t^ RIHt ^ RIHtHtHtHtH	t	H
t
 ^ RIt^ RIHtHt ^ RIHtHtHtHtHtHtHtHtHtHt ^ RIt^ RIt^ RIHtHt ^ RI H!t! ^ RI"H#u H$t% ^ RI&H't' ^ R	I(H)t)H*t*H+t+H,t,H-t-H.t.H/t/H0t0H1t1 ^ R
I2H3t4 ^ RI5H6t6H7t7H8t8 ^ RI9H:t: ^ RI;H<t< ^ RI=H>t>H?t? ^ RI@HAtAHBtBHCtCHDtDHEtEHFtFHGtGHHtHHItIHJtJHKtKHLtLHMtM ^ RINHOtOHPtPHQtQ ^ RIRHStSHTtT ^ RIUHVtV ^ RIWHXtXHYtYHZtZH[t[H\t\H]t] ^ RI^H_t_ ^ RI`Hata ^ RIbHctcHdtd ^ RIeHfu Hgth ^ RIiHjtj ^ RIkHltl ^ RImHntnHotoHptp ^ RIqHrtr ^ RIsHtttHutu ^ RIvHwtwHxtxHyty ^ RIzH{t{ ^ RI|H}t} ^ RI~Ht ^ R IHtHtHt ]'       d-   ^ R!IHt ^ R"IHt ^ R#I(HtHtHt ^ R$IHt ^ R%IHt ^ R&IHtHtHt R'tR(tR)tR*t] ! R+ R,]c4      4       t]]],          ,          ]].]3,          ,          ]]].]3,          ,          ,          ]	]]3,          ,          tR-]R.&    ! R/ R0]c]d].,          ]t4      t]! R1]lR27      t ! R3 R4]].,          4      tR9R5 R6 lltR7 R8 ltR# ):a  
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)CallableHashableIterableIteratorMappingSequenceN)partialwraps)
TYPE_CHECKINGConcatenateLiteralSelf	TypeAliasTypeVarUnioncastfinaloverload)	Timestamplib)rank_1d)NA)	AnyArrayLike	ArrayLikeDtypeObj
IndexLabelIntervalClosedTypeNDFrameTPositionalIndexerRandomStatenpt)function)AbstractMethodError	DataErrorPandas4Warning)cache_readonly)find_stack_level)coerce_indexer_dtypeensure_dtype_can_hold_na)is_boolis_bool_dtypeis_float_dtypeis_hashable
is_integeris_integer_dtypeis_list_likeis_numeric_dtypeis_object_dtype	is_scalaris_string_dtypeneeds_i8_conversionpandas_dtype)isnana_value_for_dtypenotna)
algorithmssample)executor)ArrowExtensionArrayBaseMaskedArrayExtensionArrayFloatingArrayIntegerArraySparseArray)StringDtype)ArrowStringArray)PandasObjectSelectionMixin)	DataFrame)NDFrame)basenumba_ops)get_grouper)GroupByIndexingMixinGroupByNthSelector)Index
MultiIndexdefault_index)ensure_block_shape)Series)get_group_index_sorter)get_jit_argumentsmaybe_use_numbaprepare_function_arguments)
BaseOffset)	Timedelta)AnyPT)BaseIndexer)	Resampler)ExpandingGroupbyExponentialMovingWindowGroupbyRollingGroupbya  
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.

See Also
--------
SeriesGroupBy.min : Return the min of the group values.
DataFrameGroupBy.min : Return the min of the group values.
SeriesGroupBy.max : Return the max of the group values.
DataFrameGroupBy.max : Return the max of the group values.
SeriesGroupBy.sum : Return the sum of the group values.
DataFrameGroupBy.sum : Return the sum of the group values.

Examples
--------
{example}
aV  
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.

skipna : bool, default {s}
    Exclude NA/null values. If the entire group is NA and ``skipna`` is
    ``True``, the result will be NA.

    .. versionchanged:: 3.0.0

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.

See Also
--------
SeriesGroupBy.min : Return the min of the group values.
DataFrameGroupBy.min : Return the min of the group values.
SeriesGroupBy.max : Return the max of the group values.
DataFrameGroupBy.max : Return the max of the group values.
SeriesGroupBy.sum : Return the sum of the group values.
DataFrameGroupBy.sum : Return the sum of the group values.

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
-------
%(klass)s
    The original object with the function `func` applied.

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
----------
func : 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
    %(klass)s with the same indexes as the original object filled
    with transformed values.

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.
%(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.

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)sc                  8    ] tR tRtRtR R ltR tR R ltRtR	# )
GroupByPloti  z=
Class implementing the .plot attribute for groupby objects.
c                    V ^8  d   QhRRRR/# )   groupbyGroupByreturnNone )formats   "d/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/pandas/core/groupby/groupby.py__annotate__GroupByPlot.__annotate__  s          D      c                	    Wn         R # N_groupby)selfrf   s   &&rl   __init__GroupByPlot.__init__  s    ro   c                	   aa VV3R  lpRVn         V P                  P                  W0P                  P                  4      # )c                (   < V P                   ! S/ SB # rq   )plot)rt   argskwargss   &rl   fGroupByPlot.__call__.<locals>.f  s    99d-f--ro   ry   )__name__rs   _python_apply_general_selected_obj)rt   rz   r{   r|   s   &jl rl   __call__GroupByPlot.__call__  s0    	. 
}}221mm6Q6QRRro   c                   V ^8  d   QhRR/# re   namestrrj   )rk   s   "rl   rm   rn     s       ro   c                	   a a VV 3R  lpV# )c                 x   <a a V VV3R  lpSP                   P                  VSP                   P                  4      # )c                <   < \        V P                  S4      ! S/ SB # rq   )getattrry   )rt   rz   r{   r   s   &rl   r|   0GroupByPlot.__getattr__.<locals>.attr.<locals>.f  s    tyy$/@@@ro   )rs   r   r   )rz   r{   r|   r   rt   s   jl rl   attr%GroupByPlot.__getattr__.<locals>.attr  s,    A ==66q$--:U:UVVro   rj   )rt   r   r   s   ff rl   __getattr__GroupByPlot.__getattr__  s    	W ro   rr   N)	r~   
__module____qualname____firstlineno____doc__ru   r   r   __static_attributes__rj   ro   rl   rc   rc     s     S ro   rc   r   _KeysArgTypec                     ] tR tRt$ ]P
                  0 R$m,          tR]R&   RtR]R&   RtR	]R&   R
]R&   ]	R R l4       t
]	R R l4       t]	]R R l4       4       t]	]R R l4       4       t]	]R R l4       4       t]	R 4       t]	]R 4       4       t]	R R l4       t]R R l4       t]R R l4       tR R lt]	R R  l4       t]	R! R" l4       tR#tR# )%BaseGroupByi  
group_keyskeyslevelops.BaseGrouper_grouperN_KeysArgType | NoneIndexLabel | Noneboolc                   V ^8  d   QhRR/# re   rh   intrj   )rk   s   "rl   rm   BaseGroupBy.__annotate__       % % %ro   c                	.    V P                   P                  # rq   r   ngroupsrt   s   &rl   __len__BaseGroupBy.__len__  s    }}$$$ro   c                   V ^8  d   QhRR/# )re   rh   r   rj   )rk   s   "rl   rm   r     s     % %# %ro   c                	,    \         P                  V 4      # rq   )object__repr__r   s   &rl   r   BaseGroupBy.__repr__  s     t$$ro   c                   V ^8  d   QhRR/# )re   rh   zdict[Hashable, Index]rj   )rk   s   "rl   rm   r     s     I$ I$- I$ro   c                >   \        V P                  \        4      '       di   \        V P                  4      ^8X  dO   \        P
                  ! RV P                  ^ ,           RV P                  ^ ,           R2\        \        4       R7       V P                  P                  # )a  
Dict {group name -> group labels}.

This property provides a dictionary representation of the groupings formed
during a groupby operation, where each key represents a unique group value from
the specified column(s), and each value is a list of index labels
that belong to that group.

See Also
--------
core.groupby.DataFrameGroupBy.get_group : Retrieve group from a
    ``DataFrameGroupBy`` object with provided name.
core.groupby.SeriesGroupBy.get_group : Retrieve group from a
    ``SeriesGroupBy`` object with provided name.
core.resample.Resampler.get_group : Retrieve group from a
    ``Resampler`` object with provided name.

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'): np.int64(2),
 Timestamp('2023-02-01 00:00:00'): np.int64(4)}
zWIn a future version, the keys of `groups` will be a tuple with a single element, e.g. (z,) , instead of a scalar, e.g. z, when grouping by a list with a single element. Use ``df.groupby(by='a').groups`` instead of ``df.groupby(by=['a']).groups`` to avoid this warning)
stacklevel)

isinstancer   listlenwarningswarnr%   r'   r   groupsr   s   &rl   r   BaseGroupBy.groups  s    B dii&&3tyy>Q+>MM66:iil^ D--1YYq\N ;SS
 +- }}###ro   c                   V ^8  d   QhRR/# r   rj   )rk   s   "rl   rm   r   *  r   ro   c                	.    V P                   P                  # rq   r   r   s   &rl   r   BaseGroupBy.ngroups(  s     }}$$$ro   c                   V ^8  d   QhRR/# )re   rh   z$dict[Hashable, npt.NDArray[np.intp]]rj   )rk   s   "rl   rm   r   /  s     C% C%= C%ro   c                .    V P                   P                  # )a  
Dict {group name -> group indices}.

The dictionary keys represent the group labels (e.g., timestamps for a
time-based resampling operation), and the values are arrays of integer
positions indicating where the elements of each group are located in the
original data. This property is particularly useful when working with
resampled data, as it provides insight into how the original time-series data
has been grouped.

See Also
--------
core.groupby.DataFrameGroupBy.indices : Provides a mapping of group rows to
    positions of the elements.
core.groupby.SeriesGroupBy.indices : Provides a mapping of group rows to
    positions of the elements.
core.resample.Resampler.indices : Provides a mapping of group rows to
    positions of the elements.

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
{np.int64(1): array([0, 1]), np.int64(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   &rl   r   BaseGroupBy.indices-  s    J }}$$$ro   c           	     ~  a R o\        V4      '       d+   V P                  P                  \        P                  . 4      # \        V\        4      '       d-   \        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p\        V P                  4      ^ 8  d    \        \        V P                  4      4      pMRp\        V\        4      '       d   \        V\        4      '       g   Rp\        V4      h\        V4      \        V4      8X  g    V P                  V,          # V3R lV 4       p\        ;QJ d    . R \        WQRR	7       4       F  NK  	  5M! R \        WQRR	7       4       4      pMS! V4      pV! V4      pV P                  P                  V. 4      #   \         d   pRp\        T4      ThRp?ii ; i)
zL
Safe get multiple indices, translate keys for
datelike to underlying repr.
c                    \        V \        P                  4      '       d   R  # \        V \        P                  4      '       d   R # R # )c                    \        V 4      # rq   )r   keys   &rl   <lambda>?BaseGroupBy._get_index.<locals>.get_converter.<locals>.<lambda>  s    9S>ro   c                ,    \        V 4      P                  # rq   )r   asm8r   s   &rl   r   r     s    9S>#6#6ro   c                    V # rq   rj   r   s   &rl   r   r     s    3ro   )r   datetimenp
datetime64)ss   &rl   get_converter-BaseGroupBy._get_index.<locals>.get_converter{  s:     !X..//11Ar}}--66&&ro   c              3  h   "   T F(  p\        V4      '       d   \        P                  MTx  K*  	  R # 5irq   )r7   r   nan).0comps   & rl   	<genexpr>)BaseGroupBy._get_index.<locals>.<genexpr>  s!     IDD4::47Ds   02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  4   <"   T F  pS! V4      x  K  	  R # 5irq   rj   )r   r   r   s   & rl   r   r     s     ALq-**Ls   c              3  6   "   T F  w  rV! V4      x  K  	  R # 5irq   rj   )r   r|   ns   &  rl   r   r     s     M*L$!1*Ls   Tstrict)r7   r   getr   r   r   tupler   nextiter
ValueErrorKeyErrorzip)rt   r   index_samplemsgerr
converters	converterr   s   &&     @rl   
_get_indexBaseGroupBy._get_indext  s]   	' ::<<##BFFB//dE""5IDI55IDIIDt||q T\\ 23LLlE**dE**T o%t9L 11	3<<-- BLAJ5M#jt*LM55M#jt*LMMD%l3IT?D||b))   36  %S/s23s   F F<)F77F<c                	   \        V P                  \        4      '       d   V P                  # V P                  eE   \	        V P                  4      '       d   V P                  V P                  ,          # V P
                  # V P                  # rq   )r   objrS   
_selectionr-   _obj_with_exclusionsr   s   &rl   r   BaseGroupBy._selected_obj  sc     dhh''88O??&4??++ xx00
 ,,,xxro   c                   V ^8  d   QhRR/# )re   rh   zset[str]rj   )rk   s   "rl   rm   r     s     ) ) )ro   c                	6    V P                   P                  4       # rq   )r   _dir_additionsr   s   &rl   r   BaseGroupBy._dir_additions  s    xx&&((ro   c               (    V ^8  d   QhRRRRRRRR/# )	re   funcz!Callable[Concatenate[Self, P], T]rz   zP.argsr{   zP.kwargsrh   r\   rj   )rk   s   "rl   rm   r     s2      /  	
 
ro   c                	    R # rq   rj   rt   r   rz   r{   s   &&*,rl   pipeBaseGroupBy.pipe       ro   c               (    V ^8  d   QhRRRRRRRR/# )re   r   ztuple[Callable[..., T], str]rz   rZ   r{   rh   r\   rj   )rk   s   "rl   rm   r     s2      *  	
 
ro   c                	    R # rq   rj   r   s   &&*,rl   r   r     r   ro   c               (    V ^8  d   QhRRRRRRRR/# )re   r   z@Callable[Concatenate[Self, P], T] | tuple[Callable[..., T], str]rz   rZ   r{   rh   r\   rj   )rk   s   "rl   rm   r     s8     K5 K5NK5 K5 	K5
 
K5ro   c                6    \         P                  ! W.VO5/ VB # )a  
Apply a ``func`` with arguments to this GroupBy 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 GroupBy object or, alternatively,
    a `(callable, data_keyword)` tuple where `data_keyword` is a
    string indicating the keyword of `callable` that expects the
    GroupBy object.
*args : iterable, optional
    Positional arguments passed into `func`.
**kwargs : dict, optional
    A dictionary of keyword arguments passed into `func`.

Returns
-------
GroupBy
    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 GroupBy object.

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

Examples
--------
>>> 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
)comr   r   s   &&*,rl   r   r     s    V xx4T4V44ro   c                   V ^8  d   QhRR/# re   rh   DataFrame | Seriesrj   )rk   s   "rl   rm   r     s     \- \-!3 \-ro   c                   V P                   pV P                  p\        V4      '       d   \        V4      ^8X  g"   \        V4      '       dL   \        V4      ^8X  d<   \	        V\
        4      '       d   \        V4      ^8X  d   V^ ,          pM\        V4      hV P                  V4      p\        V4      '       g   \        V4      hV P                  P                  V,          # )a"  
Construct DataFrame from group with provided name.

Parameters
----------
name : object
    The name of the group to get as a DataFrame.

Returns
-------
Series or DataFrame
    Get the respective Series or DataFrame corresponding to the group provided.

See Also
--------
DataFrameGroupBy.groups: Dictionary representation of the groupings formed
    during a groupby operation.
DataFrameGroupBy.indices: Provides a mapping of group rows to positions
    of the elements.
SeriesGroupBy.groups: Dictionary representation of the groupings formed
    during a groupby operation.
SeriesGroupBy.indices: Provides a mapping of group rows to positions
    of the elements.

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   r   r0   r   r   r   r   r   r   iloc)rt   r   r   r   indss   &&   rl   	get_groupBaseGroupBy.get_group  s    \ yy

CJ!O3t9> $&&3t9>Awtn$t$4yy4. !!&&t,,ro   c                   V ^8  d   QhRR/# )re   rh   z#Iterator[tuple[Hashable, NDFrameT]]rj   )rk   s   "rl   rm   r   }  s     b b= bro   c                    V P                   pV P                  pV P                  P                  V P                  4      p\        V4      '       d   \        V4      ^8X  g'   \        V\        4      '       d   \        V4      ^8X  d
   R V 4       pV# )a  
Groupby iterator.

This method provides an iterator over the groups created by the ``resample``
or ``groupby`` operation on the object. The method yields tuples where
the first element is the label (group key) corresponding to each group or
resampled bin, and the second element is the subset of the data that falls
within that group or bin.

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

See Also
--------
Series.groupby : Group data by a specific key or column.
DataFrame.groupby : Group DataFrame using mapper or by columns.
DataFrame.resample : Resample a DataFrame.
Series.resample : Resample a Series.

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
c              3  0   "   T F  w  rV3V3x  K  	  R # 5irq   rj   )r   r   groups   &  rl   r   'BaseGroupBy.__iter__.<locals>.<genexpr>  s     ?*#vuos   )	r   r   r   get_iteratorr   r0   r   r   r   )rt   r   r   results   &   rl   __iter__BaseGroupBy.__iter__|  so    t yy

++D,>,>?CJ!OtT""s4yA~ @?Fro   rj   >
   r   r   sortr   dropnagrouperas_indexobserved
exclusionsr   )r~   r   r   r   rE   _hidden_attrs__annotations__r   r   r   r   r   propertyr   r   r   r   r&   r   r   r   r   r  r  r   rj   ro   rl   r   r     s\    .. 2 M  $D
$#E#
% % % % I$  I$V %  % C%  C%J 0* 0*d   & ) )    K5Z \- \-| b bro   r   OutputFrameOrSeries)boundc                     ] tR tRt$ RtR]R&   R]R&   ]RR	 R
 ll4       tR R lt]R R l4       t	]RR R ll4       t
]R R l4       t]RR R ll4       t]RR R ll4       tRR R llt]R R l4       tR R lt]RR/R l4       t]RR/R l4       tR R/R! R" llt]RR# R$ ll4       t]RR%R/R& R' lll4       tR( R) lt]RR* R+ ll4       tRR, R- llt]R.RRR/R/ l4       t]R.RRR/R0 l4       t]R1 R2 l4       t]R3 4       t]RR4 R5 ll4       t]]R6 R7 l4       4       t]RR8 R9 ll4       t ]RR: R; ll4       t!]R< R= l4       t"]RR> R? ll4       t#]RR@ RA ll4       t$]RRB RC ll4       t%]RRD RE ll4       t&]RRF RG ll4       t']RRH RI ll4       t(]RJ RK l4       t)]RRL RM ll4       t*]RRN RO ll4       t+]RRP RQ ll4       t,]RRR RS ll4       t-]RRT RU ll4       t.]RRV RW ll4       t/]RX RY l4       t0RRZ R[ llt1]R R/R\ R] ll4       t2]RR^ R_ ll4       t3]RR` Ra ll4       t4]RRb Rc ll4       t5]RRd Re ll4       t6]RRf Rg ll4       t7]RRh Ri ll4       t8]]Rj Rk l4       4       t9RRl Rm llt:]RRn Ro ll4       t;]RRp Rq ll4       t<]RRr Rs ll4       t=]RRt Ru ll4       t>]RRv Rw ll4       t?]RRx Ry ll4       t@]RRz R{ ll4       tA]RR| R} ll4       tB]^R]CP                  R3R~ R ll4       tE]RR R ll4       tF]RR R ll4       tG]RR R ll4       tH]RR R ll4       tI]R R l4       tJ]RR R ll4       tKRR R lltLR R ltMRtNR# )rg   i    
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
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)
    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  NFc               H    V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRRRRRR/# )re   r   r   r   r   r   r   r  ops.BaseGrouper | Noner  zfrozenset[Hashable] | None	selectionr  r   r  r   r  r  rh   ri   rj   )rk   s   "rl   rm   GroupBy.__annotate__-  s     &O &O&O "&O !	&O
 (&O /&O %&O &O &O &O &O &O 
&Oro   c           	     	`   W`n         \        V\        4      '       g   Q \        V4      4       hW0n        Wpn        W n        Wn        Wn        Wn	        Vf   \        VVVVV
V P                  R7      w  rEpWn        Wn        W@n        V'       d   \        V4      V n        R # \        4       V n        R # )N)r   r  r  r  )r   r   rH   typer   r  r   r  r   r  rL   r  r   r   	frozensetr  )rt   r   r   r   r  r  r  r  r  r   r  r  s   &&&&&&&&&&&&rl   ru   GroupBy.__init__,  s     $#w''2c2'
 		$?'2!{{($G !3=)J/9;ro   c                   V ^8  d   QhRR/# )re   r   r   rj   )rk   s   "rl   rm   r   U  s     
 
 
ro   c                	    WP                   9   d   \        P                  W4      # WP                  9   d	   W,          # \	        R \        V 4      P                   RV R 24      h)'z' object has no attribute ')_internal_names_setr   __getattribute__r   AttributeErrorr"  r~   )rt   r   s   &&rl   r   GroupBy.__getattr__U  s\    +++**46688:T
##$$?vQG
 	
ro   c                   V ^8  d   QhRR/# r   rj   )rk   s   "rl   rm   r   `  s      # ro   c                  aaa \        \        V P                  4      V4      oVVV3R lpWn        V\        P
                  9   d   V P                  W@P                  4      # V\        P                  9   pV P                  VV P                  VV'       * R7      pV P                  P                  '       d   V'       d   V P                  V4      pV# )z<Compute the result of an operation by using GroupBy's apply.c                   < S! V .SO5/ SB # rq   rj   )xrz   r|   r{   s   &rl   curried&GroupBy._op_via_apply.<locals>.curriedd  s    Q((((ro   )is_transformnot_indexed_same)r   r"  r   r~   rI   plotting_methodsr   r   transformation_kernelsr   has_dropped_na_set_result_index_ordered)rt   r   rz   r{   r0  r2  r  r|   s   &&jl   @rl   _op_via_applyGroupBy._op_via_apply_  s     D223T:	)
   4(((--g7I7IJJt:::++%%%!--	 , 
 =='''L 33F;Fro   c                    V ^8  d   QhRRRR/# )re   r3  r   r2  rj   )rk   s   "rl   rm   r     s      >? >? >? 	>?ro   c           	     	`   ^ RI Hp V P                  '       dy   V'       gq   V P                  '       dS   V P                  P
                  pV P                  P                  pV P                  P                  pV! V^ VVVRR7      pEMV! V^ R7      pEMV'       g   V! V^ R7      pV P                  P                  p	V P                  '       d$   V P                  P                  p
V
R8g  pW,          p	V	P                  '       dz   VP                  ^ ,          P                  V	4      '       gR   \        P                   ! V	P"                  4      pVP                  P%                  V4      w  rVP'                  V^ R7      pMVP)                  V	^ R7      pM
V! V^ R7      pV P*                  P,                  ^8X  d   V P*                  P.                  pM*\1        V P2                  4      '       d   V P2                  pMRp\5        V\6        4      '       d   Ve   Wn        VP9                  V P*                  RR7      # )	    concatF)axisr   levelsnamesr  r?  Nrf   method)pandas.core.reshape.concatr>  r   r  r   result_indexr@  rA  r   indexr  idshas_duplicatesaxesequalsr:   unique1d_valuesget_indexer_non_uniquetakereindexr   ndimr   r-   r   r   rS   __finalize__)rt   valuesr3  r2  r>  r   group_levelsgroup_namesr  axlabelsmasktargetindexer_r   s   &&&&            rl   _concat_objectsGroupBy._concat_objects  s    	6???<}}}!]]77
#}}33"mm11#'%  Q/!F+F##))B{{{**|X    Q)>)>r)B)B#,,RZZ8#\\@@H
W153 F+F88==A88==D))??DDff%%$*:K""488I">>ro   c                    V ^8  d   QhRRRR/# )re   r  r  rh   rj   )rk   s   "rl   rm   r     s      )	ro   c                	    V P                   P                  pV P                  P                  '       d2   V P                  P                  '       g   VP                  V^ R7      pV# \        V P                  P                  RR7      pVP                  V^ R7      pVP                  ^ R7      pV P                  P                  '       d&   VP                  \        \        V4      4      ^ R7      pVP                  V^ R7      pV# )r<  rB  Fcopy)r   rH  r   is_monotonicr6  set_axisrO   result_ilocs
sort_indexrQ  rQ   r   )rt   r  rH  original_positionss   &&  rl   r7  !GroupBy._set_result_index_ordered  s     ==%%%dmm.J.J.J__U_3FM #4==#=#=EJ!3!<"""*==''' ^^M#e*$=A^FFQ/ro   c               $    V ^8  d   QhRRRRRR/# )re   r  Series | DataFrameqsnpt.NDArray[np.float64] | Nonerh   rG   rj   )rk   s   "rl   rm   r     s$     & &(&.L&	&ro   c                	   \        V\        4      '       d   VP                  4       p\        V P                  P
                  4      pVeE   VP                  ^ RV 2\        P                  ! V\        V4      \        V4      ,          4      4       \        \        \        V P                  P                  4      V P                  P                  4       RR7      4       F  w  pw  rVVf    V^8X  d   Vf   RMRW4,
          ^,
           2pWQP                  9  g   K=  Vf   VP                  ^ WV4       KU  VP                  ^ V\        \        P                   ! V\        V4      4      RR7      4       K  	  V# )Nlevel_Tr   rH  Fra  )r   rS   to_framer   r   	groupingsinsertr   tile	enumerater   reversedrA  get_group_levelscolumnsrO   repeat)rt   r  rk  n_groupingsr   r   levs   &&&    rl   _insert_inaxis_grouperGroupBy._insert_inaxis_grouper  s+    ff%%__&F$--112>MMVK=)2772s6{c"g7M+N
 #,,,-..0#
E;D | #a'BJ !+"5"9!:;  >>):MM!T/MM!T53B1Hu+UV-#
0 ro   c                    V ^8  d   QhRRRR/# )re   r  rj  rk  rl  rj   )rk   s   "rl   rm   r     s     " """ +"ro   c                    V P                   '       g>   V P                  WR7      pVP                  4       p\        \	        V4      4      Vn        V# V P                  P                  pVe   \        W24      pW1n        V# )z
Wraps the output of GroupBy aggregations into the expected result.

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

Returns
-------
Series or DataFrame
rk  )	r  rz  _consolidaterQ   r   rH  r   rG  _insert_quantile_level)rt   r  rk  rH  s   &&& rl   _wrap_aggregated_outputGroupBy._wrap_aggregated_output  ss    ( }}} 000?F((*F(V5FL  MM..E~ /u9 Lro   c               $    V ^8  d   QhRRRRRR/# )re   rT  r   r3  r   r2  rj   )rk   s   "rl   rm   r   *  s*     ( ( ( 	(
 (ro   c                	    \        V 4      hrq   r#   )rt   datarT  r3  r2  s   &&&&&rl   _wrap_applied_outputGroupBy._wrap_applied_output*  s     "$''ro   c                   V ^8  d   QhRR/# )re   r  rG   rj   )rk   s   "rl   rm   r   7  s     
 
	 
ro   c                	T   V P                   P                  pV P                   P                  pV P                   P                  pVP	                  V^ R7      P                  4       pVP                  p\        V\        4      '       dh   \        V P                   P                  4      ^8  d   \        R4      hV P                   P                  ^ ,          P                  pVP                  V4      pVP	                  V4      P                  4       p\        P                  ! WB4      w  rV	V
VV3# )r<  rB  z_Grouping with more than 1 grouping labels and a MultiIndex is not supported with engine='numba')r   r   re  _sorted_idsrP  to_numpyrH  r   rP   r   rp  NotImplementedErrorr   get_level_valuesr   generate_slices)rt   r  r   sorted_index
sorted_idssorted_data
index_data	group_keysorted_index_datastartsendss   &&         rl   _numba_prepGroupBy._numba_prep6  s    --''}}11]]..
ii1i5>>@ZZ
j*--4==**+a/)H  //277I#44Y?J&OOL9BBD**:?	
 	
ro   c               $    V ^8  d   QhRRRRRR/# )re   r   r   dtype_mappingzdict[np.dtype, Any]engine_kwargsdict[str, bool] | Nonerj   )rk   s   "rl   rm   r   Q  s(     ) )) +) .	)ro   c                   V P                   '       g   \        R4      hV P                  pVP                  ^8X  d   TMVP	                  4       p\
        P                  ! VVR3/ \        V4      B pV P                  P                  pV P                  P                  p	VP                  P                  ! V3RVRV	/VB p
V P                  P                  V
P                  ^&   VP                  WP                  R7      pVP                  ^8X  d%   VP!                  R4      pVP"                  Vn        V# VP$                  Vn        V# )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.TrX  r   )rK  rv  )r  r  r   rR  ro  r<   generate_shared_aggregatorrU   r   rI  r   _mgrapplyrG  rK  _constructor_from_mgrsqueezer   rv  )rt   r   r  r  aggregator_kwargsr  df
aggregatorrI  r   res_mgrr  s   &&&&,       rl   _numba_agg_generalGroupBy._numba_agg_generalQ  s#    }}}%N  ((YY!^T88
  .	

 mm--''''--
"
,3
7H
 --44Q))')E99>^^I.F))FK  "\\FNro   r  c          	        V P                   pV P                  P                  pVP                  ^8X  d   TMVP	                  4       pV P                  V4      w  rr\        P                  ! V4       \        WV^R7      w  r4\        P                  ! V3/ \        V4      B pV! VV
VV	\        VP                  4      .VO5!  pVP                  \        P                  ! V4      ^ R7      pVP                   pVP                  ^8X  d    RVP"                  /pVP%                  4       pMRVP                  /pVP&                  ! V3RV/VB # )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.
num_required_argsrB  r   rv  rH  )r   r   re  rR  ro  r  rJ   validate_udfrW   generate_numba_transform_funcrU   r   rv  rP  r   argsortrH  r   ravel_constructor)rt   r   r  rz   r{   r  index_sortingr  r  r  r  r  numba_transform_funcr  rH  result_kwargss   &&$*,           rl   _transform_with_numbaGroupBy._transform_with_numba|  s.    ((22YY!^T262B2B22F/lD!1!
  &CC 
%m4 
 &

O
 
 RZZ6Q?

99>#TYY/M\\^F&5M  FuFFFro   c          	        V P                   pVP                  ^8X  d   TMVP                  4       pV P                  V4      w  rxr\        P
                  ! V4       \        WV^R7      w  r4\        P                  ! V3/ \        V4      B pV! V
V	VV\        VP                  4      .VO5!  pV P                  P                  pVP                  ^8X  d    RVP                  /pVP                  4       pMRVP                  /pVP                  ! V3RV/VB pV P                   '       g+   V P#                  V4      p\%        \        V4      4      Vn        V# )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   rv  rH  )r   rR  ro  r  rJ   r  rW   generate_numba_agg_funcrU   r   rv  r   rG  r   r  r  r  rz  rQ   rH  )rt   r   r  rz   r{   r  r  r  r  r  r  numba_agg_funcr  rH  r  ress   &&$*,           rl   _aggregate_with_numbaGroupBy._aggregate_with_numba  s6    ((YY!^T262B2B22F/lD!1!
  77
%m4
  

O
 
 **99>#TYY/M\\^F&5MEeE}E}}}--c2C%c#h/CI
ro   include_groupsc                    V ^8  d   QhRRRR/# )re   r  r   rh   r   rj   )rk   s   "rl   rm   r     s"     cH cH cHH cHro   c                 aaa V'       d   \        R4      h\        S\        4      '       dg   \        V S4      '       dF   \	        V S4      p\        V4      '       d	   V! S/ SB # S'       g	   S'       d   \        RS 24      hV# \        RS R24      hS'       g	   S'       d4   \        S4      '       d   \        S4      VVV3R l4       pM\        R4      hSpV P                  W`P                  4      # )a  
Apply function ``func`` group-wise and combine the results together.

The function passed to ``apply`` must take a dataframe 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 dataframe as its first argument, and
    returns a dataframe, a series or a scalar. In addition the
    callable may take positional and keyword arguments.

*args : tuple
    Optional positional arguments to pass to ``func``.

include_groups : bool, default False
    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

    .. versionchanged:: 3.0.0

    The default changed from True to False, and True is no longer allowed.

**kwargs : dict
    Optional keyword arguments to pass to ``func``.

Returns
-------
Series or DataFrame
    A pandas object with the result of applying ``func`` to each group.

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

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())
A
a    5
b    2
dtype: int64

Example 4: The function passed to ``apply`` returns ``None`` for one of the
group. This group is filtered from the result:

>>> g1.apply(lambda x: None if x.iloc[0, 0] == 3 else x)
   B  C
0  1  4
1  2  6
)include_groups=True is no longer allowed.z"Cannot pass arguments to property z$apply func should be callable, not 'r'  c                   < S! V .SO5/ SB # rq   rj   )grz   r   r{   s   &rl   r|   GroupBy.apply.<locals>.fg  s    3D3F33ro   z6func must be a callable if args or kwargs are supplied)
r   r   r   hasattrr   callable	TypeErrorr
   r   r   )rt   r   r  rz   r{   r  r|   s   &f$jl  rl   r  GroupBy.apply  s    N HIIdC  tT""dD)C==///V$'I$%PQQ
  "FtfA NOOV~~t4 4 !L  A))!-F-FGGro   c               0    V ^8  d   QhRRRRRRRRR	RR
R/# )re   r|   r   r  r  r3  zbool | Noner2  r   is_aggrh   r   rj   )rk   s   "rl   rm   r   u  sF     +
 +
+
 !+
 &	+

 +
 +
 
+
ro   c                p    V P                   P                  W4      w  rgVf   TpV P                  VVVV4      # )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  )rt   r|   r  r3  r2  r  rT  mutateds   &&&&&&  rl   r   GroupBy._python_apply_generalt  sF    F --77@#&((	
 	
ro   npfuncc               (    V ^8  d   QhRRRRRRRR/# )	re   numeric_onlyr   	min_countr   aliasr   r  Callable | Nonerj   )rk   s   "rl   rm   r     s2     ? ?? ?
 ?  ?ro   c               	p    V P                   ! RR VRVRVRV/VB pVP                  V P                  RR7      # )howaltr  r  rf   rC  rj   _cython_agg_generalrS  r   )rt   r  r  r  r  r{   r  s   &&&$$, rl   _agg_generalGroupBy._agg_general  s^     )) 


 &
  	

 
 ""488I">>ro   c          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
re   r  r   rT  r   rR  r   r  r   rh   rj   )rk   s   "rl   rm   r     s4     -9 -9-9 )-914-9;C-9	-9ro   c                p   Vf   Q hVP                   ^8X  d   \        VRR7      pMN\        VP                  VP                  R7      pVP
                  ^,          ^8X  g   Q hVP                  R,          p V P                  P                  WTRR7      pTP                  p
T
\        8X  d   TP                  \        RR7      pM3\        T
4      '       d#   T
P                  4       pTP                  YzR7      p\!        YsR
7      #   \         d+   pRT RTP                   R	2p	\        T4      ! T	4      ThRp?ii ; i)zV
Fallback to pure-python aggregation if _cython_operation raises
NotImplementedError.
NFra  dtypeT)preserve_dtypezagg function failed [how->z,dtype->])rR  )NNNr<  )rR  rS   rG   r\   r  shaper  r   
agg_series	Exceptionr"  r   astyper4   construct_array_type_from_sequencerR   )rt   r  rT  rR  r  serr  
res_valuesr   r   r  string_array_clss   &&&&&       rl   _agg_py_fallbackGroupBy._agg_py_fallback  s    ;;!e,C 6886<<8B 88A;!### ''$-C
	*11#41PJ 		F?#**6*>JU##$99;)888QJ "*88#  	*.se8CII;aHCs)C.c)	*s   5D   D5%D00D5c               (    V ^8  d   QhRRRRRRRR/# )	re   r  r   r  r  r  r   r  r   rj   )rk   s   "rl   rm   r     s2     1 11 1 	1
 1ro   c                	6  a aaaaa
 \        V4      '       g   \        R 4      hS P                  VSR7      o
R VV
VVVV 3R llpS
P                  V4      pS P	                  V4      pSR9   d   S P                  VSSR,          R7      pS P                  V4      p	V	# )z(numeric_only accepts only Boolean valuesr  r   c                    V ^8  d   QhRRRR/# re   rT  r   rh   rj   )rk   s   "rl   rm   1GroupBy._cython_agg_general.<locals>.__annotate__  s     	 	y 	Y 	ro   c                8  <  SP                   P                  ! R V S3RSP                  ^,
          RS/SB pV#   \         d/    SR9   d   \	        T \
        4      '       d    MSe   SR9   d   h  Mi ; iSf   Q hSP                  ST SP                  SR7      pT# )	aggregater?  r  )rR  r  anyall)r  r  stdsem)r   _cython_operationrR  r  r   rB   r  )rT  r  r  r  r  r{   r  rt   s   & rl   
array_func/GroupBy._cython_agg_general.<locals>.array_func  s    88 Q	
 ( &  ' 	 .(Z-L-L[C+G$G %H	 ?"?**3TYYC*PFMs   49 (A2#A21A2skipna)r  r  idxminidxmax)r*   r   _get_data_to_aggregategrouped_reduce_wrap_agged_manager_wrap_idxmax_idxminr  )rt   r  r  r  r  r{   r  new_mgrr  outr  s   fff&fl    @rl   r  GroupBy._cython_agg_general  s     |$$GHH**3*O	 	6 %%j1&&w/&&**3Cx@P*QC**3/
ro   c                    V ^8  d   QhRRRR/# )re   r  r   r  r   rj   )rk   s   "rl   rm   r     s     ( (S ( (ro   c                	    \        V 4      hrq   r  )rt   r  r  r{   s   &&&,rl   _cython_transformGroupBy._cython_transform  s    !$''ro   enginec               	   \        V\        4      '       g   V P                  ! WV.VO5/ VB # V\        P                  9  d   R V R2p\        V4      hV\        P                  9   g   V\        P                  9   d   Ve	   W%R&   W5R&   \        W4      ! V/ VB # V P                  '       d   V P                  ! V.VO5RVRV/VB # \        P                  ! V RR4      ;_uu_ 4        \        P                  ! V RV P                  P                  4      ;_uu_ 4        V P                  ! V.VO5RVRV/VB uuRRR4       uuRRR4       #   + '       g   i     M; i RRR4       R#   + '       g   i     R# ; i)r'  z2' is not a valid function name for transform(name)Nr  r  r  Tr   )r   r   _transform_generalrI   transform_kernel_allowlistr   cythonized_kernelsr5  r   r  _reduction_kernel_transformr   temp_setattrr   observed_grouper)rt   r   r  r  rz   r{   r   s   &&$$*, rl   
_transformGroupBy._transform  sn    $$$**4XXQWXX888dVMNCS/!T,,,8S8S0S!#)x *7'4&777 }}}77(.>KOU 
   z488  z4==3Q3QRR77(.>KOU SR 98RRR 9888s$   '5E)E	6
E)EE))E:	c               	B   \         P                  ! V R R4      ;_uu_ 4        VR9   d0   \        \        R,          V4      pV P                  ! VR.VO5/ VB pMVe	   W%R&   W5R&   \        W4      ! V/ VB pRRR4       V P                  X4      #   + '       g   i     L!; i)r  TNr  r  r  )r   r  r   r   _idxmax_idxminr   _wrap_transform_fast_result)rt   r   r  r  rz   r{   r  s   &&$$*, rl   r  #GroupBy._reduction_kernel_transform:  s     dJ55 ++G$67>,,T4I$I&I%'-8$.;?+ ,d=f= 6 //77 65s   ABB	c                    V ^8  d   QhRRRR/# )re   r  r   rh   rj   )rk   s   "rl   rm   r   Q  s      ( x ro   c                   V P                   pV P                  P                  pVP                  V P                  P                  ^ R7      pV P
                  P                  ^8X  dK   \        P                  ! VP                  V4      pVP                  WBP                  VP                  R7      pV# VP                  P                  V4      pVP                  ^ Wc3/RR7      pVP                  VP                  ^ R7      pV# )z'
Fast transform path for aggregations.
rB  rH  r   T)
allow_dups)r   r   rI  rQ  rG  r   rR  r:   take_ndrN  r  rH  r   rP  _reindex_with_indexersrd  )rt   r  r   rI  r  outputnew_axs   &&     rl   r  #GroupBy._wrap_transform_fast_resultP  s    
 '' mm : :C88==A$$V^^S9C%%c%JF  \\&&s+F22A}3ERV2WF__SYYQ_7Fro   c                	r   \        V4      ^ 8X  d   \        P                  ! . RR7      pM*\        P                  ! \        P                  ! V4      4      pV'       d    V P
                  P                  V^ R7      pV# \        P                  ! \        V P
                  P                  4      \        R7      pVP                  R4       RWAP                  \        4      &   \        P                  ! V. V P
                  P                  R,          O^N4      P                  pV P
                  P!                  V4      pV# )r<  int64r  rB  FT   NN)r   r   arrayr  concatenater   rP  emptyrH  r   fillr  r   rr  r  r\   where)rt   r   r  filteredrY  s   &&&  rl   _apply_filterGroupBy._apply_filterl  s    w<1hhr1GggbnnW56G))..wQ.?H  88C 2 2 8 89FDIIe(,D$%774!C4#5#5#;#;B#?!C!CDFFD))//5Hro   c                    V ^8  d   QhRRRR/# )re   	ascendingr   rh   
np.ndarrayrj   )rk   s   "rl   rm   r   ~  s     $ $ $ $ro   c           	        V P                   P                  pV P                   P                  p\        W#4      pW$,          \	        V4      rRV^ 8X  d'   \
        P                  ! ^ \
        P                  R7      # \
        P                  RVRR VR,          8g  3,          p\
        P                  ! \
        P                  \
        P                  ! V4      ^ ,          V3,          4      pV( P                  4       pV'       d&   V\
        P                  ! W,          V4      ,          pMC\
        P                  ! V\
        P                  VR,          R3,          ,          V4      V,
          pV P                   P                  '       dJ   \
        P                  ! VR8H  \
        P                  VP!                  \
        P"                  RR7      4      pM!VP!                  \
        P                  RR7      p\
        P                  ! V\
        P$                  R7      p	\
        P&                  ! V\
        P$                  R7      W&   W,          # )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  TNr%  Fra  rE  )r   rI  r   rT   r   r   r)  r$  r_diffnonzerocumsumrw  r6  r+  r   r  float64intparange)
rt   r0  rI  r   sortercountrunrepr  revs
   &&        rl   _cumcount_arrayGroupBy._cumcount_array}  st    mm--'''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ro   c                   V ^8  d   QhRR/# )re   rh   r   rj   )rk   s   "rl   rm   r     s     % %X %ro   c                	    \        V P                  \        4      '       d   V P                  P                  # \        V P                  \        4      '       g   Q hV P                  P
                  # rq   )r   r   rG   _constructor_slicedrS   r  r   s   &rl   _obj_1d_constructorGroupBy._obj_1d_constructor  sL     dhh	**88///$((F++++xx$$$ro   c                    V ^8  d   QhRRRR/# re   r  r   rh   r   rj   )rk   s   "rl   rm   r     s     9
 9
$ 9
( 9
ro   c                4   a V P                  RV3R lSR7      # )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
--------
Series.any : Apply function any to a Series.
DataFrame.any : Apply function any to each row or column of a DataFrame.

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                >   < \        V R R7      P                  SR7      # Fra  )r  )rS   r  r/  r  s   &rl   r   GroupBy.any.<locals>.<lambda>      &/3363Bro   r  r  r  rt   r  s   &frl   r  GroupBy.any  s'    l ''B ( 
 	
ro   c                    V ^8  d   QhRRRR/# rG  rj   )rk   s   "rl   rm   r     s     :
 :
$ :
( :
ro   c                4   a V P                  RV3R lSR7      # )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
--------
Series.all : Apply function all to a Series.
DataFrame.all : Apply function all to each row or column of a DataFrame.

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                >   < \        V R R7      P                  SR7      # rJ  )rS   r  rK  s   &rl   r   GroupBy.all.<locals>.<lambda>$  rM  ro   rN  rO  rP  s   &frl   r  GroupBy.all  s'    n ''B ( 
 	
ro   c                   V ^8  d   QhRR/# re   rh   r   rj   )rk   s   "rl   rm   r   )  s     e ex ero   c                ,  aaaa	 V P                  4       pV P                  P                  oV P                  P                  o	SR8g  oVP                  ^8H  oR VVVV	3R llpVP                  V4      pV P                  V4      pV P                  V4      pV# )a  
Compute count of group, excluding missing values.

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

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

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
c                    V ^8  d   QhRRRR/# )re   bvaluesr   rh   rj   )rk   s   "rl   rm   #GroupBy.count.<locals>.__annotate__r  s     	 	9 	 	ro   c                  < V P                   ^8X  d%   S\        V 4      P                  ^R4      ( ,          pMS\        V 4      ( ,          p\        P                  ! VSSR7      p\        V \        4      '       dJ   \        V^ ,          \        P                  ! VP                  ^,          \        P                  R7      R7      # \        V \        4      '       dO   \        V P                  \        4      '       g/   \        R4      p\!        V 4      P#                  V^ ,          VR7      # S'       d7   VP                   ^8X  g   Q hVP                  ^ ,          ^8X  g   Q hV^ ,          # V# )r&  )rX  max_binr  )rY  zint64[pyarrow]rE  )rR  r7   reshaper   count_level_2dr   r>   rA   r   zerosr  bool_r=   r  rC   r6   r"  r  )r[  maskedcountedr  rI  	is_seriesrY  r   s   &   rl   hfuncGroupBy.count.<locals>.hfuncr  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!Nro   rE  )r  r   rI  r   rR  r  r  r  )
rt   r  rf  r  new_objr  rI  re  rY  r   s
   &     @@@@rl   r;  GroupBy.count(  s    F **,mm--''byIIN		 	0 %%e,**73--g6ro   c               (    V ^8  d   QhRRRRRRRR/# )re   r  r   r  r  !Literal['cython', 'numba'] | Noner  r  rj   )rk   s   "rl   rm   r     s>     dC dCdC dC 2	dC
 .dCro   c                   aa \        V4      '       d+   ^ RIHp V P                  V\        P
                  V^ SR7      # V P                  RVV3R lSSR7      pVP                  V P                  RR7      # )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``.

skipna : bool, default True
    Exclude NA/null values. If an entire group is NA, the result will be NA.

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

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

Returns
-------
pandas.Series or pandas.DataFrame
    Mean of values within each group. Same object type as the caller.

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

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
)grouped_meanmin_periodsr  meanc                @   < \        V R R7      P                  SSR7      # Fra  r  r  )rS   rp  r/  r  r  s   &rl   r   GroupBy.mean.<locals>.<lambda>  s!    fQU388!-f 9 ro   r  r  r  rf   rC  )	rV   pandas.core._numba.kernelsrm  r  r<   float_dtype_mappingr  rS  r   )rt   r  r  r  r  rm  r  s   &ff&&  rl   rp  GroupBy.mean  s    d 6""?**,, +   -- * . F &&txx	&BBro   c               $    V ^8  d   QhRRRRRR/# )re   r  r   r  rh   r   rj   )rk   s   "rl   rm   r     s&     a? a?4 a? a? a?ro   c                t   aa V P                  RVV3R lSSR7      pVP                  V P                  RR7      # )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.

skipna : bool, default True
    Exclude NA/null values. If an entire group is NA, the result will be NA.

    .. versionadded:: 3.0.0

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

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

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                @   < \        V R R7      P                  SSR7      # rr  )rS   r|  rt  s   &rl   r    GroupBy.median.<locals>.<lambda>S	  s!    &/66)& 7 ro   rv  rf   rC  r  )rt   r  r  r  s   &ff rl   r|  GroupBy.median  sG    t )) & * 
 ""488I">>ro   c          
     ,    V ^8  d   QhRRRRRRRRR	R/# 
re   ddofr   r  rk  r  r  r  r   r  rj   )rk   s   "rl   rm   r   \	  sC     q qq 2q .	q
 q qro   c                   aa \        V4      '       d@   ^ RIHp \        P                  ! V P                  V\        P                  V^ SSR7      4      # V P                  RVV3R lVSSR7      # )a  
Compute standard deviation of groups, excluding missing values.

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

Parameters
----------
ddof : int, default 1
    Delta Degrees of Freedom. The divisor used in calculations is ``N - ddof``,
    where ``N`` represents the number of elements.

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

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

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

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

skipna : bool, default True
    Exclude NA/null values. If an entire group is NA, the result will be NA.

    .. versionadded:: 3.0.0

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

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

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
grouped_varro  r  r  r  c                @   < \        V R R7      P                  SSR7      # Fra  )r  r  )rS   r  r/  r  r  s   &rl   r   GroupBy.std.<locals>.<lambda>	      fQU377T&7Qro   r  r  r  r  )	rV   rw  r  r   sqrtr  r<   rx  r  rt   r  r  r  r  r  r  s   &f&&&f rl   r  GroupBy.std[	  sy    | 6"">77''00! !! ( 	 	 ++Q) ,  ro   c          
     ,    V ^8  d   QhRRRRRRRRR	R/# r  rj   )rk   s   "rl   rm   r   	  sC     n nn 2n .	n
 n nro   c           	        aa \        V4      '       d,   ^ RIHp V P                  V\        P
                  V^ SSR7      # V P                  RVV3R lVSSR7      # )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``

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

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

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

skipna : bool, default True
    Exclude NA/null values. If an entire group is NA, the result will be NA.

    .. versionadded:: 3.0.0

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

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

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  r  varc                @   < \        V R R7      P                  SSR7      # r  )rS   r  r  s   &rl   r   GroupBy.var.<locals>.<lambda>:
  r  ro   r  )rV   rw  r  r  r<   rx  r  r  s   &f&&&f rl   r  GroupBy.var	  sm    z 6"">**,, +   ++Q) ,  ro   c               0    V ^8  d   QhRRRRRRRRRRRR	/# )
re   subsetzSequence[Hashable] | None	normalizer   r  r0  r  rh   r  rj   )rk   s   "rl   rm   r   A
  sV     zD zD)zD zD 	zD
 zD zD 
zDro   c           	       aaa  V'       d   RMRpV P                   pV P                  oV P                  P                   Uu0 uF"  qP                  '       g   K  VP
                  kK$  	  upo\        S\        4      '       d   SP
                  p	V	S9   d   . MS.p
M\        SP                  4      pVeV   \        V4      o S \        S4      ,          pV'       d   \        RV R24      hS V,
          pV'       d   \        RV R24      hMVo VVV 3R l\        SP                  4       4       p
\        V P                  P                  4      pV
 F3  p\        VVRRVR7      w  p pV\        VP                  4      ,          pK5  	  VP                  VRV P                  V P                   R	7      p\#        \        VP%                  4       4      pVVn        V'       d   VP'                  VR
R7      pV P(                  '       d   VP*                  P,                  p\/        \1        V4      4      VP*                  n        \/        \1        V P                  P                  4      4      pVP3                  VRR7      pVVP*                  n        V'       d   \        \/        \1        V P                  P                  4      VP*                  P4                  4      4      pVP                  VP*                  P7                  V4      V P(                  V P                   RR7      P9                  R4      pVV,          pVP;                  R4      pV P<                  '       d   TpMVP*                  p\>        P@                  ! VP,                  4      pVV9   d   \        RV R24      hVVn        VPC                  \/        \1        V4      4      4      Vn        VPE                  4       pV P                  P                  ^ ,          P                   P                  PF                  p\I        VVR7      PK                  \1        V4      V4      pVVn	        TpVPM                  V P                   RR7      # u upi )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.

proportionr;  zKeys z0 in subset cannot be in the groupby column keys.z) in subset do not exist in the DataFrame.c              3  v   <"   T F.  w  rVS9  g   K  VS9   g   K  SP                   R V3,          x  K0  	  R# 5i)r  N)r  )r   idx_namein_axis_namesr   	subsetteds   &  rl   r   (GroupBy._value_counts.<locals>.<genexpr>l
  sC       #9JC- !2792D !C  "8s   999F)r   r  r  r  )r  r  r  stable)r0  kind)r   sort_remaining)r  r  r  sumg        zColumn label 'z' is duplicate of result columnr  value_countsrC  )'r   r   r   rp  in_axisr   r   rS   setrv  r   rs  r   rL   rf   r  r  r   sizesort_valuesr  rH  rA  ranger   rf  nlevels	droplevel	transformfillnar  r   fill_missing_names	set_namesreset_indexr  rO   rq  rS  )!rt   r  r  r  r0  r  r   r  groupingr  r   unique_colsclashingdoesnt_existrp  r   r  r\  gbresult_seriesrA  index_levelr@  indexed_group_sizer  rH  rv  result_frame
orig_dtypecolsr  r   r  s!   &&&&&&                        @@@rl   _value_countsGroupBy._value_counts@
  s     )|gXX'' +/--*A*A
*AhEUEUMHMM*A
 c6""HHE+0M+ARuDckk*K!K	$s='99$z *3 3   );6$~-VW   
 (	 #,CKK"8D 001	C'MGQ g//00I  ZZ]];;	  
 VRWWY/!)55#( 6 M 999!''--E(-c%j(9M%DMM$;$; <=K)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CO
s    QQc               (    V ^8  d   QhRRRRRRRR/# )re   r  r   r  r   r  rh   r   rj   )rk   s   "rl   rm   r   
  s2     g
 g
g
+/g
AEg
	g
ro   c                @  aa V'       d{   V P                   P                  ^8X  d`   \        V P                   P                  4      '       g;   \	        \        V 4      P                   RV RV P                   P                   24      hV P                  RVV3R lVSSR7      # )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.

    .. versionchanged:: 2.0.0

        numeric_only now defaults to ``False``.

skipna : bool, default True
    Exclude NA/null values. If an entire group is NA, the result will be NA.

    .. versionadded:: 3.0.0

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

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

Examples
--------
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
z.sem called with numeric_only=z and dtype r  c                @   < \        V R R7      P                  SSR7      # r  )rS   r  r  s   &rl   r   GroupBy.sem.<locals>.<lambda>!  s    &/33f3Mro   r  )r   rR  r1   r  r  r"  r~   r  )rt   r  r  r  s   &f&frl   r  GroupBy.sem
  s    z DHHMMQ.7G7W7W:&&' (  ,~[8HJ  ''M% ( 
 	
ro   c                   V ^8  d   QhRR/# r   rj   )rk   s   "rl   rm   r   (  s     _ _( _ro   c                N   V P                   P                  4       pRp\        V P                  \        4      '       d   \        V P                  P
                  \        4      '       dp   \        V P                  P
                  \        4      '       dC   V P                  P
                  P                  P                  \        P                  J d   RpM2RpM/RpM,\        V P                  P
                  \        4      '       d   Rp\        V P                  \        4      '       d(   V P                  WP                  P                  R7      pMV P                  V4      pVe   VP                  RRRRVR7      pV P                   '       g    VP#                  R4      P%                  4       pV# )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
--------
Series.size : Apply function size to a Series.
DataFrame.size : Apply function size to each row or column of a DataFrame.

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pyarrow)r   F)infer_objectsconvert_stringconvert_booleanconvert_floatingdtype_backendr  )r   r  r   r   rS   r'  r=   rD   r  na_valuer   r   r>   rD  r   convert_dtypesr  renamer  )rt   r  r  s   &  rl   r  GroupBy.size'  s1   @ ##%EIdhh''$((..*=>>dhhnn.>??xx~~++44>(,(8$-MDHHNNO<< 0 dhh''--f88==-IF--f5F$**#$ %!&+ + F }}}]]6*668Fro   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# 
re   r  r   r  r   r  r  rk  r  r  rj   )rk   s   "rl   rm   r     sC     w ww w 	w
 2w .wro   c           
     >   \        V4      '       d+   ^ RIHp V P                  V\        P
                  VVVR7      # \        P                  ! V RR4      ;_uu_ 4        V P                  VVR\        P                  VR7      pRRR4       V#   + '       g   i     X# ; i)a~	  
Compute sum of group values.

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

    .. versionchanged:: 2.0.0

        numeric_only no longer accepts ``None``.

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

skipna : bool, default True
    Exclude NA/null values. If the entire group is NA and ``skipna`` is
    ``True``, the result will be NA.

    .. versionchanged:: 3.0.0

engine : str, default None None
    * ``'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 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 both the ``func`` and the ``apply`` groupby aggregation.

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

See Also
--------
SeriesGroupBy.min : Return the min of the group values.
DataFrameGroupBy.min : Return the min of the group values.
SeriesGroupBy.max : Return the max of the group values.
DataFrameGroupBy.max : Return the max of the group values.
SeriesGroupBy.sum : Return the sum of the group values.
DataFrameGroupBy.sum : Return the sum of the group values.

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).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
)grouped_sumrn  r  Tr  r  r  r  r  r  N)rV   rw  r  r  r<   default_dtype_mappingr   r  r  r   r  )rt   r  r  r  r  r  r  r  s   &&&&&&  rl   r  GroupBy.sum  s    B 6"">**..% +   !!$
D99**!-'66! +  : M :9 Ms   %BB	c               (    V ^8  d   QhRRRRRRRR/# re   r  r   r  r   r  rh   r   rj   )rk   s   "rl   rm   r     s2     M
 M
 M
58M
FJM
	M
ro   c                J    V P                  VVVR\        P                  R7      # )a\  
Compute prod of group values.

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

    .. versionchanged:: 2.0.0

        numeric_only no longer accepts ``None``.

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

skipna : bool, default True
    Exclude NA/null values. If an entire group is NA, the result will be NA.

    .. versionadded:: 3.0.0

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

See Also
--------
Series.prod : Return the product of the values over the requested axis.
DataFrame.prod : Return the product of the values over the requested axis.

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).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
prodr  r  r  r  r  )r  r   r  )rt   r  r  r  s   &&&&rl   r  GroupBy.prod  s0    P   %77 ! 
 	
ro   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# r  rj   )rk   s   "rl   rm   r   T  C     r rr r 	r
 2r .rro   c           	         \        V4      '       d,   ^ RIHp V P                  V\        P
                  VVRVR7      # V P                  VVVR\        P                  R7      # )ay	  
Compute min of group values.

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

    .. versionchanged:: 2.0.0

        numeric_only no longer accepts ``None``.

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

skipna : bool, default True
    Exclude NA/null values. If the entire group is NA and ``skipna`` is
    ``True``, the result will be NA.

    .. versionchanged:: 3.0.0

engine : str, default None None
    * ``'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 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 both the ``func`` and the ``apply`` groupby aggregation.

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

See Also
--------
SeriesGroupBy.min : Return the min of the group values.
DataFrameGroupBy.min : Return the min of the group values.
SeriesGroupBy.max : Return the max of the group values.
DataFrameGroupBy.max : Return the max of the group values.
SeriesGroupBy.sum : Return the sum of the group values.
DataFrameGroupBy.sum : Return the sum of the group values.

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).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  8
grouped_min_maxFro  is_maxr  minr  )	rV   rw  r  r  r<   identity_dtype_mappingr  r   r  rt   r  r  r  r  r  r  s   &&&&&& rl   r  GroupBy.minS  sp    B 6""B**//% +   $$)#vv %  ro   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# r  rj   )rk   s   "rl   rm   r     r  ro   c           	         \        V4      '       d,   ^ RIHp V P                  V\        P
                  VVRVR7      # V P                  VVVR\        P                  R7      # )ay	  
Compute max of group values.

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

    .. versionchanged:: 2.0.0

        numeric_only no longer accepts ``None``.

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

skipna : bool, default True
    Exclude NA/null values. If the entire group is NA and ``skipna`` is
    ``True``, the result will be NA.

    .. versionchanged:: 3.0.0

engine : str, default None None
    * ``'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 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 both the ``func`` and the ``apply`` groupby aggregation.

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

See Also
--------
SeriesGroupBy.min : Return the min of the group values.
DataFrameGroupBy.min : Return the min of the group values.
SeriesGroupBy.max : Return the max of the group values.
DataFrameGroupBy.max : Return the max of the group values.
SeriesGroupBy.sum : Return the sum of the group values.
DataFrameGroupBy.sum : Return the sum of the group values.

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).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  9
r  Tr  maxr  )	rV   rw  r  r  r<   r  r  r   r  r  s   &&&&&& rl   r  GroupBy.max  sp    B 6""B**//% +   $$)#vv %  ro   c               (    V ^8  d   QhRRRRRRRR/# r  rj   )rk   s   "rl   rm   r   >  s2     R
 R
 R
58R
GKR
	R
ro   c                :    R R lpV P                  VVRVVR7      # )aT  
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 group 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.
core.groupby.DataFrameGroupBy.last : Compute the last non-null entry
    of each column.
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                   V ^8  d   QhRR/# re   r   r   rj   )rk   s   "rl   rm   #GroupBy.first.<locals>.__annotate__{  s     	+ 	+h 	+ro   c                    R  R lp\        V \        4      '       d   V P                  V4      # \        V \        4      '       d	   V! V 4      # \	        \        V 4      4      h)c                   V ^8  d   QhRR/# re   r/  rS   rj   )rk   s   "rl   rm   9GroupBy.first.<locals>.first_compat.<locals>.__annotate__|  s       ro   c                    V P                   \        V P                   4      ,          p\        V4      '       g!   V P                   P                  P                  # V^ ,          # )z-Helper function for first item that isn't NA.r'  r9   r   r  r  r/  arrs   & rl   first2GroupBy.first.<locals>.first_compat.<locals>.first|  s>    ggeAGGn-3xx77==1111vro   r   rG   r  rS   r  r"  )r   r  s   & rl   first_compat#GroupBy.first.<locals>.first_compat{  sK     #y))yy''C((Sz!S	**ro   r  r  r  )rt   r  r  r  r  s   &&&& rl   r  GroupBy.first=  s1    |	+   % ! 
 	
ro   c               (    V ^8  d   QhRRRRRRRR/# r  rj   )rk   s   "rl   rm   r     s2     A
 A
 A
58A
GKA
	A
ro   c                :    R R lpV P                  VVRVVR7      # )a,  
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 group 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.
core.groupby.DataFrameGroupBy.first : Compute the first non-null entry
    of each column.
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                   V ^8  d   QhRR/# r  rj   )rk   s   "rl   rm   "GroupBy.last.<locals>.__annotate__  s     	+ 	+X 	+ro   c                    R  R lp\        V \        4      '       d   V P                  V4      # \        V \        4      '       d	   V! V 4      # \	        \        V 4      4      h)c                   V ^8  d   QhRR/# r  rj   )rk   s   "rl   rm   7GroupBy.last.<locals>.last_compat.<locals>.__annotate__  s       ro   c                    V P                   \        V P                   4      ,          p\        V4      '       g!   V P                   P                  P                  # VR,          # )z,Helper function for last item that isn't NA.rE  r  r  s   & rl   last/GroupBy.last.<locals>.last_compat.<locals>.last  s>    ggeAGGn-3xx77==1112wro   r  )r   r	  s   & rl   last_compat!GroupBy.last.<locals>.last_compat  sJ     #y))yy&C((Cy S	**ro   r	  r  r  )rt   r  r  r  r  s   &&&& rl   r	  GroupBy.last  s1    Z	+   % ! 
 	
ro   c                   V ^8  d   QhRR/# )re   rh   rG   rj   )rk   s   "rl   rm   r     s     o oi oro   c                   V P                   P                  ^8X  d   V P                  p\        VP                  4      pV'       g   \        R4      hV P                  P                  RVP                  R^ RR7      p. ROpV P                   P                  W0P                  P                  VR7      pV# V P                  R 4      pV# )	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.

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

Examples
--------

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
zNo numeric types to aggregater  ohlc)r?  r  )rH  rv  c                "    V P                  4       # rq   )r  )sgbs   &rl   r   GroupBy.ohlc.<locals>.<lambda>E  s
    CHHJro   rE  )openhighlowclose)r   rR  r   r1   r  r$   r   r  rN  _constructor_expanddimrG  _apply_to_column_groupbys)rt   r   
is_numericr  	agg_namesr  s   &     rl   r  GroupBy.ohlc  s    | 88==A$$C)#))4J ?@@88S[[&qB 9 J 9IXX44--"<"<i 5 F M//0FGro   c                   V ^8  d   QhRR/# rX  rj   )rk   s   "rl   rm   r   H  s     P P
 
Pro   c                N  aaa V P                   p\        V4      ^ 8X  dd   VP                  SSSR7      pVP                  ^8X  d   TpMVP	                  4       pVP                  4       P                  P                  R,          # \        P                  ! V RR4      ;_uu_ 4        V P                  VVV3R lVRR7      pRRR4       XP	                  4       pV P                  '       g+   V P                  V4      p\        \        V4      4      Vn        V#   + '       g   i     L^; i)a-  
Generate descriptive statistics.

Descriptive statistics include those that summarize the central
tendency, dispersion and shape of a
dataset's distribution, excluding ``NaN`` values.

Analyzes both numeric and object series, as well
as ``DataFrame`` column sets of mixed data types. The output
will vary depending on what is provided. Refer to the notes
below for more detail.

Parameters
----------
percentiles : list-like of numbers, optional
    The percentiles to include in the output. All should
    fall between 0 and 1. The default, ``None``, will automatically
    return the 25th, 50th, and 75th percentiles.
include : 'all', list-like of dtypes or None (default), optional
    A white list of data types to include in the result. Ignored
    for ``Series``. Here are the options:

    - 'all' : All columns of the input will be included in the output.
    - A list-like of dtypes : Limits the results to the
      provided data types.
      To limit the result to numeric types submit
      ``numpy.number``. To limit it instead to object columns submit
      the ``numpy.object`` data type. Strings
      can also be used in the style of
      ``select_dtypes`` (e.g. ``df.describe(include=['O'])``). To
      select pandas categorical columns, use ``'category'``
    - None (default) : The result will include all numeric columns.
exclude : list-like of dtypes or None (default), optional,
    A black list of data types to omit from the result. Ignored
    for ``Series``. Here are the options:

    - A list-like of dtypes : Excludes the provided data types
      from the result. To exclude numeric types submit
      ``numpy.number``. To exclude object columns submit the data
      type ``numpy.object``. Strings can also be used in the style of
      ``select_dtypes`` (e.g. ``df.describe(exclude=['O'])``). To
      exclude pandas categorical columns, use ``'category'``
    - None (default) : The result will exclude nothing.

Returns
-------
Series or DataFrame
    Summary statistics of the Series or Dataframe provided.

See Also
--------
DataFrame.count: Count number of non-NA/null observations.
DataFrame.max: Maximum of the values in the object.
DataFrame.min: Minimum of the values in the object.
DataFrame.mean: Mean of the values.
DataFrame.std: Standard deviation of the observations.
DataFrame.select_dtypes: Subset of a DataFrame including/excluding
    columns based on their dtype.

Notes
-----
For numeric data, the result's index will include ``count``,
``mean``, ``std``, ``min``, ``max`` as well as lower, ``50`` and
upper percentiles. By default the lower percentile is ``25`` and the
upper percentile is ``75``. The ``50`` percentile is the
same as the median.

For object data (e.g. strings), the result's index
will include ``count``, ``unique``, ``top``, and ``freq``. The ``top``
is the most common value. The ``freq`` is the most common value's
frequency.

If multiple object values have the highest count, then the
``count`` and ``top`` results will be arbitrarily chosen from
among those with the highest count.

For mixed data types provided via a ``DataFrame``, the default is to
return only an analysis of numeric columns. If the DataFrame consists
only of object and categorical data without any numeric columns, the
default is to return an analysis of both the object and categorical
columns. If ``include='all'`` is provided as an option, the result
will include a union of attributes of each type.

The `include` and `exclude` parameters can be used to limit
which columns in a ``DataFrame`` are analyzed for the output.
The parameters are ignored when analyzing a ``Series``.

Examples
--------
Describing a numeric ``Series``.

>>> s = pd.Series([1, 2, 3])
>>> s.describe()
count    3.0
mean     2.0
std      1.0
min      1.0
25%      1.5
50%      2.0
75%      2.5
max      3.0
dtype: float64

Describing a categorical ``Series``.

>>> s = pd.Series(["a", "a", "b", "c"])
>>> s.describe()
count     4
unique    3
top       a
freq      2
dtype: object

Describing a timestamp ``Series``.

>>> s = pd.Series(
...     [
...         np.datetime64("2000-01-01"),
...         np.datetime64("2010-01-01"),
...         np.datetime64("2010-01-01"),
...     ]
... )
>>> s.describe()
count                      3
mean     2006-09-01 08:00:00
min      2000-01-01 00:00:00
25%      2004-12-31 12:00:00
50%      2010-01-01 00:00:00
75%      2010-01-01 00:00:00
max      2010-01-01 00:00:00
dtype: object

Describing a ``DataFrame``. By default only numeric fields
are returned.

>>> df = pd.DataFrame(
...     {
...         "categorical": pd.Categorical(["d", "e", "f"]),
...         "numeric": [1, 2, 3],
...         "object": ["a", "b", "c"],
...     }
... )
>>> df.describe()
       numeric
count      3.0
mean       2.0
std        1.0
min        1.0
25%        1.5
50%        2.0
75%        2.5
max        3.0

Describing all columns of a ``DataFrame`` regardless of data type.

>>> df.describe(include="all")  # doctest: +SKIP
       categorical  numeric object
count            3      3.0      3
unique           3      NaN      3
top              f      NaN      a
freq             1      NaN      1
mean           NaN      2.0    NaN
std            NaN      1.0    NaN
min            NaN      1.0    NaN
25%            NaN      1.5    NaN
50%            NaN      2.0    NaN
75%            NaN      2.5    NaN
max            NaN      3.0    NaN

Describing a column from a ``DataFrame`` by accessing it as
an attribute.

>>> df.numeric.describe()
count    3.0
mean     2.0
std      1.0
min      1.0
25%      1.5
50%      2.0
75%      2.5
max      3.0
Name: numeric, dtype: float64

Including only numeric columns in a ``DataFrame`` description.

>>> df.describe(include=[np.number])
       numeric
count      3.0
mean       2.0
std        1.0
min        1.0
25%        1.5
50%        2.0
75%        2.5
max        3.0

Including only string columns in a ``DataFrame`` description.

>>> df.describe(include=[object])  # doctest: +SKIP
       object
count       3
unique      3
top         a
freq        1

Including only categorical columns from a ``DataFrame`` description.

>>> df.describe(include=["category"])
       categorical
count            3
unique           3
top              d
freq             1

Excluding numeric columns from a ``DataFrame`` description.

>>> df.describe(exclude=[np.number])  # doctest: +SKIP
       categorical object
count            3      3
unique           3      3
top              f      a
freq             1      1

Excluding object columns from a ``DataFrame`` description.

>>> df.describe(exclude=[object])  # doctest: +SKIP
       categorical  numeric
count            3      3.0
unique           3      NaN
top              f      NaN
freq             1      NaN
mean           NaN      2.0
std            NaN      1.0
min            NaN      1.0
25%            NaN      1.5
50%            NaN      2.0
75%            NaN      2.5
max            NaN      3.0
percentilesincludeexclude:Nr<  Nr  Tc                ,   < V P                  SSSR 7      # )r  )describe)r/  r"  r!  r   s   &rl   r   "GroupBy.describe.<locals>.<lambda>K  s    !** +Wg % ro   )r3  N)r   r   r$  rR  unstackro  r\   r  r   r  r   r  rz  rQ   rH  )rt   r   r!  r"  r   	describedr  s   &fff   rl   r$  GroupBy.describeH  s    j ''s8q='' % I xx1}""**,??$&&++B//dJ55// !% 0 F 6 !}}}008F(V5FL 65s   #DD$	c                    V ^8  d   QhRRRR/# )re   r  r   rh   r^   rj   )rk   s   "rl   rm   r   [  s$     uG uG+/uG	uGro   c               L    ^ RI Hp V'       d   \        R4      hV! W.VO5/ VB # )a  
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

    .. versionchanged:: 3.0

       The default was changed to False, and True is no longer allowed.

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

Returns
-------
DatetimeIndexResampler, PeriodIndexResampler or TimdeltaResampler
    Resampler object for the type of the index.

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").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").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").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").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").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
)get_resampler_for_groupingr  )pandas.core.resampler+  r   )rt   ruler  rz   r{   r+  s   &&$*, rl   resampleGroupBy.resampleZ  s-    b 	DHII)$FtFvFFro   c               8    V ^8  d   QhRRRRRRRRR	RR
RRRRR/# )re   windowz9int | datetime.timedelta | str | BaseOffset | BaseIndexerro  
int | Nonecenterr   win_type
str | NoneonclosedzIntervalClosedType | NonerD  r   rh   ra   rj   )rk   s   "rl   rm   r     sd     \
 \
I\
  \
 	\

 \
 \
 *\
 \
 
\
ro   c                n    ^ RI Hp V! V P                  VVVVVVVV P                  V P                  R7
      # )a  
Return a rolling grouper, providing rolling functionality per group.

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

    If an integer, the delta between the start and end of each window.
    The number of points in the window depends on the ``closed`` argument.

    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
    :ref:`this link<timeseries.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.

closed : str, default None
    Determines the inclusivity of points in the window

    If ``'right'``, uses the window (first, last] meaning the last point
    is included in the calculations.

    If ``'left'``, uses the window [first, last) meaning the first point
    is included in the calculations.

    If ``'both'``, uses the window [first, last] meaning all points in
    the window are included in the calculations.

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

    () and [] are referencing open and closed set
    notation respetively.

    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
)ra   )	r1  ro  r3  r4  r6  r7  rD  r   	_as_index)pandas.core.windowra   r   r   r  )	rt   r1  ro  r3  r4  r6  r7  rD  ra   s	   &&&&&&&& rl   rollingGroupBy.rolling  sA    ` 	6#]]mm
 	
ro   c               $    V ^8  d   QhRRRRRR/# )re   ro  r   rD  r   rh   r_   rj   )rk   s   "rl   rm   r   r  s-     C
 C
C
 C
 
	C
ro   c                N    ^ RI Hp V! V P                  VVV P                  R7      # )a  
Return an expanding grouper, providing expanding functionality per group.

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

method : str {'single', 'table'}, default 'single'
    Execute the expanding 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.ExpandingGroupby
    An object that supports expanding transformations over each group.

See Also
--------
Series.expanding : Expanding transformations for Series.
DataFrame.expanding : Expanding transformations for DataFrames.
Series.groupby : Apply a function groupby to a Series.
DataFrame.groupby : Apply a function groupby.

Examples
--------
>>> df = pd.DataFrame(
...     {
...         "Class": ["A", "A", "A", "B", "B", "B"],
...         "Value": [10, 20, 30, 40, 50, 60],
...     }
... )
>>> df
Class  Value
0     A     10
1     A     20
2     A     30
3     B     40
4     B     50
5     B     60

>>> df.groupby("Class").expanding().mean()
        Value
Class
A     0   10.0
      1   15.0
      2   20.0
B     3   40.0
      4   45.0
      5   50.0
)r_   )ro  rD  r   )r:  r_   r   r   )rt   ro  rD  r_   s   &&& rl   	expandingGroupBy.expandingq  s+    z 	8#]]	
 	
ro   c               @    V ^8  d   QhRRRRRRRRRRR	R
RR
RRRRRR/
# )re   r   float | Nonespanhalflifezfloat | str | Timedelta | Nonealpharo  r2  adjustr   	ignore_natimesznp.ndarray | Series | NonerD  r   rh   r`   rj   )rk   s   "rl   rm   r     sz     g
 g
g
 g
 1	g

 g
  g
 g
 g
 *g
 g
 
(g
ro   c
                \    ^ RI Hp
 V
! V P                  VVVVVVVVV	V P                  R7      # )a  
Return an ewm grouper, providing ewm functionality per group.

Parameters
----------
com : float, optional
    Specify decay in terms of center of mass.
    Alternative to ``span``, ``halflife``, and ``alpha``.

span : float, optional
    Specify decay in terms of span.

halflife : float, str, or Timedelta, optional
    Specify decay in terms of half-life.

alpha : float, optional
    Specify smoothing factor directly.

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

adjust : bool, default True
    Divide by decaying adjustment factor to account for imbalance in
    relative weights.

ignore_na : bool, default False
    Ignore missing values when calculating weights.

times : str or array-like of datetime64, optional
    Times corresponding to the observations.

method : {'single', 'table'}, default 'single'
    Execute the operation per group independently (``'single'``) or over the
    entire object before regrouping (``'table'``). Only applicable to
    ``mean()``, and only when using ``engine='numba'``.

Returns
-------
pandas.api.typing.ExponentialMovingWindowGroupby
    An object that supports exponentially weighted moving transformations over
    each group.

See Also
--------
Series.ewm : EWM transformations for Series.
DataFrame.ewm : EWM transformations for DataFrames.
Series.groupby : Apply a function groupby to a Series.
DataFrame.groupby : Apply a function groupby.

Examples
--------
>>> df = pd.DataFrame(
...     {
...         "Class": ["A", "A", "A", "B", "B", "B"],
...         "Value": [10, 20, 30, 40, 50, 60],
...     }
... )
>>> df
Class  Value
0     A     10
1     A     20
2     A     30
3     B     40
4     B     50
5     B     60

>>> df.groupby("Class").ewm(com=0.5).mean()
             Value
Class
A     0  10.000000
      1  17.500000
      2  26.153846
B     3  40.000000
      4  47.500000
      5  56.153846
)r`   )
r   rC  rD  rE  ro  rF  rG  rH  rD  r   )r:  r`   r   r   )rt   r   rC  rD  rE  ro  rF  rG  rH  rD  r`   s   &&&&&&&&&& rl   ewmGroupBy.ewm  sA    t 	F-#]]
 	
ro   c                    V ^8  d   QhRRRR/# )re   	directionzLiteral['ffill', 'bfill']limitr2  rj   )rk   s   "rl   rm   r   "  s     I I8 I Iro   c                ^  a a	 Vf   RpS P                   P                  pS P                   P                  p\        \        P
                  VVVR8H  VR7      o	R V	V 3R llpS P                  4       pVP                  V4      pS P                  V4      pS P                  P                  Vn
        V# )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.
ffill)rX  rN  compute_ffillr   c                    V ^8  d   QhRRRR/# r  rj   )rk   s   "rl   rm   #GroupBy._fill.<locals>.__annotate__H  s     	 	Y 	9 	ro   c                (  < \        V 4      pV P                  ^8X  dP   \        P                  ! V P                  \        P
                  R7      pS! W!R7       \        P                  ! W4      # \        V \        P                  4      '       da   V P                  pSP                  P                  '       d   \        V P                  4      p\        P                  ! V P                  VR7      pM0\        V 4      P                  V P                  V P                  R7      p\!        V 4       Ff  w  rV\        P                  ! V P                  ^,          \        P
                  R7      pS! W!V,          R7       \        P                  ! Wb4      WER3&   Kh  	  V# )r&  r  )r  rY  r  )r7   rR  r   r)  r  r8  r:   r  r   ndarrayr  r   r6  r)   r"  _emptyrs  )	rT  rY  r[  r  r  ivalue_elementcol_funcrt   s	   &      rl   blk_funcGroupBy._fill.<locals>.blk_funcH  s   <D{{a((6<<rww?W0!))&::
 fbjj11"LLE}}333 8 F((6<<u=C v,--fll&,,-OC(1&(9$A hhv||AbggFGAw7 * 2 2= JC1I	 ):
 
ro   rE  )r   rI  r   r	   
libgroupbygroup_fillna_indexerr  r  r  r   rH  )
rt   rM  rN  rI  r   rZ  mgrr  rh  rY  s
   f&&      @rl   _fillGroupBy._fill!  s    2 =Emm--''++$/
	 	< ))+))H%**73ro   c                   V ^8  d   QhRR/# re   rN  r2  rj   )rk   s   "rl   rm   r   n  s     Y0 Y0: Y0ro   c                (    V P                  RVR7      # )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 columns.

>>> 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
rP  rN  r_  rt   rN  s   &&rl   rP  GroupBy.ffillm  s    t zz'z//ro   c                   V ^8  d   QhRR/# rb  rj   )rk   s   "rl   rm   r     s     N0 N0: N0ro   c                (    V P                  RVR7      # )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
bfillrd  re  rf  s   &&rl   rj  GroupBy.bfill  s    ^ zz'z//ro   c                   V ^8  d   QhRR/# )re   rh   rN   rj   )rk   s   "rl   rm   r     s     Q( Q(' Q(ro   c                    \        V 4      # )ar  
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.

Returns
-------
Series or DataFrame
    N-th value within each group.

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

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: []
)rN   r   s   &rl   nthGroupBy.nth  s    f "$''ro   c               $    V ^8  d   QhRRRRRR/# )re   r   zPositionalIndexer | tupler  zLiteral['any', 'all'] | Nonerh   r   rj   )rk   s   "rl   rm   r   o  s(     5 5$5 -5 
	5ro   c                	X   V'       gF   V P                  V4      pV P                  P                  pW4R	8g  ,          pV P                  V4      pV# \	        V4      '       g   \        R4      hVR
9  d   \        RV R24      h\        \        V4      pV P                  P                  V^ R7      p\        V4      \        V P                  4      8X  d   V P                  pMV P                  P                  pV P                  P                  VP                  VP                  4      ,          pV P                  P                  '       d0   VR	8H  p	\         P"                  ! V	\$        V4      p
\'        V
RRR7      pVP)                  WpP*                  V P,                  R7      pVP/                  V4      # )r&  z4dropna option only supported for an integer argumentz_For a DataFrame or Series groupby.nth, dropna must be either None, 'any' or 'all', (was passed z).)r  r?  Int64F)r  rb  )r  r  rE  r  )"_make_mask_from_positional_indexerr   rI  _mask_selected_objr.   r   r   r   r   r  r   r?  
codes_infoisinrH  r6  r   r+  r   rO   rf   r  r  rn  )rt   r   r  rY  rI  r  droppedr  r?  nullsrT  grbs   &&&         rl   _nthGroupBy._ntho  se   
 ::1=D--##C "9%D))$/CJ !}}STT'%hb*  aL$$++Q+? w<3t1122mmG
 ==%%Dmm..tyy/GHG}}+++2 %W5gEBoogDIIoNwwqzro   c               $    V ^8  d   QhRRRRRR/# )re   qzfloat | AnyArrayLikeinterpolationz;Literal['linear', 'lower', 'higher', 'nearest', 'midpoint']r  r   rj   )rk   s   "rl   rm   r     s-     Z= Z=Z=
Z= Z=ro   c           	     ^  aaaaaa V P                  VRR7      pV P                  V4      pV P                  P                  V4      pVP                  p\
        P                  ! VP                  VP                  4      w  rR R loR V3R llo\        V4      '       d+   \        P                  ! V.\        P                  R7      p
RpM(\        P                  ! V\        P                  R7      p
T
pV P                  P                  pV P                  P                  oV P                  '       d   W^ 8  ,          p\!        V
4      o\#        \$        P&                  VV
SVV	R	7      oR
 VVVVV3R llpVP(                  P+                  V4      pV P                  V4      pV P-                  WR7      # )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.

    .. 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  c                    V ^8  d   QhRRRR/# )re   valsr   rh   z"tuple[np.ndarray, DtypeObj | None]rj   )rk   s   "rl   rm   &GroupBy.quantile.<locals>.__annotate__  s     $	" $	"	 $	".P $	"ro   c                   \        V P                  \        4      '       g   \        V P                  4      '       d   \	        R V P                   R24      hRp\        V \
        4      '       dP   \        V P                  4      '       d5   V P                  \        \        P                  R7      pV P                  pW!3# \        V P                  4      '       df   \        V \        4      '       d'   V P                  \        \        P                  R7      pMT p\        P                  ! \        P                  4      pW!3# \        V P                  4      '       d?   \        V \        4      '       d)   V P                  \        \        P                  R7      pW!3# \        V P                  4      '       d   \	        R4      h\        V P                  4      '       d   V P                  pW3# \        V \        4      '       dh   \!        V P                  4      '       dM   \        P                  ! \        P"                  4      pV P                  \        \        P                  R7      pW!3# \        P$                  ! V 4      pW!3# )zdtype 'z'' does not support operation 'quantile'N)r  r  z#Cannot use quantile with bool dtype)r   r  rC   r2   r  r>   r1   r  floatr   r   r/   r?   r$  r+   r5   r,   r7  asarray)r  	inferencer  s   &  rl   pre_processor'GroupBy.quantile.<locals>.pre_processor  s   $**k22odjj6Q6Qdjj\)PQ  *.I$005Edjj5Q5Qmm%"&&mA JJ	6 >!5 "$**--dN33--ebff-ECCHHRXX.	* >!) tzz**z$/O/Omm%"&&mA& >!% tzz** EFF$TZZ00 JJ	 &D.11nTZZ6P6PHHRZZ0	mm%"&&mA >! jj&>!ro   c          
     ,    V ^8  d   QhRRRRRRRRR	R/# )
re   r  r1  r  zDtypeObj | Noneresult_maskznp.ndarray | None	orig_valsr   rh   rj   )rk   s   "rl   rm   r    s:     0	 0	0	&0	 +0	 !	0	
 0	ro   c                  < V'       EdP   \        V\        4      '       d   Vf   Q hSR9   d   \        V4      '       g   \        W4      # \        P
                  ! 4       ;_uu_ 4        \        P                  ! R\        R7       \        V4      ! V P                  VP                  4      V4      uuR R R 4       # \        V4      '       d   SR9   g   \        V4      '       dF   V P                  R4      P                  VP                  P                  4      p VP!                  V 4      # \        V\"        P                  4      '       g   Q hV P                  V4      # V #   + '       g   i     T # ; i)Nignore)categoryi8>   linearmidpoint)r   r>   r,   r@   r   catch_warningsfilterwarningsRuntimeWarningr"  r  numpy_dtyper/   r5   view_ndarrayr  _from_backing_datar   )r  r  r  r  r~  s   &&&&rl   post_processor(GroupBy.quantile.<locals>.post_processor  s9    yi99&222$(>>~!H H  -T??
 &446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)rX  rk  r~  r  r  c                    V ^8  d   QhRRRR/# r  rj   )rk   s   "rl   rm   r  L  s     0	J 0	JY 0	J9 0	Jro   c           	     (  < T p\        V \        4      '       d6   V P                  p\        P                  ! SS3\        P
                  R 7      pM\        V 4      pRp\        V P                  4      pS! V 4      w  rV^pVP                  ^8X  d   VP                  ^ ,          p\        P                  ! VSS3\        P                  R 7      pV'       d   VP                  R4      pVP                  ^8X  d   S
! V^ ,          VVVVR7       M1\        V4       F"  p	S
! W,          WY,          W),          RVR7       K$  	  VP                  ^8X  d(   VP                  R4      pVe   VP                  R4      pMVP!                  VSS,          4      pS! WW14      # )r  Nr  )rT  rY  r  is_datetimelikeK)r   r>   _maskr   ra  rb  r7   r5   r  rR  r  r)  r7  r  r  r  r_  )rT  r  rY  r  r  r  r  ncolsr  rW  r   r   nqsr  r  s   &         rl   rZ  "GroupBy.quantile.<locals>.blk_funcL  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Iro   r~  )r  r  r   _get_splitter_sorted_datar   r  _slabelsr   r3   r   r'  r7  r  rI  r  r   r	   r\  group_quantiler  r  r  )rt   r}  r~  r  r^  r   splittersdatar  r  rk  pass_qsrI  rZ  r  r  r   r   r  r  r  s   &&f&            @@@@@rl   r  GroupBy.quantile  s^   ` ))|*)U&&s+==..s3%%**8+<+<h>N>NO$	"L0	 0	d Q<<1#RZZ0B)-GARZZ0BGmm--'';;;Qh-C"g%%'
0	J 0	Jd **++H5&&w/++C+<<ro   c                   V ^8  d   QhRR/# re   r0  r   rj   )rk   s   "rl   rm   r     s     P P Pro   c                   V P                   pVP                  pV P                  P                  pV P                  P                  '       d;   \
        P                  ! VR8H  \
        P                  V4      p\
        P                  pM\
        P                  p\        ;QJ d0    R V P                  P                   4       F  '       g   K   RM%	  RM!! R V P                  P                   4       4      '       d   \        VRR7      ^,
          pV P                  WCVR7      pV'       g   V P                  ^,
          V,
          pV# )aY  
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   NaN
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
c              3  8   "   T F  qP                   x  K  	  R # 5irq   _passed_categoricalr   pings   & rl   r   !GroupBy.ngroup.<locals>.<genexpr>  s     L4KD''4K   TFdense)ties_methodr  rE  )r   rH  r   rI  r6  r   r+  r   r7  r$  r  rp  r   rD  r   )rt   r0  r   rH  comp_idsr  r  s   &&     rl   ngroupGroupBy.ngroup  s    ~ ''		==$$ =='''xxBAHJJEHHE3LDMM4K4KL333LDMM4K4KLLLxW=AH))()G\\A%.Fro   c                   V ^8  d   QhRR/# r  rj   )rk   s   "rl   rm   r     s     6: 6:$ 6:ro   c                t    V P                   P                  pV P                  VR7      pV P                  W24      # )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
)r0  )r   rH  r?  rD  )rt   r0  rH  	cumcountss   &&  rl   cumcountGroupBy.cumcount  s:    j ))//((9(=	''	99ro   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	re   rD  r   r0  r   	na_optionpctrh   r   rj   )rk   s   "rl   rm   r     sC     W
 W
W
 W
 	W

 W
 
W
ro   c                f    VR9  d   Rp\        V4      hRVRVRVRV/pV P                  ! R	RR/VB # )
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.

Returns
-------
DataFrame
    The ranking of values within each group.

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

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
z3na_option must be one of 'keep', 'top', or 'bottom'r  r0  r  r  r  F>   topkeepbottom)rank)r   r
  )rt   rD  r0  r  r  r   r{   s   &&&&&  rl   r  GroupBy.rank  sa    R 55GCS/! 63	
 %% 

 
 	
ro   c                    V ^8  d   QhRRRR/# re   r  r   rh   r   rj   )rk   s   "rl   rm   r   j  s     =I =ID =Ih =Iro   c                \    \         P                  ! RW#R.4       V P                  ! RV3/ VB # )a  
Cumulative product for each group.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.
*args : tuple
    Positional arguments to be passed to `func`.
**kwargs : dict
    Additional/specific keyword arguments to be passed to the function,
    such as `numeric_only` and `skipna`.

Returns
-------
Series or DataFrame
    Cumulative product for each group. Same object type as the caller.

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

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  nvvalidate_groupby_funcr
  rt   r  rz   r{   s   &&*,rl   r  GroupBy.cumprodi  s1    z 	  D8*E%%iHHHro   c                    V ^8  d   QhRRRR/# r  rj   )rk   s   "rl   rm   r     s     =H =H4 =HX =Hro   c                \    \         P                  ! RW#R.4       V P                  ! RV3/ VB # )a  
Cumulative sum for each group.

Parameters
----------
numeric_only : bool, default False
    Include only float, int, boolean columns.
*args : tuple
    Positional arguments to be passed to `func`.
**kwargs : dict
    Additional/specific keyword arguments to be passed to the function,
    such as `numeric_only` and `skipna`.

Returns
-------
Series or DataFrame
    Cumulative sum for each group. Same object type as the caller.

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

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
r6  r  r  r  s   &&*,rl   r6  GroupBy.cumsum  s1    z 	  4(D%%hGGGro   c                    V ^8  d   QhRRRR/# r  rj   )rk   s   "rl   rm   r     s"     G
 G
G
 
	G
ro   c                L    VP                  RR4      pV P                  RWR7      # )a  
Cumulative min for each group.

Parameters
----------
numeric_only : bool, default False
    Include only `float`, `int` or `boolean` data.
**kwargs : dict, optional
    Additional keyword arguments to be passed to the function, such as `skipna`,
    to control whether NA/null values are ignored.

Returns
-------
Series or DataFrame
    Cumulative min for each group. Same object type as the caller.

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

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cumminrs  r   r
  rt   r  r{   r  s   &&, rl   r  GroupBy.cummin  s2    J Hd+%%< & 
 	
ro   c                    V ^8  d   QhRRRR/# r  rj   )rk   s   "rl   rm   r   4  s"     K
 K
K
 
	K
ro   c                L    VP                  RR4      pV P                  RWR7      # )a  
Cumulative max for each group.

Returns the cumulative maximum of values within each group. The result
has the same size as the input, with each element representing the
maximum of all preceding elements (including itself) within its group.

Parameters
----------
numeric_only : bool, default False
    Include only `float`, `int` or `boolean` data.
**kwargs : dict, optional
    Additional keyword arguments to be passed to the function, such as `skipna`,
    to control whether NA/null values are ignored.

Returns
-------
Series or DataFrame
    Cumulative max for each group. Same object type as the caller.

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

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cummaxrs  r  r  s   &&, rl   r  GroupBy.cummax3  s2    R Hd+%%< & 
 	
ro   c                    V ^8  d   QhRRRR/# )re   periodszint | Sequence[int]suffixr5  rj   )rk   s   "rl   rm   r     s"     N
 N
$N

 N
ro   c           	       aaa \        V4      '       d5   \        \        V4      p\        V4      ^ 8X  d   \	        R4      h^ RIHp RpMR\        V4      '       g   \        RV R\        V4       R24      hV'       d   \	        R4      h\        \        V4      .pRp. pV EF  o\        S4      '       g   \        RS R\        S4       R24      h\        \        S4      oSe'   VVV3R
 lpV P                  WP                  RR7      p	MS\        P                  J d   R	oV P                  P                   p
V P                  P"                  p\$        P&                  ! \        V
4      \$        P(                  R7      p\*        P,                  ! WVS4       V P.                  pVP1                  ^ VP2                  V3/SRR7      p	V'       dX   \5        V	\6        4      '       d   \        \8        V	P;                  4       4      p	T	P=                  V'       d   V RS 2MRS 24      p	VP?                  \        \@        \6        \B        3,          V	4      4       EK  	  \        V4      ^8X  d
   V^ ,          # X! V^RR7      # )a  
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.
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
z0If `periods` is an iterable, it cannot be empty.r=  TzPeriods must be integer, but z is .z/Cannot specify `suffix` if `periods` is an int.FNc                ,   < V P                  SS^ S4      # )r<  )shift)r/  
fill_valuefreqperiods   &rl   r   GroupBy.shift.<locals>.<lambda>  s    agg	ro   r2  r  )r  r  r\  )r?  r  )"r0   r   r   r   r   rF  r>  r.   r  r"  r   r   r   r   
no_defaultr   rI  r   r   ra  r$  r\  group_shift_indexerr   r  rH  r   rS   r   ro  
add_suffixappendr   rG   )rt   r  r  r  r  r>  r  shifted_dataframesr|   shiftedrI  r   res_indexerr   r  s   &&ff&         @rl   r  GroupBy.shift  sB   `   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 44)) 5  /!%Jmm''--// hhs3xrxx@..{&Q//44K01)# 5  gv.."8W-=-=-?@G!,,,2vhax(!F8 %%d51B+CW&MNO V %&!+ q!	
 *?	
ro   c                    V ^8  d   QhRRRR/# )re   r  r   rh   r   rj   )rk   s   "rl   rm   r     s"     W WW 
Wro   c                   V P                   pV P                  VR7      pRR.pVP                  ^8X  d+   VP                  V9   d   VP	                  R4      pW#,
          # VP
                  P                  4        UUu. uF  w  rVWd9   g   K  VNK  	  pppV'       d&   VP	                  \        P                  VR4      4      pW#,
          # u uppi )a  
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.

Returns
-------
Series or DataFrame
    First differences.

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

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  int8int16float32)	r   r  rR  r  r  dtypesitemsdictfromkeys)rt   r  r   r  dtypes_to_f32cr  	to_coerces   &&      rl   r4  GroupBy.diff  s    T ''**W*-  )88q=yyM)!..3 }	 ,/::+;+;+=X+=xqAW+=IX!..y))LM}	 Ys   ;
C
Cc                    V ^8  d   QhRRRR/# )re   r  r   fill_methodri   rj   )rk   s   "rl   rm   r   m  s"     a& a&a& a&ro   c                Z  aa Ve   \        RV: R24      hSe%   VV3R lpV P                  W@P                  RR7      # Vf   RpMTp\        W4      ! ^ R7      pVP	                  V P
                  P                  V P                  R7      pVP                  SSR	7      pWh,          ^,
          # )
aA  
Calculate pct_change of each value to previous entry in group.

Parameters
----------
periods : int, default 1
    Periods to shift for calculating percentage change. Comparing with
    a period of 1 means adjacent elements are compared, whereas a period
    of 2 compares every other element.

fill_method : None
    Must be None. This argument will be removed in a future version of pandas.

freq : str, pandas offset object, or None, default None
    The frequency increment for time series data (e.g., 'M' for month-end).
    If None, the frequency is inferred from the index. Relevant for time
    series data only.

Returns
-------
Series or DataFrame
    Percentage changes within each group.

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

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
z*fill_method must be None; got fill_method=r  c                ,   < V P                  SS^ R7      # )r<  )r  r  r?  )
pct_change)r/  r  r  s   &rl   r   $GroupBy.pct_change.<locals>.<lambda>  s    !,, ' ro   Tr  rP  rd  )r   )r  r  )	r   r   r   r   rf   r   codesr   r  )	rt   r  r  r  r|   opfilledfill_grpr  s	   &f&f     rl   r  GroupBy.pct_changel  s    \ "Jk^1MNN A
 --a1C1CRV-WWBB"+>>$--"5"5$//>R..t.< A%%ro   c                    V ^8  d   QhRRRR/# re   r   r   rh   r   rj   )rk   s   "rl   rm   r     s     %- %-c %-( %-ro   c                Z    V P                  \        RV4      4      pV P                  V4      # )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
--------
Series.head : Apply function head to a Series.
DataFrame.head : Apply function head to each row or column of a DataFrame.

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rs  slicert  rt   r   rY  s   && rl   headGroupBy.head  s,    J 66uT1~F&&t,,ro   c                    V ^8  d   QhRRRR/# r  rj   )rk   s   "rl   rm   r     s     ,- ,-c ,-( ,-ro   c                    V'       d   V P                  \        V) R4      4      pMV P                  . 4      pV P                  V4      # )aQ  
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
--------
Series.tail : Apply function tail to a Series.
DataFrame.tail : Apply function tail to each row or column of a DataFrame.

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   && rl   tailGroupBy.tail  sA    P ::5!T?KD::2>D&&t,,ro   c                    V ^8  d   QhRRRR/# )re   rY  znpt.NDArray[np.bool_]rh   r   rj   )rk   s   "rl   rm   r   (  s     ( ('< ( (ro   c                j    V P                   P                  pWR8g  ,          pV P                  V,          # )z
Return _selected_obj with mask applied.

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

Returns
-------
Series or DataFrame
    Filtered _selected_obj.
rE  )r   rI  r   )rt   rY  rI  s   && rl   rt  GroupBy._mask_selected_obj'  s0     mmby!!!$''ro   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )re   r   r2  fracrB  replacer   weightszSequence | Series | Nonerandom_statezRandomState | Nonerj   )rk   s   "rl   rm   r   ;  sJ     z@ z@z@ z@ 	z@
 *z@ )z@ro   c           	        V P                   P                  '       d   V P                   # \        P                  ! WV4      pVe$   \        P                  ! V P                   V^ R7      p\
        P                  ! V4      pV P                  P                  V P                   4      p. p	V F  w  rV P                  V
,          p\        V4      pVe   TpMVf   Q h\        W-,          4      p\        P                  ! TTTVf   RMXV,          VR7      pV	P                  W,          4       K  	  \        P                  ! V	4      p	V P                   P                  V	^ R7      # )ad	  
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.
    Default ``None`` results in sampling with the current state of np.random.

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.
Series.sample: Generate random samples from a Series 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
NrB  )r  r  r  r  )r   r)  r;   process_sampling_sizepreprocess_weightsr   r  r   r  r   r   roundr  r   r(  rP  )rt   r   r  r  r  r  r  weights_arrgroup_iteratorsampled_indicesrX  r   grp_indices
group_sizesample_size
grp_samples   &&&&&&          rl   r;   GroupBy.sample:  s4   x ###%%%++AW= 33D4F4FVWXK''533D4F4FG)KF,,v.K[)J"'''#D$56  '[5M)J "";#:;! *$ ..9!!&&Q&??ro   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	re   r  Literal['idxmax', 'idxmin']ignore_unobservedr   r  r  rh   r   rj   )rk   s   "rl   rm   r     s<     < <(<  < 	<
 < 
<ro   c                n   V P                   '       EgG   \        ;QJ d0    R V P                  P                   4       F  '       g   K   RM%	  RM!! R V P                  P                   4       4      '       d   \	        V P                  P
                  4      pV P                  P                  4       pWf^ 8  ,          P                  ^ ,          pWu8:  g   Q hWu8  pV'       * ;'       d    Tp	V P                  p
V	'       dG   \        V
\        4      '       d1   V'       d   V
P                  4       p
\	        V
P                  4      ^ 8  p	V	'       d   \        RV R24      hMFV'       g?   V P                  P                  4       P                  RR7      '       d   \        V R24      hV P                  V^VVR	7      pV# )
aF  Compute idxmax/idxmin.

Parameters
----------
how : {'idxmin', 'idxmax'}
    Whether to compute idxmin or idxmax.
numeric_only : bool, default False
    Include only float, int, boolean columns.
skipna : bool, default True
    Exclude NA/null values. If an entire group 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.
c              3  8   "   T F  qP                   x  K  	  R # 5irq   r  r  s   & rl   r   )GroupBy._idxmax_idxmin.<locals>.<genexpr>  s      %
1H$$1Hr  TFz
Can't get zZ of an empty group due to unobserved categories. Specify observed=True in groupby instead.NrB  z+ with skipna=False encountered an NA value.)r  r  r  r  )r  r  r   rp  r   rG  r  r  r   r   rG   _get_numeric_datarv  r   r7   r  )rt   r  r-  r  r  expected_lengroup_sizes
result_lenhas_unobserved	raise_errr  r  s   &&&&&       rl   r  GroupBy._idxmax_idxmin  s|   4 }}} %
151H1H%
 %
151H1H%
 "
 "
 t}}99:L--,,.K$1_5;;A>J---'6N->)>)Q)Q>I ,,DZi88113D-1	   &@ @  
 D55::<@@d@KKu$OPQQ""%	 # 
 ro   c               (    V ^8  d   QhRRRRRRRR/# )re   r  r   r  r,  r  r   rh   rj   )rk   s   "rl   rm   r     s,      "=GK	ro   c                	   V P                   P                  pVP                  ^ 8X  d   VP                  VP                  4      pV# V'       d6   VP                  ^ 4      P                  RR7      '       d   \        V R24      h\        V\        4      '       d   VP                  4       pVP                  p\        V\        P                  4      '       g   Q h\        VP                  RR7      p\        V\        4      '       dG   VP!                  VP"                  P%                  VRVR7      VP                  VP&                  R7      pV# / p\)        VP*                  4       F%  w  rVP"                  P%                  V
RVR7      W&   K'  	  V P                   P!                  WP                  R	7      pVP,                  Vn        V# )
r<  NrB  z7 with skipna=True encountered all NA values in a group.F)compatT)
allow_fillr  r  )rH  )r   rH  r  r  r  ltr  r   r   rP   to_flat_indexrN  r   rU  r8   rS   r  r'  rP  r   rs  r\   rv  )rt   r  r  r  rH  r  rT  r  r  kcolumn_valuess   &&&&       rl   r  GroupBy._wrap_idxmax_idxmin  ss    88q=ZZ,F4 3 q	400%NO  %,,++-[[Ffbjj1111)%++eDH#v&&))KK$$V$R)) *   (1&(((;$A#kk..%$8 / DG )< ..t99.E!$ro   )r   r   r  r  r  r   r   r   r   r  r  )
NNNNNTTTFT)FFrq   )NFF)FrE  )NFrE  )F)T)FTNN)FT)r&  NNFT)NFTFT)r&  FT)Fr<  TNN)Fr<  T)FrE  TNN)FrE  T)NNN)NFNNNsingle)r&  rA  )	NNNNr<  TFNrA  )g      ?r  F)averageTr  F)r&  )r&  NN)   )NNFNN)FTF)Or~   r   r   r   r   r  r   ru   r   r8  r]  r7  rz  r  r  r  r  r  r  r  r   r  r  r  r
  r  r  r  r-  r?  r  rD  r  r  r;  rp  r|  r  r  r  r  r  r  r  r  r  r  r	  r  r$  r.  r;  r?  rJ  r_  rP  rj  rn  rz  r  r  r  r  r  r6  r  r  r   r  r  r4  r  r  r  rt  r;   r  r  r   rj   ro   rl   rg   rg     s   @D N
&O &OP
  B >? >?@  2 & &P " "H( 
 
4)V %Gt %G %GN %t % %TcH cHJ +
 +
Z ? #'? ?$-9^ 1 1f( T   < 8"&86:8 8*  6    $ $P %  % 9
 9
v :
 :
x e eN dC dCL a? a?F q qf n n` zD zDx g
 g
R _ _B w wr M
 M
^ r rh r rh R
 R
h A
 A
F o obPd uG27uG uGn \
 \
| C
 C
J g
 g
R I IV Y0 Y0v N0 N0` Q(  Q(f5n Z= Z=x P Pd 6: 6:p W
 W
r =I =I~ =H =H~ G
 G
R K
 K
Z  ()>>!N
 N
` W Wr a& a&F %- %-N ,- ,-\ ( ($ z@ z@x<| ro   rg   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )re   r   rH   byr   r  r  r   r   rh   rg   rj   )rk   s   "rl   rm   rm     sA     Z0 Z0	Z0Z0 $Z0 	Z0
 Z0ro   c                    \        V \        4      '       d   ^ RIHp V! V VVVR7      # \        V \        4      '       d   ^ RIHp V! V VVVR7      # \        RV  24      h)r  )SeriesGroupBy)r   r   r  r   )DataFrameGroupByzinvalid type: )r   rS   pandas.core.groupby.genericrG  rG   rH  r  )r   rE  r  r   rG  rH  s   &&&&  rl   get_groupbyrJ    sm    N #v=!	
 	
 
C	#	#@!	
 	
 ..//ro   c               $    V ^8  d   QhRRRRRR/# )re   r  rO   rk  znpt.NDArray[np.float64]rh   rP   rj   )rk   s   "rl   rm   rm   t  s"       +B z ro   c                   \        V4      p\        VRR7      P                  4       w  r4\        W44      pV P                  '       d   \        \        V 4      p . V P                  OVNpV P                   Uu. uF  p\        P                  ! Wb4      NK  	  up\        P                  ! V\        V 4      4      .,           p\        WW. V P                  ORNR7      pV# \        V 4      p	\        \        P                  ! V	4      V 4      p
W.p\        P                  ! W4      \        P                  ! W94      .p\        WWV P                  R.R7      pV# u upi )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
Fra  N)r@  r  rA  )r   rO   	factorizer(   	_is_multir   rP   r@  r  r   rw  rr  rA  r9  r   )r  rk  r  	lev_codesry  r@  r/  r  minidx	idx_codess   &&         rl   r  r  t  s    b'C2E*446NI$Y4I
}}}:s##3::#s#,/II6Iq1"I6"'')SQTX:V9WWv:LCII:Lt:LM I 3x(4#>	9*BGGI,DEv388T:JKI 7s   4E)NNT)__conditional_annotations__r   
__future__r   collections.abcr   r   r   r   r   r   r   	functoolsr	   r
   typingr   r   r   r   r   r   r   r   r   r   r   numpyr   pandas._libsr   r   pandas._libs.algosr   pandas._libs.groupby_libsrf   r\  pandas._libs.missingr   pandas._typingr   r   r   r   r   r   r   r    r!   pandas.compat.numpyr"   r  pandas.errorsr#   r$   r%   pandas.util._decoratorsr&   pandas.util._exceptionsr'   pandas.core.dtypes.castr(   r)   pandas.core.dtypes.commonr*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   pandas.core.dtypes.missingr7   r8   r9   pandas.corer:   r;   pandas.core._numbar<   pandas.core.arraysr=   r>   r?   r@   rA   rB   pandas.core.arrays.string_rC   pandas.core.arrays.string_arrowrD   pandas.core.baserE   rF   pandas.core.commoncorecommonr   pandas.core.framerG   pandas.core.genericrH   pandas.core.groupbyrI   rJ   rK   pandas.core.groupby.grouperrL   pandas.core.groupby.indexingrM   rN   pandas.core.indexes.apirO   rP   rQ   pandas.core.internals.blocksrR   pandas.core.seriesrS   pandas.core.sortingrT   pandas.core.util.numba_rU   rV   rW   pandas._libs.tslibsrX   pandas._libs.tslibs.timedeltasrY   rZ   r[   r\   pandas.core.indexers.objectsr]   r,  r^   r:  r_   r`   ra   #_groupby_agg_method_engine_template*_groupby_agg_method_skipna_engine_template_pipe_template_transform_templaterc   r   r   r  r   r  rg   rJ  r  )rS  s   @rl   <module>r     s   #       ' ) ) #
 
 
 / 
 3 4     (  3 < !   ' ' 
 4 
 < % 6  .8  9. 0' #d6. *p6p[ | ,  4 
8nz8#$% 8XJ()*+ h !	" i `,x 8:N `H 37C nPk(# nPbaZ0zro   