U
    f/eB                     @  s  d dl mZ d dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZ d dlZd dlZd dlmZ d dlmZ d dlmZmZmZmZmZmZmZ d dlmZ d dlmZ d d	lm Z m!Z!m"Z"m#Z# d d
l$m%Z%m&Z&m'Z' d dl(m)Z) d dl*m+Z+m,Z,m-Z- d dl.m/  m0Z1 d dl2m3Z4m5Z5m6Z6 erTd dl7m8Z8m9Z9m:Z: d dl;m<Z< d dl=m>Z> d dl?m@Z@ eeAef ZBd,dddddddddZCG dd dejDdZEG dd  d eEZFG d!d deFZGG d"d# d#eGZHG d$d% d%eGZIG d&d' d'eFZJG d(d) d)eEZKG d*d+ d+eEZLdS )-    )annotationsN)TYPE_CHECKINGAnyDictHashableIteratorListcast)option_context)lib)AggFuncTypeAggFuncTypeBaseAggFuncTypeDict
AggObjTypeAxisFrameOrSeriesFrameOrSeriesUnion)cache_readonly)is_nested_object)is_dict_likeis_extension_array_dtypeis_list_likeis_sequence)ABCDataFrame
ABCNDFrame	ABCSeries)	safe_sort)	DataErrorSelectionMixinSpecificationError)array!create_series_with_explicit_dtypeensure_wrapped_if_datetimelike)	DataFrameIndexSeries)GroupBy)	Resampler)
BaseWindowFr#   r   r   bool
str | None
FrameApply)objfuncaxisrawresult_typereturnc                 C  s8   |  |}|dkrt}n|dkr$t}|| |||||dS )z=construct and return a row or column based frame apply objectr      r/   r0   argskwargs)_get_axis_numberFrameRowApplyFrameColumnApply)r,   r-   r.   r/   r0   r4   r5   klass r:   5/tmp/pip-unpacked-wheel-tiezk1ph/pandas/core/apply.pyframe_applyG   s    

r<   c                   @  s   e Zd ZU ded< ddddddZejd	d
ddZdd
ddZd	d
ddZ	dd Z
d	d
ddZd	d
ddZd	d
ddZd	d
ddZd	d
ddZdd	ddd d!d"Zdd#d$d%Zd&S )'Applyintr.   r   r)   r*   )r,   r/   r0   c                   s|   || _ || _ pd| _pi | _|dkr0td|| _s> rhttjt	fsht
sh fdd}n}| _|| _d S )Nr:   )Nreduce	broadcastexpandzUinvalid value for result_type, must be one of {None, 'reduce', 'broadcast', 'expand'}c                   s   | f S Nr:   xr4   r-   r5   r:   r;   f   s    zApply.__init__.<locals>.f)r,   r/   r4   r5   
ValueErrorr0   
isinstancenpufuncstrr   orig_frF   )selfr,   r-   r/   r0   r4   r5   rF   r:   rE   r;   __init__e   s*    	

zApply.__init__r   r1   c                 C  s   d S rB   r:   rM   r:   r:   r;   apply   s    zApply.applyzFrameOrSeriesUnion | Nonec                 C  sx   | j }| j}| j}| j}t|tr*|  S t|r:|  S t	|rJ| 
 S t|rtt|}|rt|st|stt|| S dS )z
        Provide an implementation for the aggregators.

        Returns
        -------
        Result of aggregation, or None if agg cannot be performed by
        this method.
        N)r,   rF   r4   r5   rH   rK   	apply_strr   agg_dict_liker   agg_list_likecallablecomget_cython_funcgetattrrM   r,   argr4   r5   rF   r:   r:   r;   agg   s    	

z	Apply.aggc              
     sf  | j }| j | j}| j}| j}|jdk}||dkrV|r>t|jj	 df||jS t
 rt sttt   |rdd  D  n fdd|D  t rtt  |  S tt  z|  }W nB tk
