+
    Ŝi                       R t ^ RIHt ^ RIHtHt ^ RIt^ RIH	t
 ^ RIHt ^ RIHt ^ RIHtHt ^ RIHtHtHtHt ^ R	IHt ^ R
IHt ^ RIHtHt ^ RIHu H t! ^ RI"H#t# ^ RI$H%t% ^ RI&H't' ^ RI(H)t)H*t*H+t+ ^ RI,H-t- ^ RI.H/t/H0t0 ]'       d   ^ RI1H2t2H3t3 ^ RI4H5t5H6t6H7t7 ^ RI8H9t9 ]! R4       ! R R4      4       t:] ! R R4      4       t;R R R llt<R R lt=R R lt>R# )!z]
Provide user facing operators for doing the split part of the
split-apply-combine paradigm.
)annotations)TYPE_CHECKINGfinalN)algos)OutOfBoundsDatetime)InvalidIndexError)cache_readonly
set_module)ensure_int64ensure_platform_intis_list_like	is_scalar)CategoricalDtype)
algorithms)CategoricalExtensionArray)	DataFrame)ops)recode_for_groupby)Index
MultiIndexdefault_index)Series)
PrettyDictpprint_thing)HashableIterator)	ArrayLikeNDFrameTnpt)NDFramepandasc                     a  ] tR t^Et$ RtR]R&   R]R&   R]R&   RtR]R&   V 3R	 ltRR R lltRR R llt	RRR
/R R lllt
]R R l4       tRtV ;t# )Groupera  
A Grouper allows the user to specify a groupby instruction for an object.

This specification will select a column via the key parameter, or if the
level parameter is given, a level of the index of the target
object.

If ``level`` is passed as a keyword to both `Grouper` and
`groupby`, the values passed to `Grouper` take precedence.

Parameters
----------
*args
    Currently unused, reserved for future use.
**kwargs
    Dictionary of the keyword arguments to pass to Grouper.

Attributes
----------
key : str, defaults to None
    Groupby key, which selects the grouping column of the target.
level : name/number, defaults to None
    The level for the target index.
freq : str / frequency object, defaults to None
    This will groupby the specified frequency if the target selection
    (via key or level) is a datetime-like object. For full specification
    of available frequencies, please see :ref:`here<timeseries.offset_aliases>`.
sort : bool, default to False
    Whether to sort the resulting labels.
closed : {'left' or 'right'}
    Closed end of interval. Only when `freq` parameter is passed.
label : {'left' or 'right'}
    Interval boundary to use for labeling.
    Only when `freq` parameter is passed.
convention : {'start', 'end', 'e', 's'}
    If grouper is PeriodIndex and `freq` parameter is passed.

origin : Timestamp or str, default 'start_day'
    The timestamp on which to adjust the grouping. The timezone of origin must
    match the timezone of the index.
    If string, must be one of the following:

    - 'epoch': `origin` is 1970-01-01
    - 'start': `origin` is the first value of the timeseries
    - 'start_day': `origin` is the first day at midnight of the timeseries

    - 'end': `origin` is the last value of the timeseries
    - 'end_day': `origin` is the ceiling midnight of the last day

offset : Timedelta or str, default is None
    An offset timedelta added to the origin.

dropna : bool, default True
    If True, and if group keys contain NA values, NA values together with
    row/column will be dropped. If False, NA values will also be treated as
    the key in groups.

Returns
-------
Grouper or pandas.api.typing.TimeGrouper
    A TimeGrouper is returned if ``freq`` is not ``None``. Otherwise, a Grouper
    is returned.

See Also
--------
Series.groupby : Apply a function groupby to a Series.
DataFrame.groupby : Apply a function groupby.

Examples
--------
``df.groupby(pd.Grouper(key="Animal"))`` is equivalent to ``df.groupby('Animal')``

>>> df = pd.DataFrame(
...     {
...         "Animal": ["Falcon", "Parrot", "Falcon", "Falcon", "Parrot"],
...         "Speed": [100, 5, 200, 300, 15],
...     }
... )
>>> df
   Animal  Speed
0  Falcon    100
1  Parrot      5
2  Falcon    200
3  Falcon    300
4  Parrot     15
>>> df.groupby(pd.Grouper(key="Animal")).mean()
        Speed
Animal
Falcon  200.0
Parrot   10.0

