Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pandas/core/groupby/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pandas/core/groupby/__pycache__/grouper.cpython-312.pyc

�

Mٜg�����dZddlmZddlmZmZddlZddlZddl	m
Z
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZmZddlmZdd
lmZddlmZmZddl m!cm"Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+m,Z,m-Z-ddl.m/Z/ddl0m1Z1erddl2m3Z3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9ddl:m;Z;Gd�d�Z<eGd�d��Z=							d													d d�Z>d!d�Z?d"d�Z@y)#z]
Provide user facing operators for doing the split part of the
split-apply-combine paradigm.
�)�annotations)�
TYPE_CHECKING�finalN)�using_copy_on_write�warn_copy_on_write)�lib)�OutOfBoundsDatetime)�InvalidIndexError)�cache_readonly)�find_stack_level)�is_list_like�	is_scalar)�CategoricalDtype)�
algorithms)�Categorical�ExtensionArray)�	DataFrame)�ops)�recode_for_groupby)�CategoricalIndex�Index�
MultiIndex)�Series)�pprint_thing)�Hashable�Iterator)�	ArrayLike�Axis�NDFrameT�npt)�NDFramec�^��eZdZUdZded<ded<ded<ded<dZd	ed
<�fd�Zdddejd
df							dd�Z		d					dd�Z
	ddd�							dd�Zee
dd���Zee
d���Zee
d���Zee
d���Zee
d���Zedd��Z�xZS) �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 and/or axis parameters are given, a level of the index of the target
    object.

    If `axis` and/or `level` are passed as keywords to both `Grouper` and
    `groupby`, the values passed to `Grouper` take precedence.

    Parameters
    ----------
    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 `here
        <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`_.
    axis : str, int, defaults to 0
        Number/name of the axis.
    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

        .. versionadded:: 1.3.0

    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.

    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�
_gpr_index�_grouper)�key�level�freq�axisr%r&ztuple[str, ...]�_attributesc�T��|jd��ddlm}|}t�|�|�S)Nr,r)�TimeGrouper)�get�pandas.core.resampler0�super�__new__)�cls�args�kwargsr0�	__class__s    ��F/usr/local/lib/python3.12/site-packages/pandas/core/groupby/grouper.pyr4zGrouper.__new__�s)����:�:�f��)�8��C��w��s�#�#�NFTc�v�t|�tur9|tjur%t	j
dtt���nd}|tjurd}||_||_	||_
||_||_||_
d|_d|_d|_d|_d|_d|_d|_y)Nz~Grouper axis keyword is deprecated and will be removed in a future version. To group on axis=1, use obj.T.groupby(...) instead��
stacklevelr)�typer#r�
no_default�warnings�warn�
FutureWarningrr*r+r,r-r%r&�_grouper_deprecated�_indexer_deprecated�_obj_deprecatedr(�binnerr)�_indexer)�selfr*r+r,r-r%r&s       r9�__init__zGrouper.__init__s�����:�� ��3�>�>�)��
�
��"�/�1�����3�>�>�!��D������
���	���	���	����#'�� �@D�� �#�����������
�59��
r:c	���|j|�\}}}t||jg|j|j|j
||j��\}}}||_||fS)z�
        Parameters
        ----------
        obj : Series or DataFrame
        validate : bool, default True
            if True, validate the grouper

        Returns
        -------
        a tuple of grouper, obj (possibly sorted)
        )r-r+r%�validater&)�_set_grouper�get_grouperr*r-r+r%r&rC)rH�objrK�_�groupers     r9�_get_grouperzGrouper._get_grouper,si���%�%�c�*�	��Q��%��
�X�X�J�����*�*������;�;�
����C�$+�� ���|�r:)�	gpr_indexc���|�J�|j�|j�td��|j�||_|j|_|j��|j}t
|dd�|k(r�t|t�r�|j�J�|j
�Q|j
j�}|jj|�}|j|j�}n�|jj|j�}n�||jvrtd|�d���t|||��}n�|j|j �}|j�v|j}t|t"�r;|j%|�}t|j'|�|j(|��}n|d|j*fvrtd|�d	���d}	|j,s|r^|j.sR|j0jd
d��x}	|_|j|	�}|j|	|j �
�}||_||_|||	fS)a�
        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!�namezThe grouper name z
 is not found�rTrz
The level z
 is not valid�	mergesort�first)�kind�na_position�r-)r*r+�
ValueErrorr)rDrG�getattr�
isinstancer�argsort�take�index�
_info_axis�KeyErrorr�	_get_axisr-r�_get_level_number�_get_level_values�namesrTr%�is_monotonic_increasing�arrayrEr()
rHrNr%rRr*�reverse_indexer�unsorted_ax�axr+�indexers
          r9rLzGrouper._set_grouperKs*��(�����8�8��D�J�J�$:��Q�R�R��=�=� �%�D�M� �4�4�D�M��8�8���(�(�C��y�&�$�/�3�6�:�c�6�;R�
�}�}�0�0�0��=�=�,�&*�m�m�&;�&;�&=�O�"&�-�-�"4�"4�_�"E�K�$�)�)�#�)�)�4�B����+�+�C�I�I�6�B��c�n�n�,�"�%6�s�e�=�#I�J�J��3�s�8�#�.�����t�y�y�)�B��z�z�%��
�
���b�*�-��0�0��7�E��r�3�3�E�:����%��Q�B��Q����L�0�(�:�e�W�M�)J�K�K�04���I�I��r�'A�'A�24���1A�1A� �g�2B�2�
�G�d�.�����!�B��(�(�7����(�3�C� #�������B���r:c��tjt|�j�d�tt���|j}|�td��|S)NzS.ax is deprecated and will be removed in a future version. Use Resampler.ax insteadr<z1_set_grouper must be called before ax is accessed)r@rAr>�__name__rBrr(r[)rHr`s  r9rkz
Grouper.ax�sT��	�
�
��D�z�"�"�#�$7�
7��'�)�		
������=��P�Q�Q��r:c��tjt|�j�d�tt���|jS)Nz^.indexer is deprecated and will be removed in a future version. Use Resampler.indexer instead.r<)r@rAr>rnrBrrD�rHs r9rlzGrouper.indexer�sC��	�
�
��D�z�"�"�#�$B�
B��'�)�		
��'�'�'r:c��tjt|�j�d�tt���|jS)NzX.obj is deprecated and will be removed in a future version. Use GroupBy.indexer instead.r<)r@rAr>rnrBrrErps r9rNzGrouper.obj�sC��
	�
�
��D�z�"�"�#�$@�
@��'�)�		
��#�#�#r:c��tjt|�j�d�tt���|jS)Nz\.grouper is deprecated and will be removed in a future version. Use GroupBy.grouper instead.r<)r@rAr>rnrBrrCrps r9rPzGrouper.grouper�sC��	�
�
��D�z�"�"�#�$@�
@��'�)�		
��'�'�'r:c��tjt|�j�d�tt���|jjS)NzZ.groups is deprecated and will be removed in a future version. Use GroupBy.groups instead.r<)r@rAr>rnrBrrC�groupsrps r9rtzGrouper.groups�sG��	�
�
��D�z�"�"�#�$?�
?��'�)�		
��'�'�.�.�.r:c����fd��jD�}dj|�}t��j}|�d|�d�S)Nc	3�j�K�|]*}t�|��|�dtt�|�������,y�w)N�=)r\�repr)�.0�	attr_namerHs  �r9�	<genexpr>z#Grouper.__repr__.<locals>.<genexpr>�s>�����
�-�	��t�Y�'�3��k��4���i� 8�9�:�;�-�s�03z, �(�))r.�joinr>rn)rH�
attrs_list�attrs�cls_names`   r9�__repr__zGrouper.__repr__�sJ���
�!�-�-�
�
�
�	�	�*�%����:�&�&����1�U�G�1�%�%r:)r-zAxis | lib.NoDefaultr%r$r&r$�return�None)T)rNrrKr$r�z tuple[ops.BaseGrouper, NDFrameT])F)rNrr%r$rRr'r�z3tuple[NDFrameT, Index, npt.NDArray[np.intp] | None]�r�r�r��str)rn�
__module__�__qualname__�__doc__�__annotations__r.r4rr?rIrQrLr�propertyrkrlrNrPrtr��
__classcell__)r8s@r9r#r#Bss���r�h�J��L�����#U�K��U�$�
��
�%(�^�^���%:�
#�%:��
%:��%:�
�%:�P/3����'+��	)��@+0�R �NR�R ��R �#'�R �?K�R �	<�R �h�
�
���
��
�(���(��
�	$���	$��
�(���(��
�/���/��&��&r:r#c��eZdZUdZdZded<ded<ded<d	ed
<								d															dd�Zdd�Zdd
�Ze	d d��Z
e	d!d��Ze	d"d��Ze
d#d��Ze	d$d��Ze
d%d��Ze	d&d��Ze
d&d��Ze	d'd��Ze
d'd��Ze	d'd��Ze
d'd��Ze	d(d��Ze	d)d��Zy)*�Groupingah
    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�_codeszCategorical | None�_all_grouperr'�
_orig_catsr�_indexc
��||_||_t||�}
d|_d|_||_||_||_||_||_	||_
|	|_|j}|�?t|t�r|j|�}n|}|
�|}
�n^|
}
|j!|
�}
�nIt|
t"�r�|j�J�|
j%|jd��\}}||_t|t&j(�r|}
n�|j*dj,}t/||j0j2��}
n�t|
t4t.t6t8j:f�s�t=|
dd�dk7r#t?tA|
��}tCd|�d���|j!|
�}
tE|
d	�rtG|
�tG|�k(stI|
�}d
|��}tK|��t|
t8j:�r9|
jLjNdvrbt5|
�jQ�}
|
|_ytt=|
dd�tR�r&|
jT|_tW|
||�\}
|_|
|_y)
NF�rKrrU�ndim��
Grouper for '�' not 1-dimensional�__len__z9Grouper result violates len(labels) == len(data)
result: �mM�dtype),r+�
_orig_grouper�_convert_grouperr�r�r��_sortrN�	_observed�in_axis�_dropna�_uniques�_ilevelr]r�get_level_values�mapr#rQr�
BinGrouper�	groupings�grouping_vectorr�result_indexrTrr�np�ndarrayr\r�r>r[�hasattr�lenr�AssertionErrorr�rX�to_numpyr�
categoriesr)rHr`rPrNr+r%�observedr�r&�uniquesr��ilevel�index_level�mapper�
newgrouper�newobj�ng�t�grper�errmsgs                    r9rIzGrouping.__init__sf����
�$���*�5�'�:�� �����������
����!�����������
�
�������%��,�#�4�4�V�<��#���&�"-��(��"-�/�/�&�"9�����
1�
�8�8�'�'�'�!0�!=�!=�d�h�h�QV�!=�!W��J���D�H��*�c�n�n�5�#-�� �)�)�!�,�<�<��"'���1H�1H�1M�1M�"N����f�e�^�R�Z�Z�H�
�����2�a�7���_�-�.�� �=���3F�!G�H�H�#�i�i��8�O����3���(�C��J�6�$�_�5��*�*/��2��%�V�,�,��o�r�z�z�2��$�$�)�)�T�1�
#)��"9�"B�"B�"D�� /�������$�?�AQ�
R�-�8�8�D�O�1C���x�2�.�O�T�.� /��r:c�"�d|j�d�S)Nz	Grouping(r}rUrps r9r�zGrouping.__repr__xs���4�9�9�+�Q�'�'r:c�,�t|j�S�N)�iter�indicesrps r9�__iter__zGrouping.__iter__{s���D�L�L�!�!r:c�P�t|jdd�}t|t�S)Nr�)r\r�r]r)rHr�s  r9�_passed_categoricalzGrouping._passed_categorical~s$����,�,�g�t�<���%�!1�2�2r:c��|j}|�|jj|St|jt
tf�r|jjSt|jtj�r |jjjSt|jt
�r|jjSyr�)r�r�rfr]r�rrrTr�r�BaseGrouperr�)rHr�s  r9rTz
Grouping.name�s����������;�;�$�$�V�,�,��d�(�(�5�&�/�:��%�%�*�*�*�
��,�,�c�o�o�
>��'�'�4�4�9�9�9�
��,�,�e�
4��'�'�,�,�,�r:c���|j}|�yt|t�sD|j}||jvrtd|�d���|jj
|�S|S)zS
        If necessary, converted index level name to index level position.
        NzLevel z
 not in index)r+r]�intr�rfr�r`)rHr+r`s   r9r�zGrouping._ilevel�sb��
�
�
���=���%��%��K�K�E��E�K�K�'�$�v�e�W�M�%B�C�C��;�;�$�$�U�+�+��r:c�,�t|j�Sr�)r��_group_indexrps r9�ngroupszGrouping.ngroups�s���4�$�$�%�%r:c��t|jtj�r|jjSt|j�}|j
�Sr�)r]r�rr�r�r�_reverse_indexer)rH�valuess  r9r�zGrouping.indices�sI���d�*�*�C�O�O�<��'�'�/�/�/��T�1�1�2���&�&�(�(r:c� �|jdS)Nr)�_codes_and_uniquesrps r9�codeszGrouping.codes�s���&�&�q�)�)r:c��|j�|jjS|jr|jjS|j
dS)�v
        Analogous to result_index, but holding an ArrayLike to ensure
        we can retain ExtensionDtypes.
        r�)r��
_result_index�_valuesr�r�r�rps r9�_group_arraylikezGrouping._group_arraylike�sN�����(��%�%�-�-�-�
�
%�
%��$�$�,�,�,��&�&�q�)�)r:c�b�tjdtt���|jS)r�zOgroup_arraylike is deprecated and will be removed in a future version of pandas��categoryr=)r@rArBrr�rps r9�group_arraylikezGrouping.group_arraylike�s,��	�
�
�
 �"�'�)�		
