U
    f/e"                     @   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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st|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#   J/tmp/pip-unpacked-wheel-tiezk1ph/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st|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|d d d< |jdd}|jd d dddgf }| }|jddd	}t	|| t	|| |d kst
|jdd}|jttdd }| }|jddd	}t	|| t	|| |d kst
|jdd
d}|jd d dddgf }| }|jdd
dd}t	|| t	|| |d ks@t
|jddd}|jtdd }| }|jdddd}t	|| t	|| |d kst
|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   r   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st
|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   rA   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   s   d}t jt|d |jdd W 5 Q R X 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must specify how or threshz	^\['X'\]$r@   Xr(   )r9   r:   r;   r   	TypeError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   r9   r:   rE   r   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   r6   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@r@   abcr   )	pdZIntervalIndexZfrom_breaksZCategoricalIndexr   r7   r   r   r6   )r   iicir<   r    rQ   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< tj|jd d df< |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)r@   BCDr-   r   r.   )r   r   )r.   r.   r1   r@   r]   r^   r   )r   r   )
r   r   r   r   r   Zilocr   rM   r   r6   )r   r<   r    rQ   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 )NrX   r.   r-   r1   zUIn a future version of pandas all arguments of DataFrame\.dropna will be keyword-onlyr3   )r   r   Zassert_produces_warningFutureWarningr   r6   )r   r<   r>   rQ   r    r#   r#   r$    test_dropna_pos_args_deprecation   s    z9TestDataFrameMissingData.test_dropna_pos_args_deprecationN)__name__
__module____qualname__r%   r*   r?   rC   rG   rK   rR   rW   r`   rb   r#   r#   r#   r$   r      s   A
r   )rN   rO   Znumpyr   r9   ZpandasrT   r   r   Zpandas._testingZ_testingr   r   r#   r#   r#   r$   <module>   s   