Specify a resample operation on the column 'Publish date'

>>> df = pd.DataFrame(
...     {
...         "Publish date": [
...             pd.Timestamp("2000-01-02"),
...             pd.Timestamp("2000-01-02"),
...             pd.Timestamp("2000-01-09"),
...             pd.Timestamp("2000-01-16"),
...         ],
...         "ID": [0, 1, 2, 3],
...         "Price": [10, 20, 30, 40],
...     }
... )
>>> df
  Publish date  ID  Price
0   2000-01-02   0     10
1   2000-01-02   1     20
2   2000-01-09   2     30
3   2000-01-16   3     40
>>> df.groupby(pd.Grouper(key="Publish date", freq="1W")).mean()
               ID  Price
Publish date
2000-01-02    0.5   15.0
2000-01-09    2.0   30.0
2000-01-16    3.0   40.0

If you want to adjust the start of the bins based on a fixed timestamp:

>>> start, end = "2000-10-01 23:30:00", "2000-10-02 00:30:00"
>>> rng = pd.date_range(start, end, freq="7min")
>>> ts = pd.Series(np.arange(len(rng)) * 3, index=rng)
>>> ts
2000-10-01 23:30:00     0
2000-10-01 23:37:00     3
2000-10-01 23:44:00     6
2000-10-01 23:51:00     9
2000-10-01 23:58:00    12
2000-10-02 00:05:00    15
2000-10-02 00:12:00    18
2000-10-02 00:19:00    21
2000-10-02 00:26:00    24
Freq: 7min, dtype: int64

>>> ts.groupby(pd.Grouper(freq="17min")).sum()
2000-10-01 23:14:00     0
2000-10-01 23:31:00     9
2000-10-01 23:48:00    21
2000-10-02 00:05:00    54
2000-10-02 00:22:00    24
Freq: 17min, dtype: int64

>>> ts.groupby(pd.Grouper(freq="17min", origin="epoch")).sum()
2000-10-01 23:18:00     0
2000-10-01 23:35:00    18
2000-10-01 23:52:00    27
2000-10-02 00:09:00    39
2000-10-02 00:26:00    24
Freq: 17min, dtype: int64

>>> ts.groupby(pd.Grouper(freq="17min", origin="2000-01-01")).sum()
2000-10-01 23:24:00     3
2000-10-01 23:41:00    15
2000-10-01 23:58:00    45
2000-10-02 00:15:00    45
Freq: 17min, dtype: int64

If you want to adjust the start of the bins with an `offset` Timedelta, the two
following lines are equivalent:

>>> ts.groupby(pd.Grouper(freq="17min", origin="start")).sum()
2000-10-01 23:30:00     9
2000-10-01 23:47:00    21
2000-10-02 00:04:00    54
2000-10-02 00:21:00    24
Freq: 17min, dtype: int64

>>> ts.groupby(pd.Grouper(freq="17min", offset="23h30min")).sum()
2000-10-01 23:30:00     9
2000-10-01 23:47:00    21
2000-10-02 00:04:00    54
2000-10-02 00:21:00    24
Freq: 17min, dtype: int64

To replace the use of the deprecated `base` argument, you can now use `offset`,
in this example it is equivalent to have `base=2`:

>>> ts.groupby(pd.Grouper(freq="17min", offset="2min")).sum()
2000-10-01 23:16:00     0
2000-10-01 23:33:00     9
2000-10-01 23:50:00    36
2000-10-02 00:07:00    39
2000-10-02 00:24:00    24
Freq: 17min, dtype: int64
boolsortdropnaIndex | None_grouperztuple[str, ...]_attributesc                	X   < VP                  R 4      e	   ^ RIHp Tp \        SV `  V 4      # )freq)TimeGrouper)getpandas.core.resampler,   super__new__)clsargskwargsr,   	__class__s   &*, d/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/pandas/core/groupby/grouper.pyr0   Grouper.__new__  s)    ::f)8Cws##    Nc               $    V ^8  d   QhRRRRRR/# )   r%   r$   r&   returnNone )formats   "r5   __annotate__Grouper.__annotate__  s*     : :
 : : 
:r7   c                	z    Wn         W n        W0n        W@n        WPn        R V n        R V n        R V n        R V n        R # N)	keylevelr+   r%   r&   _indexer_deprecatedbinnerr(   _indexer)selfrB   rC   r+   r%   r&   s   &&&&&&r5   __init__Grouper.__init__  s:     
		@D 59r7   c               (    V ^8  d   QhRRRRRRRR/# )r9   objr   validater$   observedr:   z tuple[ops.BaseGrouper, NDFrameT]r<   )r=   s   "r5   r>   r?   "  s,      '+>B	)r7   c           
         V P                  V4      w  p p\        VV P                  .V P                  V P                  VV P
                  VR7      w  rTpWQ3# )aY  
Parameters
----------
obj : Series or DataFrame
    Object being grouped.
validate : bool, default True
    If True, validate the grouper.
observed : bool, default True
    Whether only observed groups should be in the result. Only
    has an impact when grouping on categorical data.

Returns
-------
A tuple of grouper, obj (possibly sorted)
)rC   r%   rL   r&   rM   )_set_grouperget_grouperrB   rC   r%   r&   )rG   rK   rL   rM   _groupers   &&&&  r5   _get_grouperGrouper._get_grouper"  sY    $ %%c*	Q%XXJ**;;
C |r7   	gpr_indexc               (    V ^8  d   QhRRRRRRRR/# )	r9   rK   r   r%   r$   rU   r'   r:   z3tuple[NDFrameT, Index, npt.NDArray[np.intp] | None]r<   )r=   s   "r5   r>   r?   A  s2     M  M M #'M ?KM 	<M r7   c                  Vf   Q hV P                   e   V P                  e   \        R4      hV P                  f   W0n        V P                  V n        V P                   e   V P                   p\        VRR4      V8X  d   \        V\        4      '       d   V P                  f   Q hV P
                  eR   V P
                  P                  4       pV P                  P                  V4      pVP                  VP                  4      pMV P                  P                  VP                  4      pMWAP                  9  d   \        RV R24      h\        W,          VR7      pMVP                  pV P                  e   V P                  p\        V\        4      '       d@   VP!                  V4      p\        VP#                  V4      VP$                  V,          R7      pM"V^ VP&                  39  d   \        RV R24      hRp	V P(                  '       g	   V'       dZ   VP*                  '       gH   VP,                  P                  R	R
R7      ;qn        VP                  V	4      pVP                  V	^ R7      pWV	3# )aG  
given an object and the specifications, setup the internal grouper
for this particular specification

Parameters
----------
obj : Series or DataFrame
sort : bool, default False
    whether the resulting grouper should be sorted
gpr_index : Index or None, default None

Returns
-------
NDFrame
Index
np.ndarray[np.intp] | None
Nz2The Grouper cannot specify both a key and a level!namezThe grouper name z is not foundrX   z
The level z is not valid	mergesortfirst)kindna_positionaxis)rB   rC   
ValueErrorr(   rD   rF   getattr
isinstancer   argsorttakeindex
_info_axisKeyErrorr   r   _get_level_number_get_level_valuesnamesrX   r%   is_monotonic_increasingarray)
rG   rK   r%   rU   rB   reverse_indexerunsorted_axaxrC   indexers
   &&&$      r5   rO   Grouper._set_grouperA  s   ( 88DJJ$:QRR == %M 44DM 88((Cy&$/36:c6;R;R
 }}000==,&*mm&;&;&=O"&--"4"4_"EK$))#))4B++CII6Bnn,"%6se=#IJJ38#. Bzz%

 b*--007Er33E:%QB1bgg,.$z%%FGG 04IIIr'A'A'A 241A1A g 2B 2 G. !B((7(+Cr7   c                   V ^8  d   QhRR/# r9   r:   strr<   )r=   s   "r5   r>   r?     s     & &# &r7   c                	   a  V 3R  lS P                    4       pRP                  V4      p\        S 4      P                  pV RV R2# )c              3  h   <"   T F'  p\        SV4      f   K  V R\        SV4      : 2x  K)  	  R # 5i)N=)ra   ).0	attr_namerG   s   & r5   	<genexpr>#Grouper.__repr__.<locals>.<genexpr>  s7      
-	tY' 8yk74367-s   22z, ())r)   jointype__name__)rG   
attrs_listattrscls_names   f   r5   __repr__Grouper.__repr__  sJ    
!--


 		*%:&&1UG1%%r7   )	r(   rF   rD   rE   r&   r+   rB   rC   r%   )rB   rC   r+   r%   r&   )NNNFT)TT)F)r   
__module____qualname____firstlineno____doc____annotations__r)   r0   rH   rS   rO   r   r   __static_attributes____classcell__)r4   s   @r5   r#   r#   E   s_    yv JL#MKM$:&>M NRM  M ^ & &r7   r#   c                  X   ] tR tRt$ RtRtR]R&   R]R&   R]R	&   R'R
 R lltR R ltR R lt	]
R R l4       t]
R R l4       t]
R R l4       t]R R l4       t]
R R l4       t]R R l4       t]R R l4       t]
R R l4       t]
R  R! l4       t]R" R# l4       t]
R$ R% l4       tR&tR# )(Groupingi  a  
Holds the grouping information for a single key

Parameters
----------
index : Index
grouper :
obj : DataFrame or Series
name : Label
level :
observed : bool, default False
    If we are a Categorical, use the observed values
in_axis : if the Grouping is a column in self.obj and hence among
    Groupby.exclusions list
dropna : bool, default True
    Whether to drop NA groups.
uniques : Array-like, optional
    When specified, will be used for unique values. Enables including empty groups
    in the result for a BinGrouper. Must not contain duplicates.

Attributes
-------
indices : dict
    Mapping of {group -> index_list}
codes : ndarray
    Group codes
group_index : Index or None
    unique groups
groups : dict
    Mapping of {group -> label_list}
Nz$npt.NDArray[np.signedinteger] | None_codesr'   
_orig_catsr   _indexc               8    V ^8  d   QhRRRRRRRRRRR	RR
RRR/# )r9   re   r   rK   zNDFrame | Noner%   r$   rM   in_axisr&   uniqueszArrayLike | Noner:   r;   r<   )r=   s   "r5   r>   Grouping.__annotate__  sd     g/ g/g/ 	g/ g/ g/ g/ g/ "g/ 
g/r7   c
                	   \        V\        4      '       d   VP                  R R7      pW@n        W n        \        W4      p
RV n        Wn        WPn        W0n	        W`n
        Wpn        Wn        Wn        V P                  pVeH   \        V\        4      '       d   VP!                  V4      pMTpV