r    Y n. tk
r } ztd|W 5 d}~X Y nX t|ttfr:|jr:|js:tdt|ttfrZ|j|jsbtd|S )	aI  
        Transform a DataFrame or Series.

        Returns
        -------
        DataFrame or Series
            Result of applying ``func`` along the given axis of the
            Series or DataFrame.

        Raises
        ------
        ValueError
            If the transform function fails or does not transform.
        r2   r   c                 S  s   i | ]}t |p||qS r:   )rV   get_callable_name).0vr:   r:   r;   
<dictcomp>   s      z#Apply.transform.<locals>.<dictcomp>c                   s   i | ]
}| qS r:   r:   )r]   colr-   r:   r;   r_      s      Transform function failedNFunction did not transform)r,   rL   r.   r4   r5   ndimr6   AssertionErrorT	transformr   r   r	   r   r   r   transform_dict_liketransform_str_or_callable	TypeError	ExceptionrG   rH   r   r   emptyindexequals)rM   r,   r.   r4   r5   Z	is_seriesresulterrr:   ra   r;   rg      sH    



zApply.transformc                 C  s,  ddl m} | j}| j}| j}t|ts,tt|dkr@t	d| 
d||}i }g }d}| D ]\}	}
|j|	dd}z|j|
df||||	< W qb tk
r } z.t|dkr|nt|tsd	}||	 W 5 d
}~X Y qbX qb|s|rtnt	}|dt|dkr tj| dtdd ||ddS )zC
        Compute transform in the case of a dict-like func
        r   concat$No transform functions were providedrg   Tr2   rd   >   rs   rc   FNrb   z did not transform successfully and did not raise a TypeError. If any error is raised except for TypeError, this will raise in a future version of pandas. Drop these columns/ops to avoid this warning.   )
stacklevelr.   )pandas.core.reshape.concatrr   r,   r4   r5   rH   r   re   lenrG   normalize_dictlike_argitems_gotitemrg   rk   rK   rj   appendwarningswarnFutureWarning)rM   r-   rr   r,   r4   r5   resultsZfailed_namesZall_type_errorsnamehowcolgrp   r9   r:   r:   r;   rh      s>    
zApply.transform_dict_likec                 C  s   | j }| j}| j}t|tr0| j||f||S |sR|sRt|}|rRt|| S z|j	|fd|i|W S  t
k
r   ||f|| Y S X dS )zL
        Compute transform in the case of a string or callable func
        r4   N)r,   r4   r5   rH   rK   _try_aggregate_string_functionrV   rW   rX   rQ   rk   )rM   r-   r,   r4   r5   rF   r:   r:   r;   ri     s    

zApply.transform_str_or_callablec                   s8  ddl m} | j}ttt | j}t|ts2|}n|j	j
dkrF|j	}n|j}g }g }|j
dkr|D ]\}|j|jd|d}z||}	W n tk
r   Y qbX ||	 t|p|}
||
 qbng }t|D ]\}}|j|d|jdd|f d}z||}	W n^ ttfk
r   Y q tk
r` } z&dt|kr>ndt|krNn W 5 d}~X Y qX ||	 || q|j|}t|stdz|||ddd	}W n\ tk
r } z<dd
lm} ||||jd}t|rtd|| W Y S d}~X Y n.X |jj t  fdd|D }|j!|ddS dS )z
        Compute aggregation in the case of a list-like argument.

        Returns
        -------
        Result of aggregation.
        r   rq   r2   )rd   ZsubsetNzMust produce aggregated valuez
no resultsF)keysr.   sortr%   )rm   r   z3cannot combine transform and aggregation operationsc                 3  s    | ]}|j j kr|j V  qd S rB   )rm   size)r]   ro   Z
index_sizer:   r;   	<genexpr>  s     z&Apply.agg_list_like.<locals>.<genexpr>)copy)"rx   rr   r,   r	   r   r   rF   rH   r   _selected_objrd   Z_obj_with_exclusionsr|   r   	aggregaterj   r}   rV   r\   	enumerateZilocr   rG   rK   columnsZtakery   pandasr%   r   rm   r   nextZreindex)rM   rr   r,   rZ   selected_objr   r   ar   Znew_resr   indicesrm   r`   rp   Zconcatenatedr%   ro   Zfull_ordered_indexr:   r   r;   rT   4  sn    





