Файловый менеджер - Редактировать - /home/digitalm/venv/lib/python3.7/site-packages/pandas/core/groupby/__pycache__/categorical.cpython-37.pyc
Назад
B �5�g� � @ sl d dl mZ d dlZd dlmZ d dlmZmZm Z d dl mZ ddddd �d d�Zddddd �dd�Z dS )� )�annotationsN)�unique1d)�Categorical�CategoricalDtype�recode_for_categories)�CategoricalIndexr �boolz&tuple[Categorical, Categorical | None])�c�sort�observed�returnc C s� |rft | j�}||dk }| jr*t�|�}| j�|�}t| j| j|�}t|| jd�}t ||dd�| fS |rr| dfS | � � }|j|jdk }|jr�t�|�}|�|j�|��}|�| j| j� |j� �}| �|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)r �codesr �npr � categoriesZtaker r r �unique�set_categories�add_categories�isinZreorder_categories) r r r Zunique_codesZ take_codesr r r �cat� r �U/home/digitalm-up/venv/lib/python3.7/site-packages/pandas/core/groupby/categorical.py�recode_for_groupby s$ $ r r )r r �cir c C s0 |r|� | j�S | j| j�|j� }|�|�S )a; Reverse the codes_to_groupby to account for sort / observed. Parameters ---------- c : Categorical sort : bool The value of the sort parameter groupby was called with. ci : CategoricalIndex The codes / categories to recode Returns ------- CategoricalIndex )r r r r )r r r Znew_catsr r r �recode_from_groupby[ s r )� __future__r �numpyr Zpandas.core.algorithmsr Zpandas.core.arrays.categoricalr r r Zpandas.core.indexes.apir r r r r r r �<module> s M
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Генерация страницы: 0.05 |
proxy
|
phpinfo
|
Настройка