hyb
2025-11-18 7539e6f48c75dcaeb808359cccfd1c0d0d182ce8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Ë
nñúh&%ãóê—ddlmZddlmZddlmZmZmZddlZ    ddl
m Z m Z ddl mZmZerddlmZddlmZmZdd    lmZGd
„d «Ze ej0«Gd „d ««ZGd„d«Zy)é)Ú annotations)ÚIterable)Ú TYPE_CHECKINGÚLiteralÚcastN)Úcache_readonlyÚdoc)Ú
is_integerÚ is_list_like)ÚPositionalIndexer)Ú    DataFrameÚSeries)Úgroupbycóv—eZdZdZed d„«Z                d d„Zd d„Zdd„Zdd„Z    dd„Z
edd„«Z edd    „«Z y
)ÚGroupByIndexingMixinz<
    Mixin for adding ._positional_selector to GroupBy.
    cór—tr%ttj|«}t    |«S|}t    |«S)aÌ
 
        Return positional selection for each group.
 
        ``groupby._positional_selector[i:j]`` is similar to
        ``groupby.apply(lambda x: x.iloc[i:j])``
        but much faster and preserves the original index and order.
 
        ``_positional_selector[]`` is compatible with and extends :meth:`~GroupBy.head`
        and :meth:`~GroupBy.tail`. For example:
 
        - ``head(5)``
        - ``_positional_selector[5:-5]``
        - ``tail(5)``
 
        together return all the rows.
 
        Allowed inputs for the index are:
 
        - An integer valued iterable, e.g. ``range(2, 4)``.
        - A comma separated list of integers and slices, e.g. ``5``, ``2, 4``, ``2:4``.
 
        The output format is the same as :meth:`~GroupBy.head` and
        :meth:`~GroupBy.tail`, namely
        a subset of the ``DataFrame`` or ``Series`` with the index and order preserved.
 
        Returns
        -------
        Series
            The filtered subset of the original Series.
        DataFrame
            The filtered subset of the original DataFrame.
 
        See Also
        --------
        DataFrame.iloc : Purely integer-location based indexing for selection by
            position.
        GroupBy.head : Return first n rows of each group.
        GroupBy.tail : Return last n rows of each group.
        GroupBy.nth : Take the nth row from each group if n is an int, or a
            subset of rows, if n is a list of ints.
 
        Notes
        -----
        - The slice step cannot be negative.
        - If the index specification results in overlaps, the item is not duplicated.
        - If the index specification changes the order of items, then
          they are returned in their original order.
          By contrast, ``DataFrame.iloc`` can change the row order.
        - ``groupby()`` parameters such as as_index and dropna are ignored.
 
        The differences between ``_positional_selector[]`` and :meth:`~GroupBy.nth`
        with ``as_index=False`` are:
 
        - Input to ``_positional_selector`` can include
          one or more slices whereas ``nth``
          just handles an integer or a list of integers.
        - ``_positional_selector`` can  accept a slice relative to the
          last row of each group.
        - ``_positional_selector`` does not have an equivalent to the
          ``nth()`` ``dropna`` parameter.
 
        Examples
        --------
        >>> df = pd.DataFrame([["a", 1], ["a", 2], ["a", 3], ["b", 4], ["b", 5]],
        ...                   columns=["A", "B"])
        >>> df.groupby("A")._positional_selector[1:2]
           A  B
        1  a  2
        4  b  5
 
        >>> df.groupby("A")._positional_selector[1, -1]
           A  B
        1  a  2
        2  a  3
        4  b  5
        )rrrÚGroupByÚGroupByPositionalSelector©ÚselfÚ groupby_selfs  úOH:\Change_password\venv_build\Lib\site-packages\pandas/core/groupby/indexing.pyÚ_positional_selectorz)GroupByIndexingMixin._positional_selector%s7€õ\ 䤧¡°Ó6ˆLô)¨Ó6Ð6ð ˆLä(¨Ó6Ð6ócóF—t|«rgtd„tt|«D««r'|j    ttt
|««}n…|j tt|««}net|t«r|j|«}nCt|«r |jtt
|««}ntdt|«›d«‚t|t«r!|r|j dk\}n|j dk}tt"j$|«S)Nc3ó2K—|]}t|«–—Œy­w©N)r
)Ú.0Úis  rú    <genexpr>zJGroupByIndexingMixin._make_mask_from_positional_indexer.<locals>.<genexpr>€sèø€Ò> Q”:˜a—=Ñ>ùs‚zInvalid index zE. Must be integer, list-like, slice or a tuple of integers and slicesr)r ÚallrrÚ_make_mask_from_listÚintÚ_make_mask_from_tupleÚtupleÚ
isinstanceÚsliceÚ_make_mask_from_slicer
Ú_make_mask_from_intÚ    TypeErrorÚtypeÚboolÚ_ascending_countÚnpÚndarray©rÚargÚmasks   rÚ"_make_mask_from_positional_indexerz7GroupByIndexingMixin._make_mask_from_positional_indexer{sì€ô ˜Ô ÜÑ>¬$¬x¸Ó*=Ô>Ô>Ø×0Ñ0´´h¼s±mÀSÓ1IÓJ‘à×1Ñ1´$´u¸cÓ2BÓC‘ä ˜œUÔ #Ø×-Ñ-¨cÓ2‰DÜ ˜Œ_Ø×+Ñ+¬D´°c«NÓ;‰D䨠¤ c£  ð,&ð&óð ô dœDÔ !ÙØ×,Ñ,°Ñ1‘à×,Ñ,¨qÑ0ä”B—J‘J Ó%Ð%rcóP—|dk\r|j|k(S|j| dz
k(S)Nré)r-Ú_descending_count)rr1s  rr)z(GroupByIndexingMixin._make_mask_from_int˜s1€Ø !Š8Ø×(Ñ(¨CÑ/Ð /à×)Ñ)¨s¨d°Q©hÑ7Ð 7rcó—|Dcgc]
}|dk\sŒ    |‘Œ }}|Dcgc]}|dksŒ    | dz
‘Œ}}d}|r#|tj|j|«z}|r#|tj|j|«z}|Scc}wcc}w)Nrr5F)r.Úisinr-r6)rÚargsr1ÚpositiveÚnegativer2s      rr"z)GroupByIndexingMixin._make_mask_from_listžsˆ€Ø#'Ö4˜C¨3°!«8’CÐ4ˆÐ4Ø(,Ö8 °°a³SD˜1“HÐ8ˆÐ8à"'ˆá Ø ”B—G‘G˜D×1Ñ1°8Ó<Ñ <ˆDá Ø ”B—G‘G˜D×2Ñ2°HÓ=Ñ =ˆDàˆ ùò5ùÚ8s…
A=A=š
B¥Bcóì—d}|D]l}t|«r#||jtt|««z}Œ1t    |t
«r||j |«z}ŒVtdt|«›d«‚|S)NFzInvalid argument z. Should be int or slice.)    r
r)rr#r&r'r(Ú
ValueErrorr+)rr9r2r1s    rr$z*GroupByIndexingMixin._make_mask_from_tuple¬s|€Ø"'ˆàò    ˆCܘ#ŒØ˜×0Ñ0´´c¸3³Ó@Ñ@‘ܘC¤Ô'ؘ×2Ñ2°3Ó7Ñ7‘ä Ø'¬¨S«     {Ð2KÐLóðð     ðˆ rcól—|j}|j}|j}||dkrtd|›d«‚d}|€d}|€|dkDr¾||j|zdk(z}n¨|dk\r0||j|k\z}|dkDrŒ||j|z
|zdk(z}ns||j
| kz}|j
|zdz}|j|j
z|dzzdk}t j||j|«}|||zdk(z}|,|dk\r||j|kz}|S||j
| k\z}|S)Nrz Invalid step z. Must be non-negativeTr5)ÚstartÚstopÚstepr=r-r6r.Úwhere)rr1r?r@rAr2Ú offset_arrayÚ limit_arrays        rr(z*GroupByIndexingMixin._make_mask_from_slice»s€Ø—    ‘    ˆØx‰xˆØx‰xˆà Ð   q¢Ü˜}¨T¨FÐ2HÐIÓJÐ Jà"&ˆà ˆ<؈Dà ˆ=ؐaŠxؘ×-Ñ-°Ñ4¸Ñ9Ñ9‘à aŠZØ D×)Ñ)¨UÑ2Ñ 2ˆDàaŠxؘ×.Ñ.°Ñ6¸$Ñ>À!ÑCÑC‘ð D×*Ñ*¨e¨VÑ3Ñ 3ˆDà×1Ñ1°EÑ9¸AÑ=ˆLà×%Ñ%¨×(>Ñ(>Ñ>À%È!Á)ÑLØñˆKôŸ8™8 K°×1FÑ1FÈ ÓUˆLà L 4Ñ'¨1Ñ,Ñ ,ˆDà РؐqŠyؘ×-Ñ-°Ñ4Ñ4ðˆ ð˜×.Ñ.°4°%Ñ7Ñ7àˆ rcó†—tr*ttj|«}|j    «S|}|j    «Sr©rrrrÚ_cumcount_arrayrs  rr-z%GroupByIndexingMixin._ascending_countås<€å ܤ§¡°Ó6ˆLð×+Ñ+Ó-Ð-ð ˆLà×+Ñ+Ó-Ð-rcól—trttj|«}n|}|j    d¬«S)NF)Ú    ascendingrFrs  rr6z&GroupByIndexingMixin._descending_countîs.€å ܤ§¡°Ó6‰LàˆLà×+Ñ+°eÐ+Ó<Ð<rN)Úreturnr)r1úPositionalIndexer | tuplerJú
np.ndarray)r1r#rJrL)r9z Iterable[int]rJúbool | np.ndarray)r9r%rJrM)r1r'rJrM)rJrL) Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrr3r)r"r$r(r-r6©rrrr sr„ñðòS7óðS7ðj&à &ð&ð
ó&ó:8ó ó ó(ðTò.óð.ðò=óñ=rrcó—eZdZdd„Zdd„Zy)rcó—||_yr©Úgroupby_object©rrVs  rÚ__init__z"GroupByPositionalSelector.__init__úó
€Ø,ˆÕrcón—|jj|«}|jj|«S)a
        Select by positional index per group.
 
        Implements GroupBy._positional_selector
 
        Parameters
        ----------
        arg : PositionalIndexer | tuple
            Allowed values are:
            - int
            - int valued iterable such as list or range
            - slice with step either None or positive
            - tuple of integers and slices
 
        Returns
        -------
        Series
            The filtered subset of the original groupby Series.
        DataFrame
            The filtered subset of the original groupby DataFrame.
 
        See Also
        --------
        DataFrame.iloc : Integer-location based indexing for selection by position.
        GroupBy.head : Return first n rows of each group.
        GroupBy.tail : Return last n rows of each group.
        GroupBy._positional_selector : Return positional selection for each group.
        GroupBy.nth : Take the nth row from each group if n is an int, or a
            subset of rows, if n is a list of ints.
        )rVr3Ú_mask_selected_objr0s   rÚ __getitem__z%GroupByPositionalSelector.__getitem__ýs1€ð>×"Ñ"×EÑEÀcÓJˆØ×"Ñ"×5Ñ5°dÓ;Ð;rN©rVzgroupby.GroupByrJÚNone)r1rKrJúDataFrame | Series)rNrOrPrXr\rRrrrrøs „ó-ô <rrcó6—eZdZdZdd„Z    d                    dd„Zd    d„Zy)