zApply.agg_list_likec                   s  ddl m} ddlm} | jtt| j}tt	s>}d}nj
}j}| d||}|jdkrj|dd  fdd	| D nfd
d	| D t| }dd  D }t|r@fdd|D }|g kr|n|}|jdkr||}	|	|jj |	}ttrdnd}
|fdd	|D |
|d}nNt|rTtdn:ddl m} jdkr~tdj}nd}||d}|S )z
        Compute aggregation in the case of a dict-like argument.

        Returns
        -------
        Result of aggregation.
        r   )r$   rq   Nr[   r2   rt   c                   s   i | ]\}}|  |qS r:   )r[   r]   keyr   )r   r:   r;   r_     s      z'Apply.agg_dict_like.<locals>.<dictcomp>c                   s&   i | ]\}}| j |d d|qS )r2   rt   )r|   r[   r   )r,   r:   r;   r_     s     c                 S  s   g | ]}t |tqS r:   )rH   r   )r]   rr:   r:   r;   
<listcomp>  s     z'Apply.agg_dict_like.<locals>.<listcomp>c                   s   g | ]} | j s|qS r:   )rl   r]   kr   r:   r;   r     s     
    c                   s   i | ]}| | qS r:   r:   r   r   r:   r;   r_     s      )r.   r   zLcannot perform both aggregation and transformation operations simultaneouslyr   r%   )r   )r   r$   rx   rr   r,   r	   r   rF   rH   r   r   Z
_selectionrz   rd   r|   r{   listr   valuesallZ
_set_namesr   namesr   anyrG   r%   r   )rM   r$   rr   rZ   r   Z	selectionr   Z
is_ndframeZkeys_to_useZktur.   ro   r%   r   r:   )r   r,   r   r;   rS     sT    



  

zApply.agg_dict_likec                 C  sz   t t| j}| j}t||d}t|rbt|}d|jkrH| j	| j
d< n| j	dkrbtd| d| j||f| j| j
S )zy
        Compute apply in case of a string.

        Returns
        -------
        result: Series or DataFrame
        Nr.   r   z
Operation z does not support axis=1)r	   rK   rF   r,   rX   rU   inspectgetfullargspecr4   r.   r5   rG   r   )rM   rF   r,   r-   sigr:   r:   r;   rR     s    	


zApply.apply_strc                 C  s   | j j| j| jf| j| jS )z
        Compute apply in case of a list-like or dict-like.

        Returns
        -------
        result: Series, DataFrame, or None
            Result when self.f is a list-like or dict-like, None otherwise.
        )r,   r   rF   r.   r4   r5   rP   r:   r:   r;   apply_multiple  s    	zApply.apply_multiplerK   r   )r   r,   r-   r1   c           	        s   |dkst |dkr4t|tr4tdd | D sJtdd | D rRtd|jdkrt| t|j	 }t
|dkrttt|}td	| d
dd  t fdd| D ri }| D ]$\}} |s|g||< q|||< q|}|S )a  
        Handler for dict-like argument.

        Ensures that necessary columns exist if obj is a DataFrame, and
        that a nested renamer is not passed. Also normalizes to all lists
        when values consists of a mix of list and non-lists.
        )rQ   r[   rg   r[   c                 s  s   | ]\}}t |V  qd S rB   )r   r]   _r^   r:   r:   r;   r     s     z/Apply.normalize_dictlike_arg.<locals>.<genexpr>c                 s  s   | ]\}}t |V  qd S rB   )r   r   r:   r:   r;   r     s     znested renamer is not supportedr2   r   z