��$�$�$r:c��|j�;|j}t|t�sJ�|j}|j|�S|jSr�)r�r�r]rr��set_categories)rH�	group_idx�catss   r9r�zGrouping._result_index�sR�����(��)�)�I��i�)9�:�:�:��?�?�D��+�+�D�1�1�� � � r:c�b�tjdtt���|jS)NzLresult_index is deprecated and will be removed in a future version of pandasr�)r@rArBrr�rps r9r�zGrouping.result_index�s*���
�
�
 �"�'�)�		
��!�!�!r:c���|j\}}|j�s7|j�r*t|t�sJ�|j
r^|t
|�k(j�rBt	jtj|jdg�|jd��}n�t
|�dkDr�|j}|jdkj�}|j|dkretj |jd|�}tj"|j|d�}t	j||jd��}t%j&||j(��S)N���Fr�rrU)r�r�r�r]rr�r��any�
from_codesr��appendr�r�r��argmaxr�nunique_ints�insertr�_with_inferrT)rHr�r��cat�na_idx�
na_unique_idx�	new_codess       r9r�zGrouping._group_index�s ���0�0���w��|�|�� 8� 8��g�{�3�3�3��z�z�u��G��4�9�9�;�%�0�0��I�I�g�m�m�b�T�2�G�4F�4F�QV����U��a���*�*���)�)�a�-�/�/�1���9�9�V�$�q�(�$.�$;�$;�C�I�I�g�v�<N�$O�M� "�	�	�'�-�-��� K�I�)�4�4�!�7�#5�#5���G�� � ��t�y�y�9�9r:c�b�tjdtt���|jS)NzKgroup_index is deprecated and will be removed in a future version of pandasr�)r@rArBrr�rps r9�group_indexzGrouping.group_index�s*���
�
�
 �"�'�)�		
�� � � r:c��|j�r�|j}|j}|jrIt	j
|j�}||dk7}|jr4tj|�}ntjt|��}tj|||jd��}|j}|js�|dk}tj |�r�|jr#t|�}tj"|||�}n\|j%�}t	j&|d|�}tj"||k\|dz|�}tj"|||�}|js|j)|j*�}||fSt-|jt.j0�r:|jj2}|jj4j6}||fS|j8�=t|j|j8��}|j}|j8}||fSt	j:|j|j|j��\}}||fS)Nr�F)r�r��orderedrKrr�)r�)r%�use_na_sentinel)r�r�r�r�r�unique1dr�r�r�r%�aranger�rr�r�r�r��wherer�r��reorder_categoriesr�r]rr��
codes_infor�r�r��	factorize)	rHr�r��ucodesr�r��na_mask�na_coder�s	         r9r�zGrouping._codes_and_uniques	s���#�#��&�&�C����J��~�~�#�,�,�S�Y�Y�7����"��-���:�:��W�W�V�_�F����3�z�?�3��!�,�,���S�[�[�SX��G��I�I�E��<�<��!�)���6�6�'�?��z�z�"%�j�/�� "����'�5� A��")���!1��",�"9�"9�%���.�"I�� "����'�)9�5�1�9�e� L�� "����'�5� A���>�>�!�4�4�T�_�_�E���'�>�!�
��,�,�c�o�o�
>��(�(�3�3�E��*�*�7�7�?�?�G��g�~���]�]�
&��d�2�2�t�}�}�M�C��I�I�E��m�m�G��g�~��(�1�1��$�$�4�:�:�t�|�|��N�E�7��g�~�r:c��tj|j|jd��}|jj|�S)NFr�)rr�r�r�r��groupby)rHr�s  r9rtzGrouping.groupsHs5���%�%�d�j�j�$�2C�2C�e�T���{�{�"�"�4�(�(r:)NNNTFFTN)r`rrNzNDFrame | Noner%r$r�r$r�r$r&r$r�zArrayLike | Noner�r�r�)r�r�r�r$)r�r)r�z
int | None)r�r�)r�z$dict[Hashable, npt.NDArray[np.intp]])r�znpt.NDArray[np.signedinteger])r�rr�)r�z/tuple[npt.NDArray[np.signedinteger], ArrayLike])r�zdict[Hashable, np.ndarray])rnr�r�r�r�r�rIr�r�rr�rTr�r�r�r�r�r�r�r�r�r�r�r�rt�r:r9r�r��s����@48�F�0�7�$�$����M�
�"������$(�g/��g/��	g/��
g/��g/��g/��g/�"�g/�
�g/�R(�"��3��3�����"�����&��&��)��)��*��*��*��*��%��%��	!��	!��"��"��:��:�,�!��!��<��<�|�)��)r:r�c�	���j|�}|��t|t�r?t|�rt	|�dk(r|d}|��t|�r�|j
|�}d}n�t|�r1t	|�}	|	dk(r|d}n|	dk(rtd��td��t|t�r>�j|�j|k7r5td|�d�j|�����|dkDs|dkrtd	��d}|}t|t�rH|j�d
��\}
�|j�
|
t��fS|
t|jh��fSt|tj �r
|t��fSt|t"�s|g}d
}n|}t	|�t	|�k(}t%d�|D��}
t%d
�|D��}t%d�|D��}|
sk|si|sg|re|�ct�t&�rt)�fd�|D��}n&t�t*�sJ�t)�fd�|D��}|st-j.|�g}t|t0t"f�r|�dgt	|�z}|}n|gt	|�z}g}t3�}d�fd�}d�fd�}t5||�D�],\}}||�rd}|j7|j�n�||�r��j8dk7rR|�vrN|r�j;||��d|�|}}}|j8dk7rtd|�d���|j7|�na�j=||��rd
|d}}}nGt?|��t|t�r*|j�|j7|j�d}nd
}t|t@�stA||�|||||��n|}|jC|���/t	|�dk(rt	��rtd��t	|�dk(rI|jCtAtEgd��tGjHgtFjJ����tj ||||��}
|
t|��fS)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 axis,level,sort, while
    the passed in axis, 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.

    Nr�rzNo group keys passed!z*multiple levels only valid with MultiIndexzlevel name z is not the name of the r�z2level > 0 or level < -1 only valid with MultiIndexFr�c3�VK�|]!}t|�xst|t����#y�wr�)�callabler]�dict�ry�gs  r9r{zget_grouper.<locals>.<genexpr>�s$����H�4�a�x��{�9�j��D�&9�9�4�s�')c3�HK�|]}t|ttf����y�wr�)r]r#r�rs  r9r{zget_grouper.<locals>.<genexpr>�s����H�4�a�z�!�g�x�%8�9�4�s� "c	3�zK�|]3}t|ttttt
jf����5y�wr�)r]�list�tuplerrr�r�rs  r9r{zget_grouper.<locals>.<genexpr>�s*�����IM�A�
�1�t�U�F�E�2�:�:�>�?��s�9;c3�n�K�|],}|�jvxs|�jjv���.y�wr�)�columnsr`rf�ryrrNs  �r9r{zget_grouper.<locals>.<genexpr>�s3�����'�BF�Q��S�[�[� �8�A������$8�8�$�s�25c3�N�K�|]}|�jjv���y�wr�)r`rfrs  �r9r{zget_grouper.<locals>.<genexpr>�s�����&J�T��q�C�I�I�O�O�';�T�s�"%c���t|�s2�jdk(ry�jd}	|j|�yy#tt
tf$rYywxYw)Nr�Fr�T)�_is_label_liker��axes�get_locrb�	TypeErrorr
)r*�itemsrNs  �r9�
is_in_axiszget_grouper.<locals>.is_in_axis�sZ����c�"��x�x�1�}���H�H�R�L�E�
��
�
�c�"�
��	�i�):�;�
��
�s�A�A�Ac���t|d�syt�s
t�rW	�|j}t|t�r6t|t�r&|jj|jd�Sy	|�|juS#tt
ttf$rYywxYw#tt
ttf$rYywxYw)NrTFr)r�rrrTrb�
IndexErrorr
r	r]r�_mgr�references_same_values)�gpr�obj_gpr_columnrNs  �r9�	is_in_objzget_grouper.<locals>.is_in_obj�s�����s�F�#��� �$6�$8�
�!$�S�X�X����#�v�&�:�n�f�+M��x�x�6�6�"�'�'�����		��#�c�h�h�-�'�'���j�*;�=P�Q�
��
���*�&7�9L�M�	��	�s#�B�;B+�B(�'B(�+C�CTrZr�r�)rNr+r%r�r�r&r�)r�)r%r&r�)&rcr]rr
r�rr�r[r�rT�_get_axis_namer#rQr*�	frozensetrr�rr�r�allr�com�asarray_tuplesafer�set�zip�addr��_check_label_or_level_ambiguity�_is_level_referencerbr�r�rr�rh�intp)rNr*r-r+r%r�rKr&�
group_axis�nlevelsrP�keys�match_axis_length�any_callable�any_groupers�
any_arraylike�all_in_columns_index�levelsr��
exclusionsrrrr�rT�pings`                         r9rMrMNsu���@���t�$�J�
���j�*�-��E�"�s�5�z�Q���a����{�y��/� �1�1�%�8�����E�"��e�*���a�<�!�!�H�E���\�$�%<�=�=�$�%Q�R�R��%��%��=�=��&�+�+�u�4�$�%�e�W�-"�"%�"4�"4�T�":�!;�=������e�b�j� �!U�V�V��E��C��#�w���'�'��e�'�<�����7�7�?��I�K��,�,��I�s�w�w�i�0�#�5�5�
�C����	)��I�K��$�$��c�4� ��u��!������I��Z��8���H�4�H�H�L��H�4�H�H�L���IM���M�
�����M��c�9�%�#&�'�BF�'�$� ��c�6�*�*�*�#&�&J�T�&J�#J� �#��)�)�$�/�0�D��%�%���'��;��6�C��J�&�D�����3�t�9�$�� "�I� #��J�
� �4�$��'�
��U��S�>��G��N�N�3�8�8�$�
��_��x�x�1�}������7�7��$�7�G�%)�3��C��s����8�8�q�=�%�}�T�F�:M�%N�O�O����t�$��(�(��4�(�8�&+�S�$�����s�m�#�
��W�
%�#�'�'�*=��N�N�3�7�7�#��G��G��c�8�,�
������!���	
��	
�	�����W(�Z�9�~���s�3�x��0�1�1�
�9�~�������%��%�"8�"�(�(�2�R�W�W�:U�V�W��o�o�j�)�$�v�N�G��I�j�)�3�.�.r:c�T�t|ttf�xs|duxrt|�Sr�)r]r�rr)�vals r9rr8s%���c�C��<�(�P�S��_�-O��3��Pr:c��t|t�r|jSt|t�rB|jj|�r|jS|j|�jSt|t�r|jSt|tttttjf�rOt|�t|�k7rt!d��t|ttf�rt#j$|�}|S|S)Nz$Grouper and axis must be same length)r]rr1rr`�equalsr��reindexrrrrrr�r�r�r[rr)r-rPs  r9r�r�<s����'�4� ��{�{��	�G�V�	$��=�=����%��?�?�"��?�?�4�(�0�0�0�	�G�Z�	(�����	�G�d�E�5�+�r�z�z�J�	K��w�<�3�t�9�$��C�D�D��g��e�}�-��+�+�G�4�G����r:)NrNTFTT)rNrr-rr%r$r�r$rKr$r&r$r�z5tuple[ops.BaseGrouper, frozenset[Hashable], NDFrameT]r�)r-r)Ar��
__future__r�typingrrr@�numpyr��pandas._configrr�pandas._libsr�pandas._libs.tslibsr	�
pandas.errorsr
�pandas.util._decoratorsr�pandas.util._exceptionsr�pandas.core.dtypes.commonr
r�pandas.core.dtypes.dtypesr�pandas.corer�pandas.core.arraysrr�pandas.core.common�core�commonr�pandas.core.framer�pandas.core.groupbyr�pandas.core.groupby.categoricalr�pandas.core.indexes.apirrr�pandas.core.seriesr�pandas.io.formats.printingr�collections.abcrr�pandas._typingrrrr �pandas.core.genericr!r#r�rMrr�r�r:r9�<module>rOs���#�����
�3�+�2�4��7�"��!� �'�#�>���
&�3���
��,�c&�c&�L
�b)�b)��b)�N	
��
�����g/�	�g/��g/�
�g/��
g/��g/�
�g/�;�g/�TQ�r:

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists