U
    `»{jˆ(  ã                   @   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dd„ ZdS ) ÚTestDataFrameMissingDatac                 C   s
  t |jƒ}tj |¡}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 ks¶t‚|jddgd	�}	|jddgdd
�}
t
 |	d |¡ t
 |d |¡ |
d k�st‚d S )Né   Úfoo©Úindex©r   ÚnameÚall©ÚhowT)r   Úinplace)r   Úsubset)r   r   r   )Úlenr   ÚnpÚrandomÚrandnÚnanr   r   ÚdropnaÚcopyÚtmÚassert_series_equalÚAssertionError)ÚselfÚfloat_frameÚNÚmatÚframeÚoriginalÚexpectedZinplace_frame1Zinplace_frame2Úsmaller_frameÚreturn_value© r#   úe/var/www/html/bwave/python/venv/lib/python3.8/site-packages/pandas/tests/frame/methods/test_dropna.pyÚtest_dropEmptyRows   s$    
z+TestDataFrameMissingData.test_dropEmptyRowsc                 C   sF  t |jƒ}tj |¡}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 ksÐt‚|j	dgd�}t
 |d |¡ |d dk ¡ �st‚|j	dgdd	�}	t
 |j|j¡ t
 |j|j¡ |	d k�sBt‚d S )
Nr   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 …dddgf }| ¡ }|jddd	�}t	 
||¡ t	 
||¡ |d ks„t‚|jdd�}|jttddƒƒ }| ¡ }|jddd	�}t	 
||¡ t	 
||¡ |d ksÞt‚|jdd
d�}|jd d …dddgf }| ¡ }|jdd
dd�}t	 
||¡ t	 
||¡ |d k�sBt‚|jddd�}|jtddƒ }| ¡ }|jdddd�}t	 
||¡ t	 
||¡ |d k�sžt‚|jddd�}t	 
||¡ |jddd�}t	 
||¡ |jddddgd�}| ¡ }|jddddgdd�}t	 
||¡ t	 
||¡ |d k�s*t‚|jddd�}t	 
||¡ tj|d< |jddd�}|jd d …dddgf }t	 
||¡ d}tjt|d�� |jdd� W 5 Q R X d S )Né   é   é   é   ©Úaxisr   é   T)r0   r   r   )r0   Úthresh)r0   r2   r   )r0   r   )r0   r   r   r   )r0   r   z)No axis named 3 for object type DataFrame©Úmatch)r   r   r   r   r   Úilocr   Úlocr   r   Úassert_frame_equalr   Ú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 ksšt
‚|d  dg¡ t 	|d |¡ |d }|jdgdd�}t 	|| dg¡¡ t 	|d |¡ |d k�st
‚d S )Nr.   r-   ÚA)r
   )Údtyper
   Tr'   )r   r   r   rB   r   Úvaluesr   r   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   sX   d}t jt|d�� |jdd� W 5 Q R X t jtdd�� |jddgd� W 5 Q R X 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 5 Q R X tjtd
d�� |jddd� W 5 Q R X | ¡ }tjtd
d�� |jdddd� W 5 Q R X 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    üÿ
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   sN   t j ddddg¡}t  |¡}tdtdƒi|d�}|}| ¡ }t ||¡ d S )Nr   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¡tj d¡tj d¡dddddgdœƒ}tj|jdd	d
dgf< tj|jd< tj|jd< d}tjt|d�� tj|jd d …df< W 5 Q R X |j	dddgdd�}ddddg|_
ddddg|_
|j	ddgdd�}t ||¡ d S )Nr   ÚaÚbÚcÚdÚe)rA   ÚBÚCÚDr-   r   r.   )r   r   )r.   r.   z.will attempt to set the values inplace insteadr3   r1   rA   r^   r_   r   )r   r   )r   r   r   r   r   r5   r   Úassert_produces_warningÚFutureWarningr   rN   r7   )r   r=   r?   r    rR   r#   r#   r$   Ú"test_dropna_with_duplicate_columnsÓ   s$    


üÿz;TestDataFrameMissingData.test_dropna_with_duplicate_columnsc              	   C   s\   t ddddgiƒ}d}tjt|d�� | d¡}W 5 Q R X t ddddgiƒ}t ||¡ d S )NrY   r.   r-   r1   zUIn a future version of pandas all arguments of DataFrame\.dropna will be keyword-onlyr3   )r   r   ra   rb   r   r7   )r   r=   r?   rR   r    r#   r#   r$   Ú test_dropna_pos_args_deprecationê   s    ÿz9TestDataFrameMissingData.test_dropna_pos_args_deprecationc                 C   sb   t dddg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 )Nr.   r-   r1   rT   r,   r   ©rA   r^   r_   Úacç      @g      @r   r   r_   r(   )r   r8   r   ÚNaNr   r   r7   ©r   r=   r    rR   r#   r#   r$   Útest_set_single_column_subsetö   s    " ÿz6TestDataFrameMissingData.test_set_single_column_subsetc              	   C   s>   t ddddgiƒ}tjtdd�� |jddd	� W 5 Q R X d S )
NrA   r.   r-   r1   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   re   g      ð?rY   rg   rA   r_   r(   )r   r   rh   r8   r   Úarrayr   r7   ri   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 5 Q R X tjt|d�� |jddd� W 5 Q R X tjt|d�� |jd d d� W 5 Q R X 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_incompatibleN)Ú__name__Ú
__module__Ú__qualname__r%   r*   r@   rD   rG   rL   rS   rX   rc   rd   rj   rk   rm   rn   rp   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   