a
    é´«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ÚexpectedZinplace_frame1Zinplace_frame2Úsmaller_frameÚreturn_value© r$   úe/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/pandas/tests/frame/methods/test_dropna.pyÚtest_dropEmptyRows   s$    
z+TestDataFrameMissingData.test_dropEmptyRowsc                 C   sL  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 sÖJ ‚|j
dgd	�}t |d |¡ |d dk ¡ �s
J ‚|j
dgdd
�}	t |j|j¡ t |j|j¡ |	d u �sHJ ‚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   Zassert_index_equal)r   r   r   r   r   r    Z
inp_frame1Z
inp_frame2r"   r#   ÚexpZ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 s†J ‚|jdd�}|jttdd	ƒƒ }| 	¡ }|jddd�}t
 ||¡ t
 ||¡ |d u sàJ ‚|jdd
d�}|jd d …g d¢f }| 	¡ }|jdd
dd�}t
 ||¡ t
 ||¡ |d u �sBJ ‚|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   ƒ n1 �s°0    Y  d S )Nr   )é   é   é   ©Úaxis)r   r.   é   T)r0   r   r   r,   r   )r0   Úthresh)r0   r2   r   r-   r1   )r0   r   )r0   r   r   r   )r0   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   ÚdfZdroppedr!   Úinpr#   Úmsgr$   r$   r%   Útest_dropnaC   sb    
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 sšJ ‚|d  
dg¡ t 	|d |¡ |d }|j
dgdd�}t 	|| 
dg¡¡ t 	|d |¡ |d u �sJ ‚d S )Nr.   r   ÚA)r   )Údtyper   Tr(   )r   r   r   rB   r   Úvaluesr   r   r   r   Zdrop)r   r    r!   r=   Zdf2Z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 s40    Y  t jtdd��  |jddgd� W d   ƒ n1 sr0    Y  d S )	Nzinvalid how option: foor3   r   r   z	^\['X'\]$rA   ÚXr)   )r:   r;   r<   r   ÚKeyError)r   r   r?   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 st0    Y  tjtd
d�� |jddd� W d   ƒ n1 s°0    Y  | ¡ }tjtd
d��  |jdddd� W d   ƒ n1 sö0    Y  d S )Nr.   r   r1   r-   r   r,   é   é   é	   zsupplying multiple axesr3   r   r   )r   r0   )r   r.   T)r   r0   r   )r   r   r   r:   r;   Ú	TypeErrorr   r   )r   r=   r>   r$   r$   r%   Útest_dropna_multiple_axes¥   s    üÿ
0,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ß  r.   )Útzinfor   ZTimer   r/   r1   )Úcolumnsr	   )
r   ÚdatetimeÚdateutilÚtzZtzutcr   r   r7   r   r   )r   r=   Zdt1Z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¸@rA   Úabcr   )	ÚpdZIntervalIndexZfrom_breaksZCategoricalIndexr   r8   r   r   r7   )r   ÚiiÚcir=   r!   rR   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)rA   ÚBÚCÚD)r   r.   r   )r   r   )r.   r.   r1   ©rA   r^   r_   r   )r   r   )rA   rA   r^   r_   rA   r_   )r   r   r   r   r   r   r5   r   rN   r   r7   ©r   r=   r!   rR   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©r.   r   r1   rT   r-   r   ra   r.   r1   Úacç      @g      @r   r   r   r_   r)   )r   r8   r   r   r   r   r7   rb   r$   r$   r%   Útest_set_single_column_subsetè   s     ÿz6TestDataFrameMissingData.test_set_single_column_subsetc                 C   sP   t dg d¢iƒ}tjtdd�� |jddd� W d   ƒ n1 sB0    Y  d S )NrA   rd   z['D']r3   r`   r   )r   r0   )r   r:   r;   rF   r   )r   r=   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 )Nr.   r   rT   r-   r   ra   g      ð?rY   rf   rA   r_   r)   )r   r   r   r8   r   Úarrayr   r7   rb   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 )
Nr.   r   r1   r-   r   )rN   r/   T)Zcheck_index_type)r   rU   Z
RangeIndexr   r   r   r7   )r   r0   r=   r!   rR   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 sF0    Y  tjt|d�� |jddd� W d   ƒ n1 s‚0    Y  tjt|d�� |jd d d� W d   ƒ n1 s¾0    Y  d S )Nr.   r   zAYou cannot set both the how and thresh arguments at the same timer3   r   )r   r2   Úany)r   rU   ZNAr:   r;   rK   r   )r   r=   r?   r$   r$   r%   Ú"test_how_thresh_param_incompatible  s    ,,z;TestDataFrameMissingData.test_how_thresh_param_incompatibleÚvalr.   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 )	NrY   r.   r   )r1   r   r.   r   T)Úignore_index)ro   r   )r   r   r   r7   )r   rn   r=   rR   r!   r$   r$   r%   Útest_dropna_ignore_index  s    z1TestDataFrameMissingData.test_dropna_ignore_indexN)Ú__name__Ú
__module__Ú__qualname__r&   r+   r@   rD   rG   rL   rS   rX   rc   rg   rh   rj   rk   rm   r:   ÚmarkZparametrizerp   r$   r$   r$   r%   r      s    A	
	r   )rO   rP   Únumpyr   r:   ZpandasrU   r   r   Zpandas._testingZ_testingr   r   r$   r$   r$   r%   Ú<module>   s   