Column(s) z do not existc                 S  s   t | tttfS rB   )rH   r   tupledictrC   r:   r:   r;   <lambda>$      z.Apply.normalize_dictlike_arg.<locals>.<lambda>c                 3  s   | ]\}} |V  qd S rB   r:   )r]   r   rD   Zis_aggregatorr:   r;   r   *  s     )re   rH   r   r   r{   r   rd   setr   r   ry   r   r   KeyError)	rM   r   r,   r-   colsZcols_sortednew_funcr   r^   r:   r   r;   rz     s0    


zApply.normalize_dictlike_arg)rZ   c                 O  s   t |tstt||d}|dk	rbt|r4|||S t|dksDttdd |D dks^t|S tt|d}|dk	rt|dr||f||S td| dt	|j
 ddS )	z
        if arg is a string, then try to operate on it:
        - try to find a function (or attribute) on ourselves
        - try to find a numpy function
        - raise
        Nr   c                 S  s   g | ]}|d kr|qS )rw   r:   )r]   kwargr:   r:   r;   r   F  s      z8Apply._try_aggregate_string_function.<locals>.<listcomp>Z	__array__'z' is not a valid function for 'z' object)rH   rK   re   rX   rU   ry   rI   hasattrAttributeErrortype__name__rY   r:   r:   r;   r   5  s    
z$Apply._try_aggregate_string_functionN)r   
__module____qualname____annotations__rN   abcabstractmethodrQ   r[   rg   rh   ri   rT   rS   rR   r   rz   r   r:   r:   r:   r;   r=   b   s   
&?1aO-r=   )	metaclassc                   @  s4   e Zd ZdZeddddZeddddZdS )	NDFrameApplyzg
    Methods shared by FrameApply and SeriesApply but
    not GroupByApply or ResamplerWindowApply
    r$   rO   c                 C  s   | j jS rB   )r,   rm   rP   r:   r:   r;   rm   Y  s    zNDFrameApply.indexc                 C  s   | j | jS rB   )r,   Z_get_agg_axisr.   rP   r:   r:   r;   agg_axis]  s    zNDFrameApply.agg_axisN)r   r   r   __doc__propertyrm   r   r:   r:   r:   r;   r   S  s
   r   c                      s0  e Zd ZU ded< eejddddZeejddddZeejd	dd
dZ	ejddddddZ
eddddZeddddZedd ZeddddZddddZ fddZdd Zd d! Zddd"d#d$Zd%d& Zd'dd(d)Zddddd*d+Zdd fd,d-Z  ZS ).r+   r#   r,   r$   rO   c                 C  s   d S rB   r:   rP   r:   r:   r;   result_indexh  s    zFrameApply.result_indexc                 C  s   d S rB   r:   rP   r:   r:   r;   result_columnsm  s    zFrameApply.result_columnszIterator[Series]c                 C  s   d S rB   r:   rP   r:   r:   r;   series_generatorr  s    zFrameApply.series_generatorResTyper   r   	res_indexr1   c                 C  s   d S rB   r:   rM   r   r   r:   r:   r;   wrap_results_for_axisw  s    z FrameApply.wrap_results_for_axisc                 C  s   | j S rB   )r   rP   r:   r:   r;   res_columns  s    zFrameApply.res_columnsc                 C  s   | j jS rB   )r,   r   rP   r:   r:   r;   r     s    zFrameApply.columnsc                 C  s   | j jS rB   )r,   r   rP   r:   r:   r;   r     s    zFrameApply.valuesr%   c                 C  s   | j jS rB   )r,   dtypesrP   r:   r:   r;   r     s    zFrameApply.dtypesc              	   C  s   t | jr|  S t| jdkr6t| jdkr6|  S t| jtrJ| 	 S t| jt
jrt
jdd | jjjd| jd}W 5 Q R X | jj|dS | jdkr| | jS t| jjs|  S | jr|  S |  S )zcompute the resultsr   ignorer   rQ   ra   datar@   )r   rF   r   ry   r   rm   apply_empty_resultrH   rK   rR   rI   rJ   errstater,   _mgrrQ   _constructorr0   apply_broadcastr   shaper/   	apply_rawapply_standard)rM   r   r:   r:   r;   rQ     s"    

