a
    é´«j!!  ã                   @   sl   d Z ddlZddlZddlmZmZ ddlmZmZm	Z	 ddl
mZmZ dd„ Zdd	„ Zd
d„ Zdd„ ZdS )zð
Tests of the groupby API, including internal consistency and with other pandas objects.

Tests in this file should only check the existence, names, and arguments of groupby
methods. It should not test the results of any groupby operation.
é    N)Ú	DataFrameÚSeries)Úgroupby_other_methodsÚreduction_kernelsÚtransformation_kernels)ÚDataFrameGroupByÚSeriesGroupByc                 C   s6   | j dd�}dd„ t|ƒD ƒ}h d£}||ks2J ‚d S )NÚsecond)Úlevelc                 S   s   h | ]}|  d ¡s|’qS ©Ú_©Ú
startswith)Ú.0Úv© r   ú\/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/pandas/tests/groupby/test_api.pyÚ	<setcomp>   ó    z&test_tab_completion.<locals>.<setcomp>>B   ÚAÚgroupsZ	get_groupÚcountÚnuniqueZ	expandingZ	aggregateÚlastZ	transformZboxplotZdtypesÚcumminÚidxmaxÚallÚffillÚindicesÚfilterZrollingÚcumsumÚ
pct_changeÚcummaxÚsemÚpipeÚquantileÚndimÚtailZfillnaÚidxminÚhistZewmÚminZohlcÚmedianZvalue_countsÚrankZnthÚcumcountZtakeÚbfillZaggÚBÚanyÚprodÚdiffÚheadÚshiftÚCZdescribeÚsizeÚfirstÚmaxÚcorrwithÚngroupZngroupsZresampleÚmeanÚstdÚcumprodÚapplyZskewZcorrÚsumÚsampleZcovÚvarZplot)ÚgroupbyÚdir)Ú multiindex_dataframe_random_dataÚgrpÚresultsÚexpectedr   r   r   Útest_tab_completion   s    DrH   c                 C   sÀ   |   | jd d …df ¡}dd„ t|ƒD ƒt| jƒ }t|ƒ}|t8 }|t8 }|t8 }tt@ r`J ‚tt@ rlJ ‚tt@ rxJ ‚|r�d|› d�}t|ƒ‚ttB tB }||kr¼d|| › d�}t|ƒ‚d S )Nr   c                 S   s   h | ]}|  d ¡s|’qS r   r   )r   r   r   r   r   r   i   r   z/test_all_methods_categorized.<locals>.<setcomp>z?
There are uncategorized methods defined on the Grouper class:
aG  .

Was a new method recently added?

Every public method On Grouper must appear in exactly one the
following three lists defined in pandas.core.groupby.base:
- `reduction_kernels`
- `transformation_kernels`
- `groupby_other_methods`
see the comments in pandas/core/groupby/base.py for guidance on
how to fix this test.
        zI
Some methods which are supposed to be on the Grouper class
are missing:
z‡.

They're still defined in one of the lists that live in pandas/core/groupby/base.py.
If you removed a method, you should update them
)	rB   ZilocrC   ÚsetÚcolumnsr   r   r   ÚAssertionError)rD   rE   ÚnamesZ	new_namesÚmsgZall_categorizedr   r   r   Útest_all_methods_categorizede   s0    ÿÿþýrN   c                 C   sÂ  | dv rd}t j|d� | dv r2tt| ƒr.J ‚d S tt| ƒ}tt| ƒ}tt |¡j	ƒ}| dkrfdh}ntt |¡j	ƒ}tƒ tƒ  }}| dv r–h d£}næ| d	v r¨d
dh}nÔ| dv r¸dh}nÄ| dv rÒh d£}h d£}nª| dv rìh d£}ddh}n�| dv �r h d£}n|| dv �rh d£}nh| dv �r.ddh}d
h}nN| dv �r@dh}n<| dv �rXdh}dh}n$| dv �rjd
h}n| dv �r|ddh}||@ |k�sŽJ ‚||@ |k�s J ‚||8 }||8 }||k�s¾J ‚d S )N©r7   r   z?first and last are entirely different between frame and groupby)Úreason)r-   r:   r6   Úself©r0   r   >   ÚaxisÚkwargsÚ	bool_only)r   Únumeric_onlyrS   )r   ©r8   r*   >   rT   ÚskipnarS   ¾   ÚengineZ	min_countÚengine_kwargs©r;   r<   r?   rA   rZ   r[   ©r+   r1   r#   ©Zbackfillr.   r   Úpad¾   ZinplaceZdowncastrS   Z
limit_area©r"   r   rX   Úargs©r=   r    ©r!   rT   ©r,   ©r%   Úmethod)
ÚpytestÚskipÚhasattrr   Úgetattrr   rI   ÚinspectÚ	signatureÚ
parameters)Úgroupby_funcrM   Zframe_methodÚ	gb_methodÚresultrG   Úexclude_expectedÚexclude_resultr   r   r   Útest_frame_consistency•   s\    














rt   c                 C   s¸  |dv rt  d¡ |dv r,tt|ƒr(J ‚d S tt|ƒ}tt|ƒ}tt |¡j	ƒ}|dkr`dh}ntt |¡j	ƒ}tƒ tƒ  }}|dv r�h d£}nâ|dv r d	h}nÒ|d
v rºh d£}h d£}n¸|dv rÔh d£}ddh}nž|dv ræh d£}nŒ|dv røh d£}nz|dv �rddh}dh}n`|dv �r$dh}nN|dv �r<dh}d	h}n6|dv �rNdh}n$|dv �rbddh}n|dv �rrdh}||@ |k�s„J ‚||@ |k�s–J ‚||8 }||8 }||k�s´J ‚d S )NrO   z@first and last are entirely different between Series and groupby)r-   r9   r:   r6   rQ   rR   >   rS   rT   rU   )r2   rS   rW   >   rT   rX   rS   rY   r\   rZ   r[   r]   r^   r`   ra   rX   rb   rV   rc   rd   rT   re   )r(   r   rf   )
rh   ri   rj   r   rk   r   rI   rl   rm   rn   )Úrequestro   Zseries_methodrp   rq   rG   rr   rs   r   r   r   Útest_series_consistencyÑ   sZ    














rv   )Ú__doc__rl   rh   Zpandasr   r   Zpandas.core.groupby.baser   r   r   Zpandas.core.groupby.genericr   r   rH   rN   rt   rv   r   r   r   r   Ú<module>   s   J0<