o
    Û­jK(  ã                   @   sV   d dl Z d dlZd dlZd dlZd dlZd dlmZmZ d dl	m
Z G dd„ dƒZdS )é    N)Ú	DataFrameÚSeriesc                   @   s–   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zej dddg¡d d!„ ƒZd"S )#ÚTestDataFrameMissingDatac                 C   s  t |jƒ}tj d¡ |¡}tj|d d…< td|i|jd�}t||jdd�}| 	¡ }| 
¡ | 
¡ }}|j	dd�}	t |d |¡ |j	ddd	�}
t |	d |¡ t |d |¡ |
d u s^J ‚|j	ddgd
�}	|j	ddgdd�}
t |	d |¡ t |d |¡ |
d u s…J ‚d S )Né   é   Úfoo©Úindex©r	   ÚnameÚall©ÚhowT)r   Úinplace)r   Úsubset)r   r   r   )Úlenr	   ÚnpÚrandomÚdefault_rngÚstandard_normalÚnanr   r   ÚdropnaÚcopyÚtmÚassert_series_equal)ÚselfÚfloat_frameÚNÚmatÚframeÚoriginalÚexpectedÚinplace_frame1Úinplace_frame2Úsmaller_frameÚreturn_value© r&   úc/var/www/html/CropPilot/venv/lib/python3.10/site-packages/pandas/tests/frame/methods/test_dropna.pyÚtest_dropEmptyRows   s$   
z+TestDataFrameMissingData.test_dropEmptyRowsc                 C   sH  t |jƒ}tj d¡ |¡}tj|d d…< td|i|jd�}d|d< t||jdd�}| 	¡ | 	¡ }}| 
¡ }t |d |¡ |j
dd�}	t|dd … |jdd … dd�}
t |d |
¡ t |d |
¡ |	d u skJ ‚|j
dgd	�}t |d |¡ |d dk ¡ s„J ‚|j
dgdd
�}	t |j|j¡ t |j|j¡ |	d u s¢J ‚d S )Nr   r   r   r   Úbarr
   T©r   ©r   )r   r   )r   r	   r   r   r   r   r   r   r   r   r   r   r   r   Úassert_index_equal)r   r   r   r   r   r    Ú
inp_frame1Ú
inp_frame2r$   r%   ÚexpÚsamesize_framer&   r&   r'   Útest_dropIncompleteRows(   s*   
 z0TestDataFrameMissingData.test_dropIncompleteRowsc                 C   s¼  t tj d¡ d¡ƒ}tj|jd d…df< |jdd�}|jd d …g d¢f }| 	¡ }|jddd�}t
 ||¡ t
 ||¡ |d u sCJ ‚|jdd�}|jttdd	ƒƒ }| 	¡ }|jddd�}t
 ||¡ t
 ||¡ |d u spJ ‚|jdd
d�}|jd d …g d¢f }| 	¡ }|jdd
dd�}t
 ||¡ t
 ||¡ |d u s J ‚|jddd�}|jtdd	ƒ }| 	¡ }|jdddd�}t
 ||¡ t
 ||¡ |d u sÍJ ‚|jddd�}t
 ||¡ |jddd�}t
 ||¡ |jdg d¢d�}| 	¡ }|jdg d¢dd�}t
 ||¡ t
 ||¡ |d u �sJ ‚|jddd�}t
 ||¡ tj|d< |jddd�}|jd d …g d¢f }t
 ||¡ d}tjt|d�� |jdd� W d   ƒ d S 1 �sWw   Y  d S )Nr   )é   é   é   ©Úaxis)r   r4   é   T)r6   r   r   r2   r   )r6   Úthresh)r6   r8   r   r3   r7   )r6   r   )r6   r   r   r   )r6   r   z)No axis named 3 for object type DataFrame©Úmatch)r   r   r   r   r   r   Úilocr   Úlocr   r   Úassert_frame_equalÚlistÚrangeÚpytestÚraisesÚ