zFrameApply.applyc                   s~   | j }| j}|dkrJt|j| j| j| j| j| j	 }|d k	rD|jn|}n
t
 	 }|d krz|j| j|fd| ji| j}|S )Nr2   r4   )r,   r.   r7   rf   rL   r/   r0   r4   r5   r[   superrQ   )rM   r,   r.   ro   	__class__r:   r;   r[     s     
zFrameApply.aggc                 C  s   t | jst| jdkr"| j S | jdk}ddlm} |svz| |g tj	d}W n t
k
rh   Y nX t|| }|rt| jr| |g tj	d}ntj}| jj|| jdS | j S dS )z
        we have an empty result; at least 1 axis is 0

        we will try to apply the function to an empty
        series in order to see if this is a reduction function
        )r?   Nr?   r   r   dtyperm   N)rU   rF   re   r0   r,   r   r   r%   rI   float64rk   rH   ry   r   nan_constructor_sliced)rM   Zshould_reducer%   r   r:   r:   r;   r     s"    



zFrameApply.apply_empty_resultc                 C  sV   dd }t || j| j| j}|jdkr@| jj|| j| j	dS | jj
|| jdS dS )z$apply to the values as a numpy arrayc                   s    fdd}|S )z
            Wrap user supplied function to work around numpy issue.

            see https://github.com/numpy/numpy/issues/8352
            c                    s&    | |}t |tr"tj|td}|S )Nr   )rH   rK   rI   r    object)r4   r5   ro   ra   r:   r;   wrapper  s    

z<FrameApply.apply_raw.<locals>.wrap_function.<locals>.wrapperr:   )r-   r   r:   ra   r;   wrap_function  s    z+FrameApply.apply_raw.<locals>.wrap_functionr   rm   r   r   N)rI   Zapply_along_axisrF   r.   r   rd   r,   r   rm   r   r   r   )rM   r   ro   r:   r:   r;   r     s
    
zFrameApply.apply_rawtargetr1   c           	      C  s   t | jstt|j}|jd }t|jD ]`\}}| || }t	|j
}|dkrbtdn|dkr~|t|kr~td||d d |f< q.| jj||j|jd}|S )Nr   r2   ztoo many dims to broadcastzcannot broadcast resultr   )rU   rF   re   rI   Z
empty_liker   r   r   r   Zasarrayrd   rG   ry   r,   r   rm   )	rM   r   Zresult_valuesZresult_compareir`   resZaresro   r:   r:   r;   r     s$    

  zFrameApply.apply_broadcastc                 C  s   |   \}}| ||S rB   )apply_series_generatorwrap_resultsr   r:   r:   r;   r   $  s    zFrameApply.apply_standardztuple[ResType, Index]c              	   C  s~   t | jst| j}| j}i }tdd H t|D ]8\}}| |||< t|| tr2|| j	dd||< q2W 5 Q R X ||fS )Nzmode.chained_assignmentF)deep)
rU   rF   re   r   r   r
   r   rH   r   r   )rM   Z
series_genr   r   r   r^   r:   r:   r;   r   *  s     z!FrameApply.apply_series_generatorc                 C  sj   ddl m} t|dkr8d|kr8t|d r8| ||S | jj}||krXt|tj	d}n||}||_
|S )Nr   r   )Zdtype_if_empty)r   r%   ry   r   r   r,   r   r!   rI   r   rm   )rM   r   r   r%   Zconstructor_slicedro   r:   r:   r;   r   =  s      zFrameApply.wrap_resultsc                   s6   | j dkr,| j}|j| j }|j|| jdS t  S )Nr   r   )rF   r,   r   r.   r   r   r   rR   )rM   r,   valuer   r:   r;   rR   T  s
    
