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
U
¬ý°dA ã@sLddlmZddlZddlmZddlmZmZm    Z    dddddœd    d
„Z
dS) é)Ú annotationsN)Úunique1d)Ú CategoricalÚCategoricalDtypeÚrecode_for_categoriesrÚboolz&tuple[Categorical, Categorical | None])ÚcÚsortÚobservedÚreturnc Csð|rdt|jƒ}||dk}|r(t |¡}|j |¡}t|j|j|ƒ}t||jd}t    ||dd|fS|rp|dfSt 
|j  ¡¡}t|j|jdkƒ}    |r¢t |    ¡}    t |ƒt |    ƒkrÒtj ||    dd}
t |    |
f¡}n|    }t    || ¡j |¡ƒdfS)a=
    Code the categories to ensure we can groupby for categoricals.
 
    If observed=True, we return a new Categorical with the observed
    categories only.
 
    If sort=False, return a copy of self, coded with categories as
    returned by .unique(), followed by any categories not appearing in
    the data. If sort=True, return self.
 
    This method is needed solely to ensure the categorical index of the
    GroupBy result has categories in the order of appearance in the data
    (GH-8868).
 
    Parameters
    ----------
    c : Categorical
    sort : bool
        The value of the sort parameter groupby was called with.
    observed : bool
        Account only for the observed values
 
    Returns
    -------
    Categorical
        If sort=False, the new categories are set to the order of
        appearance in codes (unless ordered=True, in which case the
        original order is preserved), followed by any unrepresented
        categories in the original order.
    Categorical or None
        If we are observed, return the original categorical, otherwise None
    éÿÿÿÿ)ÚorderedT)ÚdtypeZfastpathN)Z assume_unique)rÚcodesÚnpr    Ú
categoriesZtakerrr rZarangeZnuniqueÚlenZ    setdiff1dZ concatenateÚunique) rr    r
Z unique_codesZ
take_codesrrrZ    all_codesZunique_notnan_codesZ missing_codes©rúVd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/core/groupby/categorical.pyÚrecode_for_groupby s($
 
 
r) Ú
__future__rÚnumpyrZpandas.core.algorithmsrZpandas.core.arrays.categoricalrrrrrrrrÚ<module>s