ValueError)r   ÚdfÚdroppedr!   Úinpr%   Úmsgr&   r&   r'   Útest_dropnaC   sd   
$ÿz$TestDataFrameMissingData.test_dropnac                 C   s  t ddtjgdd�}t ddg|jdd�}td|j ¡ iƒ}| ¡ }|d  ¡  t 	|d |¡ |d }|jdd�}t 	||¡ t 	|d |¡ |d u sMJ ‚|d  
dg¡ t 	|d |¡ |d }|j
dgdd�}t 	|| 
dg¡¡ t 	|d |¡ |d u s�J ‚d S )Nr4   r   ÚA)r   )Údtyper   Tr*   )r   r   r   rI   r   Úvaluesr   r   r   r   Údrop)r   r    r!   rC   Údf2Úserr%   r&   r&   r'   Útest_drop_and_dropna_caching„   s$   z5TestDataFrameMissingData.test_drop_and_dropna_cachingc                 C   s‚   d}t jt|d�� |jdd� W d   ƒ n1 sw   Y  t jtdd�� |jddgd� W d   ƒ d S 1 s:w   Y  d S )	Nzinvalid how option: foor9   r   r   z	^\['X'\]$rH   ÚXr+   )r@   rA   rB   r   ÚKeyError)r   r   rF   r&   r&   r'   Útest_dropna_cornerœ   s   ÿ"ÿz+TestDataFrameMissingData.test_dropna_cornerc                 C   s  t dtjddgdtjddgtjtjtjtjgdtjdd	ggƒ}tjtd
d�� |jdddgd� W d   ƒ n1 s:w   Y  tjtd
d�� |jddd� W d   ƒ n1 sXw   Y  | ¡ }tjtd
d�� |jdddd� W d   ƒ d S 1 s|w   Y  d S )Nr4   r   r7   r3   r   r2   é   é   é	   zsupplying multiple axesr9   r   r   )r   r6   )r   r4   T)r   r6   r   )r   r   r   r@   rA   Ú	TypeErrorr   r   )r   rC   rE   r&   r&   r'   Útest_dropna_multiple_axes¥   s"   üÿ
ÿÿ"ÿz2TestDataFrameMissingData.test_dropna_multiple_axesc                 C   s°   t ƒ }tjdddtj ¡ d�}tjdddtj ¡ d�}|g|d< |jdd�}t d|giƒ}t ||¡ t d|d tj	|giƒ}|jdd�}t ||gdgddgd	�}t ||¡ d S )
Niß  r4   )Útzinfor   ÚTimer   r5   r7   )Úcolumnsr	   )
r   ÚdatetimeÚdateutilÚtzÚtzutcr   r   r=   r   r   )r   rC   Údt1Údt2Úresultr!   r&   r&   r'   Útest_dropna_tz_aware_datetime¹   s   
z6TestDataFrameMissingData.test_dropna_tz_aware_datetimec                 C   sJ   t j g d¢¡}t  |¡}tdtdƒi|d�}|}| ¡ }t ||¡ d S )N)r   g=
×£p=@g…ëQ¸	@g…ëQ¸@rH   Úabcr   )	ÚpdÚIntervalIndexÚfrom_breaksÚCategoricalIndexr   r>   r   r   r=   )r   ÚiiÚcirC   r!   r`   r&   r&   r'   Ú&test_dropna_categorical_interval_indexÉ   s   
z?TestDataFrameMissingData.test_dropna_categorical_interval_indexc                 C   sÈ   t tj d¡ d¡tj d¡ d¡tj d¡ d¡g d¢dœƒ}tj|jdg d¢f< tj|jd< tj|jd< tj|jd d …df< |jg d	¢d
d�}g d¢|_g d¢|_|jddgd
d�}t	 
||¡ d S )Nr   r   )ÚaÚbÚcÚdÚe)rH   ÚBÚCÚD)r   r4   r   )r   r   )r4   r4   r7   ©rH   ro   rp   r   )r   r   )rH   rH   ro   rp   rH   rp   )r   r   r   r   r   r   r;   r   rY   r   r=   ©r   rC   r!   r`   r&   r&   r'   Ú"test_dropna_with_duplicate_columnsÓ   s    üÿ

z;TestDataFrameMissingData.test_dropna_with_duplicate_columnsc                 C   s`   t g d¢tdƒdtjdgdœƒ}t ddgtdƒd	d
gdœddgd�}|jdd�}t ||¡ d S )N©r4   r   r7   rb   r3   r   rr   r4   r7   Úacç      @g      @r   r   r   rp   r+   )r   r>   r   r   r   r   r=   rs   r&   r&   r'   Útest_set_single_column_subsetè   s    ÿz6TestDataFrameMissingData.test_set_single_column_subsetc                 C   sR   t dg d¢iƒ}tjtdd�� |jddd� W d   ƒ d S 1 s"w   Y  d S )NrH   ru   z['D']r9   rq   r   )r   r6   )r   r@   rA   rP   r   )r   rC   r&   r&   r'   Ú&test_single_column_not_present_in_axisñ   s   "ÿz?TestDataFrameMissingData.test_single_column_not_present_in_axisc                 C   s`   t ddtjgtdƒdtjdgdœƒ}t dgdgd	gdœƒ}|jt d
dg¡d�}t ||¡ d S )Nr4   r   rb   r3   r   rr   g      ð?rj   rw   rH   rp   r+   )r   r   r   r>   r   Úarrayr   r=   rs   r&   r&   r'   Útest_subset_is_nparrayù   s   $z/TestDataFrameMissingData.test_subset_is_nparrayc                 C   sH   t ddgddggt dd¡d�}| ¡ }|j|d�}tj||dd	� d S )
Nr4   r   r7   r3   r   )rY   r5   T)Úcheck_index_type)r   rc   Ú
RangeIndexr   r   r   r=   )r   r6   rC   r!   r`   r&   r&   r'   Útest_no_nans_in_frame   s    z.TestDataFrameMissingData.test_no_nans_in_framec                 C   sÎ   t ddtjgƒ}d}tjt|d�� |jddd� W d   ƒ n1 s#w   Y  tjt|d�� |jddd� W d   ƒ n1 sAw   Y  tjt|d�� |jd d d� W d   ƒ d S 1 s`w   Y  d S )Nr4   r   zAYou cannot set both the how and thresh arguments at the same timer9   r   )r   r8   Úany)r   rc   ÚNAr@   rA   rU   r   )r   rC   rF   r&   r&   r'   Ú"test_how_thresh_param_incompatible  s   ÿÿ"ÿz;TestDataFrameMissingData.test_how_thresh_param_incompatibleÚvalr4   g      ø?c                 C   sb   t ddd|gig d¢d�}|jdd�}t ddd|giƒ}t ||¡ |jddd� t ||¡ d S )	Nrj   r4   r   )r7   r   r4   r   T)Úignore_index)rƒ   r   )r   r   r   r=   )r   r‚   rC   r`   r!   r&   r&   r'   Útest_dropna_ignore_index  s   z1TestDataFrameMissingData.test_dropna_ignore_indexN)Ú__name__Ú
__module__Ú__qualname__r(   r1   rG   rN   rQ   rV   ra   ri   rt   rx   ry   r{   r~   r�   r@   ÚmarkÚparametrizer„   r&   r&   r&   r'   r      s"    A	
	r   )rZ   r[   Únumpyr   r@   Úpandasrc   r   r   Úpandas._testingÚ_testingr   r   r&   r&   r&   r'   Ú<module>   s    