ÚGroupByNthSelectorzO
    Dynamically substituted for GroupBy.nth to enable both call and index
    có—||_yrrUrWs  rrXzGroupByNthSelector.__init__%rYrNcó:—|jj||«Sr©rVÚ_nth)rÚnÚdropnas   rÚ__call__zGroupByNthSelector.__call__(s€ð
×"Ñ"×'Ñ'¨¨6Ó2Ð2rcó8—|jj|«Srrd)rrfs  rr\zGroupByNthSelector.__getitem__/s€Ø×"Ñ"×'Ñ'¨Ó*Ð*rr]r)rfrKrgzLiteral['any', 'all', None]rJr_)rfrKrJr_)rNrOrPrQrXrhr\rRrrrara s7„ñó-ð /3ð3à $ð3ð,ð3ð
ó    3ô+rra)Ú
__future__rÚcollections.abcrÚtypingrrrÚnumpyr.Úpandas.util._decoratorsrr    Úpandas.core.dtypes.commonr
r Úpandas._typingr Úpandasr rÚpandas.core.groupbyrrrrrarRrrú<module>rsssðÝ"å$÷ñó ÷÷
ñ
Ý0÷õ,÷U=ñU=ñpÐ×.Ñ.Ó/÷$<ð$<ó0ð$<÷N+ò+r