zFrameApply.apply_str)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rQ   r[   r   r   r   r   r   r   rR   __classcell__r:   r:   r   r;   r+   b  s:   

#%c                      sj   e Zd ZdZddd fddZedd Zedd	d
dZedd	ddZddddddZ	  Z
S )r7   r   r#   r   c                   s   t  |S rB   )r   r   )rM   r   r   r:   r;   r   b  s    zFrameRowApply.apply_broadcastc                   s    fddt t jD S )Nc                 3  s   | ]} j j|d dV  qdS )r2   rw   N)r,   _ixs)r]   r   rP   r:   r;   r   g  s     z1FrameRowApply.series_generator.<locals>.<genexpr>)rangery   r   rP   r:   rP   r;   r   e  s    zFrameRowApply.series_generatorr$   rO   c                 C  s   | j S rB   r   rP   r:   r:   r;   r   i  s    zFrameRowApply.result_indexc                 C  s   | j S rB   r   rP   r:   r:   r;   r   m  s    zFrameRowApply.result_columnsr   r   r   c              
   C  s   | j dkr | j|}||_|S | j dkrVtdd | D rV| j|}||_|S z| jj|d}W nN tk
r } z0dt|kr| j|}||_| W Y S  W 5 d}~X Y nX t	|d t
st|jt| jkr| j|_t|jt|kr||_|S )zreturn the results for the rowsr?   Nc                 s  s   | ]}t |tV  qd S rB   )rH   r   )r]   rD   r:   r:   r;   r   |  s    z6FrameRowApply.wrap_results_for_axis.<locals>.<genexpr>r   z%All arrays must be of the same lengthr   )r0   r,   r   rm   r   r   r   rG   rK   rH   r   ry   r   r   )rM   r   r   r   ro   rp   r:   r:   r;   r   q  s0    
z#FrameRowApply.wrap_results_for_axis)r   r   r   r.   r   r   r   r   r   r   r   r:   r:   r   r;   r7   _  s   
r7   c                      s|   e Zd ZdZddd fddZedd Zedd	d
dZedd	ddZddddddZ	ddddddZ
  ZS )r8   r2   r#   r   c                   s   t  |j}|jS rB   )r   r   rf   )rM   r   ro   r   r:   r;   r     s    z FrameColumnApply.apply_broadcastc                 c  s   | j }t|}t|dkst| jjddd}|j}t|jrh| j}t	t|D ]}|j|ddV  qPn2t
|| jD ]$\}}||_|| ||_|V  qtd S )Nr   rw   )r   r"   ry   re   r,   r   r   r   r   r   ziprm   Z
set_valuesr   )rM   r   ZserZmgrr,   r   Zarrr   r:   r:   r;   r     s    

z!FrameColumnApply.series_generatorr$   rO   c                 C  s   | j S rB   r   rP   r:   r:   r;   r     s    zFrameColumnApply.result_indexc                 C  s   | j S rB   r   rP   r:   r:   r;   r     s    zFrameColumnApply.result_columnsr   r   r   c                 C  sJ   | j dkr| ||}n.t|d ts:| j|}||_n| ||}|S )z"return the results for the columnsrA   r   )r0   infer_to_same_shaperH   r   r,   r   rm   rM   r   r   ro   r:   r:   r;   r     s    
z&FrameColumnApply.wrap_results_for_axisc                 C  s&   | j j|d}|j}||_| }|S )z7infer the results to the same shape as the input objectr   )r,   r   rf   rm   Zinfer_objectsr   r:   r:   r;   r     s
    z$FrameColumnApply.infer_to_same_shape)r   r   r   r.   r   r   r   r   r   r   r   r   r:   r:   r   r;   r8     s   
