U
    f/e                     @   sN   d dl Zd dlZd dlZd dlmZmZmZmZ d dl	m
Z G dd dZdS )    N)	DataFrameIndexSeriesconcatc                   @   sD   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S )TestDataFrameConcatc                 C   s   t tdddgtjd}t tdtjd}t||fddj}ttdgd	 td
gd	  ddddgd}t	
|| d S )N)
      foobar)datacolumnsdtype)r   r      axisfloat64r   float32r   index)r   nponesr   r   r   Zdtypesr   r   tmassert_series_equal)selfABresultsexpected r   N/tmp/pip-unpacked-wheel-tiezk1ph/pandas/tests/reshape/concat/test_dataframe.py"test_concat_multiple_frames_dtypes   s    
z6TestDataFrameConcat.test_concat_multiple_frames_dtypesc                 C   sz   t tdtdd}t tdd tdd}t||fddgd}t d	d	d
d
d
dd	d	d
d
d
dd}t|| d S )N)r   r   ZABr   )   r   r   )beebah)r#   bookeysg      ?g       @))r#   r$   r   )r#   r$   r   )r#   r%   r   )r#   r%   r   )r#   r%   r   )r   r   )r   r   r   listr   r   assert_frame_equal)r   df1df2r   r   r   r   r   test_concat_tuple_keys   s&    z*TestDataFrameConcat.test_concat_tuple_keysc           	      C   s  t ddgddgd}tddgdd	}t||g|d
}t ddddgddddgdtjjddgddgfdd gdd}t|| tddgd d	}t||g|dgd}t|| t||g|d
}t ddddgddddgdtjjddgddgfd d gdd}t|| d S )Nr   r   皙?皙?)r	   r
   abZbaznamer&   r   namesr   )r'   r4   )r   r   r   pd
MultiIndexfrom_productr   r)   )	r   dfr   Zconcatted_named_from_keysZexpected_namedZindex_no_nameZconcatted_named_from_namesZconcatted_unnamedZexpected_unnamedr   r   r   test_concat_named_keys4   s"    z*TestDataFrameConcat.test_concat_named_keysc              	   C   s  t dddgitdd}t dddgitdd}t dddddgidd	dd	gd}t||gd
d}t|| t||gdd}t|| t||gdd}t|| t ddgddggdd	gddgd}t||gdd}t|| t||gd	d}	t|	| tddg}
tddg}tddddgdd	dd	gd}t|
|gd
d}t|| t|
|gdd}t|| t|
|gdd}t|| t ddgddggdd	gdd	gd}t|
|gdd}t|| t|
|gd	d}t|| tjt	dd t|
|gdd W 5 Q R X d S )Nr   r-   r.   r   r   g333333?g?r   r   r   r   Zrows)r   r   r   zNo axis named)matchZ	something)
r   ranger   r   r)   r   r   pytestZraises
ValueError)r   r*   r+   Zexpected_indexZconcatted_indexZconcatted_rowZconcatted_0Zexpected_columnsZconcatted_columnsZconcatted_1Zseries1Zseries2Zexpected_index_seriesZconcatted_index_seriesZconcatted_row_seriesZconcatted_0_seriesZexpected_columns_seriesZconcatted_columns_seriesZconcatted_1_seriesr   r   r   test_concat_axis_parameterJ   sL         z.TestDataFrameConcat.test_concat_axis_parameterc                 C   s   t dtdidtjjdddgddd	ggd
dgdd}t|jd dd d f |jdd d d f f}t ddd
ddgidtjjddddgd
dgdd}t	|| d S )Ncol	   Zint32A0A1A2B0B1B2r   r   r3   )r   r   r         )rA   rD   )rA   rE   )rC   rE   )rC   rF   )
r   r;   r5   r6   r7   r   Zilocfrom_tuplesr   r)   r   r8   resultr   r   r   r   test_concat_numerical_names   s$    
 	0
 z/TestDataFrameConcat.test_concat_numerical_namesc                 C   s`   t ddig}t||gdd}|d}t tddgddddgdd}t|| d S )Nr/   r0   r   r   categoryr   r!   )r   r   Zastyper   arrayZreshaper   r)   rK   r   r   r   test_concat_astype_dup_col   s    
 z.TestDataFrameConcat.test_concat_astype_dup_colc                 C   s~   t dtdddgtdddgdd	d
i}t dtddgtddgdd	d
i}t||gdddg|d}t|jddgksztd S )Nvaluer   r   r"   r/   r0   cidr1   r   rH   rI   t1t2)r   r'   sort)rT   rQ   )rU   rQ   )r   r   r   r   r(   r   AssertionError)r   rV   rT   rU   rL   r   r   r   test_concat_dataframe_keys_bug   s    "$z2TestDataFrameConcat.test_concat_dataframe_keys_bugN)
__name__
__module____qualname__r    r,   r9   r>   rM   rP   rX   r   r   r   r   r      s   :r   )Znumpyr   r<   Zpandasr5   r   r   r   r   Zpandas._testingZ_testingr   r   r   r   r   r   <module>   s
   