Файловый менеджер - Редактировать - /home/digitalm/venv/lib/python3.7/site-packages/pandas/core/__pycache__/aggregation.cpython-37.pyc
Назад
B �5�g!2 � @ s: d Z ddlmZ ddlmZ ddlmZ ddlmZm Z m Z mZmZm Z mZ ddlmZmZ ddlmZmZ ddlmZ dd lmZ dd lm mZ ddlmZ er�ddlm Z d dd�dd�Z!dd�dd�Z"ddd�dd�Z#ddd�dd�Z$ddd �d!d"�Z%d#d#d$�d%d&�Z&d'd(d)d*d+d,�d-d.�Z'dd/d�d0d1�Z(d S )2z� aggregation.py contains utility functions to handle multiple named and lambda kwarg aggregations in groupby and DataFrame/Series aggregation � )�annotations)�defaultdict)�partial)� TYPE_CHECKING�Any�Callable�DefaultDict�Hashable�Iterable�Sequence)�AggFuncType� FrameOrSeries)�is_dict_like�is_list_like)� ABCSeries)�SpecificationErrorN)�Index)�SerieszAggFuncType | NonezCtuple[bool, AggFuncType | None, list[str] | None, list[int] | None])�func�returnc K st | dkot f |�}d}d}|sVt| t�rFt| �tt| ��krFtd��n| dkrVtd��|rht|�\} }}|| ||fS )a� This is the internal function to reconstruct func given if there is relabeling or not and also normalize the keyword to get new order of columns. If named aggregation is applied, `func` will be None, and kwargs contains the column and aggregation function information to be parsed; If named aggregation is not applied, `func` is either string (e.g. 'min') or Callable, or list of them (e.g. ['min', np.max]), or the dictionary of column name and str/Callable/list of them (e.g. {'A': 'min'}, or {'A': [np.min, lambda x: x]}) If relabeling is True, will return relabeling, reconstructed func, column names, and the reconstructed order of columns. If relabeling is False, the columns and order will be None. Parameters ---------- func: agg function (e.g. 'min' or Callable) or list of agg functions (e.g. ['min', np.max]) or dictionary (e.g. {'A': ['min', np.max]}). **kwargs: dict, kwargs used in is_multi_agg_with_relabel and normalize_keyword_aggregation function for relabelling Returns ------- relabelling: bool, if there is relabelling or not func: normalized and mangled func columns: list of column names order: list of columns indices Examples -------- >>> reconstruct_func(None, **{"foo": ("col", "min")}) (True, defaultdict(<class 'list'>, {'col': ['min']}), ('foo',), array([0])) >>> reconstruct_func("min") (False, 'min', None, None) NzFFunction names must be unique if there is no new column names assignedz4Must provide 'func' or tuples of '(column, aggfunc).)�is_multi_agg_with_relabel� isinstance�list�len�setr � TypeError�normalize_keyword_aggregation)r �kwargsZ relabeling�columns�order� r �M/home/digitalm-up/venv/lib/python3.7/site-packages/pandas/core/aggregation.py�reconstruct_func'