f   Tp
EMT
pVP#                  V4      p
EMj\        V
\$        4      '       d   V P                  f   Q hV
P'                  V P                  R R7      w  rWn	        \        V\(        P*                  4      '       d   Tp
MVP,                  ^ ,          P.                  p\1        VVP2                  P4                  R R7      p
M\        V
\        \0        \6        \8        P:                  34      '       g   \=        V
R^4      ^8w  d$   \?        \A        V
4      4      p\C        RV R24      hVP#                  V
4      p
\E        V
R4      '       d   \G        V
4      \G        V4      8X  g   \I        V
4      pR	V 2p\K        V4      h\        V
\8        P:                  4      '       d6   V
PL                  PN                  R
9   d   \        V
4      PQ                  4       p
M>\        \=        V
RR4      \R        4      '       d   V
PT                  V n        \W        WV4      p
Wn        R# )F)deepN)rL   rX   copyndimGrouper for '' not 1-dimensional__len__z9Grouper result violates len(labels) == len(data)
result: mMdtype),rb   r   r   rC   _orig_grouper_convert_grouperr   r   _sortrK   	_observedr   _dropna_uniques_ilevelr   get_level_valuesmapr#   rS   r   
BinGrouper	groupingsgrouping_vectorr   result_indexrX   r   npndarrayra   rt   r   r`   hasattrlenr   AssertionErrorr   r\   to_numpyr   
categoriesr   )rG   re   rR   rK   rC   r%   rM   r   r&   r   r   ilevelindex_levelmapper
newgroupernewobjngtgrpererrmsgs   &&&&&&&&&&          r5   rH   Grouping.__init__  sb    gv&&lll.G
$*5:
!
  %,,#44V<#&"-("-//&"9 11
 88'''!0!=!=dhhQV!=!WJH*cnn55 #-  ))!,<<"'Z4499# fe^RZZH
 
 2a7_-. =3F!GHH#ii8O 33(CJ6$_5PQVPWX  %V,,orzz22$$))T1
 #)"9"B"B"D$?AQRR-88DO0QO.r7   c                   V ^8  d   QhRR/# rs   r<   )r=   s   "r5   r>   r   +  s     ( (# (r7   c                	"    R V P                    R2# )z	Grouping(r}   rY   rG   s   &r5   r   Grouping.__repr__+  s    499+Q''r7   c                   V ^8  d   QhRR/# )r9   r:   r   r<   )r=   s   "r5   r>   r   .  s     " "( "r7   c                	,    \        V P                  4      # rA   )iterindicesr   s   &r5   __iter__Grouping.__iter__.  s    DLL!!r7   c                   V ^8  d   QhRR/# r9   r:   r$   r<   )r=   s   "r5   r>   r   2  s     3 3T 3r7   c                	P    \        V P                  R R4      p\        V\        4      # )r   N)ra   r   rb   r   )rG   r   s   & r5   _passed_categoricalGrouping._passed_categorical1  s$    ,,gt<%!122r7   c                   V ^8  d   QhRR/# )r9   r:   r   r<   )r=   s   "r5   r>   r   7  s      h r7   c                	   V P                   pVe   V P                  P                  V,          # \        V P                  \
        \        34      '       d   V P                  P                  # \        V P                  \        P                  4      '       d!   V P                  P                  P                  # \        V P                  \
        4      '       d   V P                  P                  # R # rA   )r   r   rj   rb   r   r   r   rX   r   r   BaseGrouperr   )rG   r   s   & r5   rX   Grouping.name6  s    ;;$$V,,d((5&/::%%***,,coo>>''44999,,e44'',,, r7   c                   V ^8  d   QhRR/# )r9   r:   z
int | Noner<   )r=   s   "r5   r>   r   I  s       r7   c                    V P                   pVf   R# \        V\        4      '       gG   V P                  pWP                  9  d   \        RV R24      hVP                  P                  V4      # V# )zC
If necessary, converted index level name to index level position.
NzLevel z not in index)rC   rb   intr   rj   r   re   )rG   rC   re   s   &  r5   r   Grouping._ilevelH  sc    
 

=%%%KKEKK'$veWM%BCC;;$$U++r7   c                   V ^8  d   QhRR/# )r9   r:   r   r<   )r=   s   "r5   r>   r   X  s     ! ! !r7   c                	,    \        V P                  4      # rA   )r   r   r   s   &r5   ngroupsGrouping.ngroupsW  s    4<<  r7   c                   V ^8  d   QhRR/# )r9   r:   z$dict[Hashable, npt.NDArray[np.intp]]r<   )r=   s   "r5   r>   r   \  s     ) )= )r7   c                	    \        V P                  \        P                  4      '       d   V P                  P                  # \        V P                  4      pVP                  4       # rA   )rb   r   r   r   r   r   _reverse_indexer)rG   valuess   & r5   r   Grouping.indices[  sL     d**COO<<''///T112&&((r7   c                   V ^8  d   QhRR/# )r9   r:   znpt.NDArray[np.signedinteger]r<   )r=   s   "r5   r>   r   e  s     * *4 *r7   c                	(    V P                   ^ ,          # )    _codes_and_uniquesr   s   &r5   codesGrouping.codesd      &&q))r7   c                   V ^8  d   QhRR/# )r9   r:   r   r<   )r=   s   "r5   r>   r   i  s     * * *r7   c                	(    V P                   ^,          # )   r   r   s   &r5   r   Grouping.uniquesh  r   r7   c                   V ^8  d   QhRR/# )r9   r:   z/tuple[npt.NDArray[np.signedinteger], ArrayLike]r<   )r=   s   "r5   r>   r   m  s     > >$S >r7   c                	   V P                   '       Ed   V P                  pVP                  pV P                  '       dU   \        P
                  ! VP                  4      pW3R8g  ,          pV P                  '       d   \        P                  ! V4      pM\        P                  ! \        V4      4      pRpV P                  '       g   VP                  4       p\        P                  ! V4      '       dk   RpV P                  '       d   \        V4      pM3VP                  4       p\        P                   ! VP                  RV 4      p\        P"                  ! W6R4      p\$        P&                  ! W2VP(                  RR7      pVP                  p	V'       dM   V P                  '       g#   \        P*                  ! V	X8  V	^,           V	4      p	\        P*                  ! XXV	4      p	W3# \-        V P                  \.        P0                  4      '       d:   V P                  P2                  p	V P                  P4                  P6                  pW3# V P8                  e=   \%        V P                  V P8                  R7      pVP                  p	V P8                  pW3# \        P:                  ! V P                  V P                  V P                  R7      w  rW3# )r   FTN)r   r   orderedrL   )r   )r%   use_na_sentinel)r   r   r   r   r   unique1dr   r   r   r%   aranger   r   isnaanyargmaxnunique_intsinsertr   
from_codesr   whererb   r   r   
codes_infor   _valuesr   	factorize)
rG   catr   ucodeshas_dropped_nana_maskna_codena_idxr   r   s
   &         r5   r   Grouping._codes_and_uniquesl  s    ### &&CJ~~~#,,SYY7"-:::WWV_F3z?3"N<<<((*66'??%)Nzzz"%j/ ")!1","9"9#))GV:L"MYYv;F!,,S[[SXG IIEzzzHHUg%5uqy%HE'59>!,,coo>>((33E**77??G ~ ]]& d22t}}MCIIEmmG ~ (11$$4::t||NE ~r7   c                   V ^8  d   QhRR/# )r9   r:   zdict[Hashable, Index]r<   )r=   s   "r5   r>   r     s     
" 
"- 
"r7   c                	  a V P                   w  r\        P                  ! W P                  R R7      p\        P
                  ! \        V4      \        V4      4      w  op\        V4      P                  4       pV3R l\        W3R,          R R7       4       p\        W$RR7       UUu/ uF   w  rVWPP                  P                  V4      bK"  	  ppp\        V4      # u uppi )Fr   c              3  0   <"   T F  w  rSW x  K  	  R # 5irA   r<   )rx   startendrs   &  r5   rz   "Grouping.groups.<locals>.<genexpr>  s     X2WJE1U<2Ws   :r   NNstrictT)r   r   _with_inferrX   libalgosgroupsort_indexerr   r   r
   cumsumzipr   rd   r   )	rG   r   r   counts_resultkvresultr  s	   &       @r5   groupsGrouping.groups  s    00##G))%H../B5/I3w<X	6f%,,.X#fRjQV2WX58RV5WX5WTQ![[%%a((5WX&!! Ys   %&Cc                   V ^8  d   QhRR/# r9   r:   r   r<   )r=   s   "r5   r>   r     s     ' '8 'r7   c                	B    V P                   '       d   V # V P                  # rA   )r   _observed_groupingr   s   &r5   observed_groupingGrouping.observed_grouping  s    >>>K&&&r7   c                   V ^8  d   QhRR/# r  r<   )r=   s   "r5   r>   r     s      H r7   c                	    \        V P                  V P                  V P                  V P                  V P
                  R V P                  V P                  V P                  R7	      pV# )T)rK   rC   r%   rM   r   r&   r   )	r   r   r   rK   rC   r   r   r   r   )rG   groupings   & r5   r  Grouping._observed_grouping  sP    KK**LL<<MM

 r7   )r   r   r   r   r   r   r   r   r   rC   rK   )NNNTFFTN)r   r   r   r   r   r   r   rH   r   r   r   r   rX   r   propertyr   r   r   r   r   r  r  r  r   r<   r7   r5   r   r     s   @ 48F07Mg/R(" 3 3  "   ! ! ) ) * * * * > >@ 
" 
" ' '  r7   r   c               0    V ^8  d   QhRRRRRRRRRRRR	/# )
r9   rK   r   r%   r$   rM   rL   r&   r:   z5tuple[ops.BaseGrouper, frozenset[Hashable], NDFrameT]r<   )r=   s   "r5   r>   r>     sN     V/ V/	V/ 	V/
 V/ V/ V/ ;V/r7   c                  a  S P                   pVEe   \        V\        4      '       dT   \        V4      '       d   \	        V4      ^8X  d
   V^ ,          pVf%   \        V4      '       d   VP                  V4      pRpM\        V4      '       d:   \	        V4      pV^8X  d   V^ ,          pMV^ 8X  d   \        R4      h\        R4      h\        V\        4      '       d,   S P                   P                  V8w  d   \        RV R24      hMV^ 8  g   VR8  d   \        R4      hRpTp\        V\        4      '       dL   VP                  S RVR7      w  p	o VP                  f   V	\        4       S 3# V	\        VP                  04      S 3# \        V\        P                  4      '       d   V\        4       S 3# \        V\         4      '       g   V.p
RpMTp
\	        V
4      \	        V4      8H  p\"        ;QJ d    R	 V
 4       F  '       g   K   R
M	  RM! R	 V
 4       4      p\"        ;QJ d    R V
 4       F  '       g   K   R
M	  RM! R V
 4       4      p\"        ;QJ d    R V
 4       F  '       g   K   R
M	  RM! R V
 4       4      pV'       g   V'       g   V'       g   V'       d   Vf   \        S \$        4      '       d<   \&        ;QJ d    V 3R lV
 4       F  '       d   K   RM	  R
M! V 3R lV
 4       4      pMR\        S \(        4      '       g   Q h\&        ;QJ d    V 3R lV
 4       F  '       d   K   RM	  R
M! V 3R lV
 4       4      pV'       g   \*        P,                  ! V
4      .p
\        V\.        \         34      '       d   Vf   R.\	        V4      ,          p
TpMV.\	        V
4      ,          p. p\1        4       pR V 3R llpR V 3R llp\3        V
VR
R7       EF^  w  ppV! V4      '       d   R
pVP5                  VP                  4       MV! V4      '       d   S P6                  ^8w  db   VS 9   d[   V'       d   S P9                  V^ R7       R
TS V,          pppVP6                  ^8w  d   \        RV R24      hVP5                  V4       MoS P;                  V^ R7      '       d   RTRpppMO\=        V4      h\        V\        4      '       d-   VP                  e   VP5                  VP                  4       R
pMRp\        V\>        4      '       g   \?        VVS VVVVVR7      MTpVPA                  V4       EKa  	  \	        V4      ^ 8X  d   \	        S 4      '       d   \        R4      h\	        V4      ^ 8X  dI   VPA                  \?        \C        ^ 4      \D        PF                  ! . \D        PH                  R7      4      4       \        P                  ! VVW6R7      p	V	\        V4      S 3# )a  
Create and return a BaseGrouper, which is an internal
mapping of how to create the grouper indexers.
This may be composed of multiple Grouping objects, indicating
multiple groupers

Groupers are ultimately index mappings. They can originate as:
index mappings, keys to columns, functions, or Groupers

Groupers enable local references to level,sort, while
the passed in level, and sort are 'global'.

This routine tries to figure out what the passing in references
are and then creates a Grouping for each one, combined into
a BaseGrouper.

If observed & we have a categorical grouper, only show the observed
values.

If validate, then check for key/level overlaps.

NzNo group keys passed!z*multiple levels only valid with MultiIndexzlevel name z is not the name of the indexz2level > 0 or level < -1 only valid with MultiIndexF)rL   rM   c              3  h   "   T F(  p\        V4      ;'       g    \        V\        4      x  K*  	  R # 5irA   )callablerb   dictrx   gs   & r5   rz   get_grouper.<locals>.<genexpr>2  s&     H4ax{99jD&994s   22Tc              3  N   "   T F  p\        V\        \        34      x  K  	  R # 5irA   )rb   r#   r   r'  s   & r5   rz   r)  3  s     H4az!gx%8994s   #%c           	   3     "   T F4  p\        V\        \        \        \        \
        P                  34      x  K6  	  R # 5irA   )rb   listtupler   r   r   r   r'  s   & r5   rz   r)  4  s,      IMA
1tUFE2::>??s   <>c              3     <"   T F4  qSP                   9   ;'       g    VSP                  P                  9   x  K6  	  R # 5irA   )columnsre   rj   rx   r(  rK   s   & r5   rz   r)  A  s3      'BFQS[[ 88A$88$s   ?"?c              3  T   <"   T F  qSP                   P                  9   x  K  	  R # 5irA   )re   rj   r0  s   & r5   rz   r)  F  s     &JTCIIOO';Ts   %(c                   V ^8  d   QhRR/# r   r<   )r=   s   "r5   r>   !get_grouper.<locals>.__annotate__V  s      4 r7   c                   < \        V 4      '       g;   SP                  ^8X  d   R# SP                  R,          p VP                  V 4       R# R#   \        \
        \        3 d     R# i ; i)r   FTr   )_is_label_liker   axesget_locrg   	TypeErrorr   )rB   itemsrK   s   & r5   
is_in_axisget_grouper.<locals>.is_in_axisV  s]    c""xx1} HHRLEc"
 	 i):; s   A A)(A)c                   V ^8  d   QhRR/# r   r<   )r=   s   "r5   r>   r3  f  s      $ r7   c                @  < \        V R 4      '       g   R#  SV P                  ,          p\        T \        4      '       d=   \        T\        4      '       d'   T P                  P                  TP                  ^ 4      # R#   \        \        \        \
        3 d     R# i ; i)rX   F)
r   rX   rg   
IndexErrorr   r   rb   r   _mgrreferences_same_values)gprobj_gpr_columnrK   s   & r5   	is_in_objget_grouper.<locals>.is_in_objf  s    sF##	 ]N c6""z.&'I'I8822>3F3FJJ	 *&79LM 		s   A> >BBr	  r^   r   r   )rK   rC   r%   rM   r   r&   )r   )r%   r&   r   )%re   rb   r   r   r   r   r   r`   rt   rX   r#   rS   rB   	frozensetr   r   r,  r   r   allr   comasarray_tuplesafer-  setr  addr   _check_label_or_level_ambiguity_is_level_referencerg   r   appendr   r   rl   intp)rK   rB   rC   r%   rM   rL   r&   
group_axisnlevelsrR   keysmatch_axis_lengthany_callableany_groupersany_arraylikeall_in_columns_indexlevelsr   
exclusionsr:  rC  rA  r   rX   pings   f&&&&&&                  r5   rP   rP     s   > J  j*--E""s5zQa{y// 11%8 E""e*a<!!HE\$%<==$%QRR%%%99>>U*${5'9V%WXX +ebj !UVV EC #w''eh'O77?IK,,Iswwi0#55 
C	)	)IK$$c4  u!IZ8 3H4H333H4HHL3H4H333H4HHLC IMCCC IM M Mc9%%#&3 'BF'333 'BF' $  c6****#&3&JT&J333&JT&J#J #))$/0D%%'';6CJ&D3t9$ "I #J    $t44
US>>GNN388$__xx1}77!7D%)3Cs88q= %}TF:M%NOOt$((1(55&+S$sm#W%%#''*=NN377#GG c8,, !	  	 	W 5Z 9~s3xx011
9~-"2BHHRrww4OPQ ooj)$NGIj)3..r7   c                   V ^8  d   QhRR/# r   r<   )r=   s   "r5   r>   r>     s     Q Q4 Qr7   c                l    \        V \        \        34      ;'       g    V R J;'       d    \        V 4      # rA   )rb   rt   r-  r   )vals   &r5   r5  r5    s+    cC<(PPS_-O-O3Pr7   c                   V ^8  d   QhRR/# )r9   r_   r   r<   )r=   s   "r5   r>   r>     s      5 r7   c                d   \        V\        4      '       d   VP                  # \        V\        4      '       dI   VP                  P                  V 4      '       d   VP                  # VP                  V 4      P                  # \        V\        4      '       d   VP                  # \        V\        \        \        \        \        P                  34      '       dY   \        V4      \        V 4      8w  d   \!        R 4      h\        V\        \        34      '       d   \"        P$                  ! V4      pV# V# )z$Grouper and axis must be same length)rb   r&  r-   r   re   equalsr   reindexr   r,  r-  r   r   r   r   r   r`   rG  rH  )r_   rR   s   &&r5   r   r     s    '4  {{	GV	$	$==%%??"??4(000	GZ	(	(	GdE5+rzzJ	K	Kw<3t9$CDDge}--++G4Gr7   )NNTFTT)?r   
__future__r   typingr   r   numpyr   pandas._libsr   r  pandas._libs.tslibsr   pandas.errorsr   pandas.util._decoratorsr   r	   pandas.core.dtypes.commonr
   r   r   r   pandas.core.dtypes.dtypesr   pandas.corer   pandas.core.arraysr   r   pandas.core.commoncorecommonrG  pandas.core.framer   pandas.core.groupbyr   pandas.core.groupby.categoricalr   pandas.core.indexes.apir   r   r   pandas.core.seriesr   pandas.io.formats.printingr   r   collections.abcr   r   pandas._typingr   r   r   pandas.core.genericr    r#   r   rP   r5  r   r<   r7   r5   <module>rx     s   
 #
  4 +
  7 " !   ' # > 
 &
 
  , HS& S& S&l
 q q qh	V/rQr7   