r8   c                      sj   e Zd ZU ded< dZdddd fddZd	d
ddZ fddZdd
ddZd	d
ddZ	  Z
S )SeriesApplyr%   r,   r   r   r)   )r,   r-   convert_dtypec                   s"   || _ t j||dd ||d d S NFr3   )r   r   rN   )rM   r,   r-   r   r4   r5   r   r:   r;   rN     s    zSeriesApply.__init__r   rO   c                 C  sH   | j }t|dkr|  S t| jr,|  S t| jtr@|  S | 	 S )Nr   )
r,   ry   r   r   rF   r   rH   rK   rR   r   rM   r,   r:   r:   r;   rQ     s    
zSeriesApply.applyc              
     s   t   }|d kr| j}| j}| j}t|s0t|dd  z| jj	|f||}W n, t
ttfk
r   || jf||}Y nX |S )N_level)r   r[   rF   r4   r5   rU   re   popr,   rQ   rG   r   rj   )rM   ro   rF   r4   r5   r   r:   r;   r[     s    

zSeriesApply.aggc                 C  s"   | j }|j|j|jdj|ddS )N)r   rm   rQ   method)r,   r   r   rm   __finalize__r   r:   r:   r;   r   +  s
     zSeriesApply.apply_empty_resultc              
   C  s   | j }| j}tjddh t|tjr:||W  5 Q R  S t|jr^t|j	dr^|j	
|}n|tj	}tj||| jd}W 5 Q R X t|rt|d tr|jt||jdS |j||jdj|ddS d S )	Nr   r   map)convertr   r   rQ   r   )rF   r,   rI   r   rH   rJ   r   r   r   Z_valuesr   Zastyper   r   Z	map_inferr   ry   r   Z_constructor_expanddimpd_arrayrm   r   r   )rM   rF   r,   Zmappedr   r:   r:   r;   r   1  s&     zSeriesApply.apply_standard)r   r   r   r   r.   rN   rQ   r[   r   r   r   r:   r:   r   r;   r     s   
r   c                      s4   e Zd Zddd fddZdd Zdd	 Z  ZS )
GroupByApplyzGroupBy[FrameOrSeries]r   r,   r-   c                   s:   |  }|j|dd| _t j||dd ||d d S )Nr.   r   Fr3   )r   r,   r6   getr.   r   rN   rM   r,   r-   r4   r5   r   r:   r;   rN   U  s    zGroupByApply.__init__c                 C  s   t d S rB   NotImplementedErrorrP   r:   r:   r;   rQ   g  s    zGroupByApply.applyc                 C  s   t d S rB   r  rP   r:   r:   r;   rg   j  s    zGroupByApply.transform)r   r   r   rN   rQ   rg   r   r:   r:   r   r;   r   T  s   r   c                      sB   e Zd ZU dZded< ddd fddZdd	 Zd
d Z  ZS )ResamplerWindowApplyr   zResampler | BaseWindowr,   r   r  c                   s   t  j||dd ||d d S r   )r   rN   r  r   r:   r;   rN   r  s    zResamplerWindowApply.__init__c                 C  s   t d S rB   r  rP   r:   r:   r;   rQ     s    zResamplerWindowApply.applyc                 C  s   t d S rB   r  rP   r:   r:   r;   rg     s    zResamplerWindowApply.transform)	r   r   r   r.   r   rN   rQ   rg   r   r:   r:   r   r;   r  n  s
   
r  )r   FNNN)M
__future__r   r   r   typingr   r   r   r   r   r   r	   r~   ZnumpyrI   Zpandas._configr
   Zpandas._libsr   Zpandas._typingr   r   r   r   r   r   r   Zpandas.util._decoratorsr   Zpandas.core.dtypes.castr   Zpandas.core.dtypes.commonr   r   r   r   Zpandas.core.dtypes.genericr   r   r   Zpandas.core.algorithmsr   Zpandas.core.baser   r   r   Zpandas.core.commoncorecommonrV   Zpandas.core.constructionr    r   r!   r"   r   r#   r$   r%   Zpandas.core.groupbyr&   Zpandas.core.resampler'   Zpandas.core.window.rollingr(   r>   r   r<   ABCMetar=   r   r+   r7   r8   r   r   r  r:   r:   r:   r;   <module>   sP   $	$	        t ~<Lm