3
Ud]                 @   s^   d dl Zd dlZd dlZd dlmZmZ d dljZ	dd Z
dd Zdd Zd	d
 Zdd ZdS )    N)	DataFrame
MultiIndexc             C   s   | j  }| j}tj|| d S )N)Zto_numpyvaluestmZassert_numpy_array_equal)idxresultexp r	   ^/var/www/html/virt/lib64/python3.6/site-packages/pandas/tests/indexes/multi/test_conversion.pytest_to_numpy	   s    r   c              C   sd  ddddg} t j| }|jdd}t| }tj|| |j }||_tj|| ddddg} t j| ddgd	}|jdd}t| }ddg|_tj|| |j }||_tj|| t j| }|jdddgd
}t| }ddg|_tj|| |jddgd}||_ddg|_tj|| d}tj	t
|d |jdd W d Q R X d}tj	t|d |jdgd W d Q R X t jtdtjdddg}|jdd}ttjtjddddtjtjddddd}tj|| |j }||_tj|| |jdddgd
}ttjtjddddtjtjddddd}tj|| |jddgd}||_tj|| d S )N   onetwo   F)indexfirstsecond)names)r   name)r   z1'name' must be a list / sequence of column names.)matchz<'name' should have same length as number of levels on index.   Z20130101   )periodsZint64)dtype)r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   from_tuplesto_framer   r   assert_frame_equalr   columnspytestZraises	TypeError
ValueErrorZfrom_productrangepd
date_rangenprepeatZarangeZtile)Ztuplesr   r   expectedmsgr	   r	   r
   test_to_frame   sb    




r(   c           
      s   t jjt jddddddddddgt jddddd	d	gd
dddddddggdddd	gd  fddt jD } t jt jddddddddddgt jddddd	d	gd
dddddddgd} jdd}|j	j
 }tj|| | |kstd S )NZ19910905   z
US/Eastern)r   tzr   r   abcT)Zorderedxyzdates)r   c                s   i | ]\}} j | j|qS r	   )Zlevelsr   ).0ir   )mir	   r
   
<dictcomp>c   s    z0test_to_frame_dtype_fidelity.<locals>.<dictcomp>)r1   r+   r,   r-   F)r   )r"   r   from_arraysr#   ZCategorical	enumerater   r   r   Zdtypesto_dictr   r   AssertionError)Zoriginal_dtypesZexpected_dfdfZ	df_dtypesr	   )r4   r
   test_to_frame_dtype_fidelityX   s     
r;   c              C   sP   dddg} t jjdddgdddgdd	d
gg| d}|j jj }|| ksLtd S )Nr0   r   r+   r,   r-   r.   r/   qwe)r   )r"   r   r6   r   r   tolistr9   )r&   r4   r   r	   r	   r
   $test_to_frame_resulting_column_ordert   s
    
"r@   c             C   s&   t jddd}| j }tj|| d S )Nfoor   r   barbazquxF)Ztupleize_colsrA   r   rA   r   rB   r   rC   r   rD   r   rD   r   )rE   rF   rG   rH   rI   rJ   )r"   IndexZto_flat_indexr   Zassert_index_equal)r   r&   r   r	   r	   r
   test_to_flat_index~   s         rL   )Znumpyr$   r   Zpandasr"   r   r   Zpandas._testingZ_testingr   r   r(   r;   r@   rL   r	   r	   r	   r
   <module>   s   
I
