o
    d                     @   sH   d Z ddlZddlZddlmZmZ ddlmZmZ dd Z	dd Z
dS )	zY
Test the consistency of the groupby API, both internally and with other pandas objects.
    N)	DataFrameSeries)DataFrameGroupBySeriesGroupByc           	      C   s  |dv rd}| j tjj|d |dv r"d}| j tjj|d |dkr/tt|r-J d S tt|}tt|}t	t
|j}|dkrIdh}nt	t
|j}t	 t	 }}|d	v rah d
}nl|dv rjddh}nc|dv rrdh}n[|dv rh d}h d}nN|dv rh d}ddh}nA|dv rh d}n8|dv rh d}n/|dv rddh}dh}n#|dv rdh}n|dv rdh}dh}n|dv rdh}n|dv rd dh}||@ |ksJ ||@ |ksJ ||8 }||8 }||ksJ d S )!Nfirstlastz?first and last are entirely different between frame and groupbyreason)cumcountzDataFrame has no such methodngroupsizeselfanyall>   kwargs	bool_onlyaxis)countnumeric_onlyr   )Znuniquemaxmin>   skipnar   r      Z	min_countengine_kwargsenginemeanZstdsumvarr   r   ZmedianprodZsemZbackfillZbfillZffillpad   Zdowncastr   ZinplaceZcummaxZcumminr   argsZcumprodZcumsumZ
pct_changer   ZrankZquantilemethod)node
add_markerpytestmarkxfailhasattrr   getattrr   setinspect	signature
parameters)	requestgroupby_funcmsgZframe_method	gb_methodresultexpectedexclude_expectedexclude_result rA   ]/app/.heroku/python/lib/python3.10/site-packages/pandas/tests/groupby/test_api_consistency.pytest_frame_consistency   sb   







rC   c           	      C   s  |dv rd}| j tjj|d |dv r"d}| j tjj|d |dkr/tt|r-J d S tt|}tt|}t	t
|j}|dkrIdh}nt	t
|j}t	 t	 }}|d	v rah d
}nk|dv ridh}nc|dv rvh d}h d}nV|dv rh d}ddh}nI|dv rh d}n@|dv rh d}n7|dv rddh}dh}n+|dv rdh}n#|dv rdh}dh}n|dv rdh}n|dv rddh}n|dv rdh}||@ |ksJ ||@ |ksJ ||8 }||8 }||ksJ d S ) Nr   z@first and last are entirely different between Series and groupbyr	   )r   ZcorrwithzSeries has no such methodr   r   r   r   >   r   r   r   )diffr   r   >   r   r   r   r   r   r   r   r"   r$   r&   r'   r   r(   r   r)   r*   r   r+   )ZidxminZidxmaxr,   )r.   r/   r0   r1   r2   r3   r   r4   r   r5   r6   r7   r8   )	r9   r:   r;   Zseries_methodr<   r=   r>   r?   r@   rA   rA   rB   test_series_consistencyR   sb   







rE   )__doc__r6   r0   Zpandasr   r   Zpandas.core.groupby.genericr   r   rC   rE   rA   rA   rA   rB   <module>   s    ?