U
    -e                     @   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kr"d}| j tjj|d |dkrDd}| j tjj|d |dkr^tt|rZtd S tt|}tt	|}t
t|j}|dkrdh}nt
t|j}t
 t
  }}|d	krd
ddh}n|dkrddh}n|dkrdh}n|dkrdd
dh}dddh}n|dkr$dd
dh}ddh}n|dkr:dd
dh}n~|dkrPdddh}nh|dkrjddh}dh}nN|dkr|dh}n<|dkrd
h}dh}n$|dkrdh}n|dkrd dh}||@ |kst||@ |kst||8 }||8 }||kst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_only)Znuniquemaxminskipna	min_countengineengine_kwargsZmeanZstdsumvarZmedianprodZsemZbackfillZbfillZffillpaddowncastinplaceZcummaxZcumminargsZcumprodZcumsumZ
pct_changeZrankZquantilemethod)node
add_markerpytestmarkxfailhasattrr   AssertionErrorgetattrr   setinspect	signature
parameters)	requestgroupby_funcmsgZframe_method	gb_methodresultexpectedexclude_expectedexclude_result rB   j/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/pandas/tests/groupby/test_api_consistency.pytest_frame_consistency   sb    














rD   c           	      C   s  |dkr"d}| j tjj|d |dkrDd}| j tjj|d |dkr^tt|rZtd S tt|}tt	|}t
t|j}|dkrdh}nt
t|j}t
 t
  }}|d	krd
ddh}n|dkrdh}n|dkrdd
dh}dddh}n|dkrdd
dh}ddh}n|dkr&dd
dh}n|dkr<dddh}nz|dkrVddh}dh}n`|dkrhdh}nN|dkrd
h}dh}n6|dkrdh}n$|dkrdd
h}n|dkrdh}||@ |kst||@ |kst||8 }||8 }||kst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+   )ZidxminZidxmaxr,   )r.   r/   r0   r1   r2   r3   r   r4   r5   r   r6   r7   r8   r9   )	r:   r;   r<   Zseries_methodr=   r>   r?   r@   rA   rB   rB   rC   test_series_consistencyR   sb    














rF   )__doc__r7   r0   Zpandasr   r   Zpandas.core.groupby.genericr   r   rD   rF   rB   rB   rB   rC   <module>   s   ?