HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/pandas/tests/frame/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/pandas/tests/frame/__pycache__/test_join.cpython-36.pyc
3

���hK"�@s.ddlmZddlZddlZddlZddlmZmZmZddl	j
Zejdd��Z
ejdd��Zejdd	��Zejjd
dded
dgddgd�ddgd�fddedd
gddgd�ddgd�fdded
ddgddejgd�dddgd�fddeddd
gejddgd�dddgd�fd	deejdd
gdddgd�dddgd�fd	dedd
ejgdddgd�dddgd�fddeddd
ejgejdddgd�ddddgd�fddeddd
ejgejdddgd�ddddgd�fg�dd��Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zejjd'ddg�d(d)��ZGd*d+�d+�ZdS),�)�datetimeN)�	DataFrame�Index�period_rangecCs*ttjd�jdd�td�tdddd�d�S)	N���Zabcde�2000�A)�start�freqZperiods)�data�columns�index)r�npZarangeZreshape�listr�rr�>/tmp/pip-build-5_djhm0z/pandas/pandas/tests/frame/test_join.py�frame_with_period_indexsrcCstddddgidddgd�S)N�ar�
r��)r)rrrrr�leftsrcCstddddgidddgd�S)	N�bi,�d���rr)r)rrrrr�rightsrzhow, sort, expected�innerFrrrr)rrrr)rTi,r�outercCs |j|||d�}tj||�dS)N)�how�sort)�join�tm�assert_frame_equal)rrr!r"�expected�resultrrr�	test_joins-r(cCs�|j|jdd�ddgf}|j|jdd�ddgfjddd�}|j|�}tj|j|j�tddddg�}tj|j|�|j|dd	�}tj|j|j�tj|j|�|j|d
d	�}tj|j|j�tj|j|�|j|dd	�}tj|j|jdd��tj|j|�|j|dd	�}tj|j|jj��tj|j|�t	j
td
d��|j|dd	�WdQRXd}x6dD].}t	j
t|d��|j||d	�WdQRX�qjWdS)Nrr
�Br�C�Drr)r!rrr zjoin method)�matchZfoozcolumns overlap but no suffix���)r rr)�locrZilocr#r$Zassert_index_equalrrZsort_values�pytest�raises�
ValueError)�float_frame�f�f2�joinedZexpected_columns�msgr!rrr�test_join_indexOs0(

r7cCs�|jdd�ddgf}|jddd�ddgf}|j�}|dddd�|d<|dddd�|d<|j|�}tj||�|j|dd�}tj||ddd��|j|dd�}tj||jdd�|jf�dS)Nr
r)rr*r+r)r!)r.�copyr#r$r%r)r2�afZbfr&r'rrr�test_join_index_morexs
r:c	Cs`|j�}|j|jd�}|j|�}tj||dd�d|_tjt	dd��|j|�WdQRXdS)NrF)Zcheck_nameszmust have a name)r,r-)
r8�poprr#r$r%�namer/r0r1)r2Zdf�sr5rrr�test_join_index_series�s
r>cCs�|jdd�dddgf}|jdd�dddgf}|j|ddd�}|jdd�ddgfjd�}|jdd�ddgfjd�}|jdd�ddgf}|j|�j|�}tj||jdd�|jf�dS)Nr
r)r*r+Z_df1Z_df2)ZlsuffixZrsuffix)r.r#Z
add_suffixr$r%r)r2�df1�df2r5Zdf1_sufZdf2_sufZ
no_overlapr&rrr�test_join_overlap�srAcCs^|jdd�d�}tj|jgddd�}|jj|j�}|j|�}t|||jd�}t	j
||�dS)NcSs|�|��S)Nr)�keyrrr�<lambda>�sz(test_join_period_index.<locals>.<lambda>)rrr)Zaxis)r
rr)�renamerZconcatenate�valuesr�appendr#rrr$r%)r�otherZ
joined_valuesZjoined_colsr5r&rrr�test_join_period_index�s
rHcCs�tddddgidddgd�}td	d
ddgid
ddgd�}tddddgiddd
gd�}|j||gdd�}tddddgtjdddgtjddtjgd�ddddgd�}tj||�dS)Nrrrrrrr)rrrri,r�ci�i�iXr)r!)rrrI)rr#r�nanr$r%)r?r@Zdf3r5r&rrr�(test_join_left_sequence_non_unique_index�s
rK�sort_kwcCs�tdddgiddgd�}tddd	gid
dgd�}tddd
gidd
gd�}tdtd�dd�ddtd�d�ddtd�d�d��}|dkr�|jddd
gd�}tjddd��|j||gd|d�}WdQRXtj||�dS)N�col1rrrIr)r�col2rrr�col3��g@rJg�?)rrrIg@g@g@g @)rMrNrOF)Zcheck_stacklevelr )r!r")r�floatZreindexr$Zassert_produces_warningr#r%)rLrrrIr&r'rrr�)test_suppress_future_warning_with_sort_kw�srSc@seZdZdd�Zdd�ZdS)�TestDataFrameJoincCsrddg}tddd�tddd�g}t|td�dgd�}td	dgd
dgg||d�}|j|dd�}t|j�d
ksnt�dS)
NZ20120209Z20120222i�r�	�Zaa)rrrrr)�on)rr�ranger#�lenr�AssertionError)�selfZ	str_datesZdt_datesr
r*Ztstrrr�test_join_str_datetime�sz(TestDataFrameJoin.test_join_str_datetimecCs�tjdddgdddgdddgdddgddd
gddd gddd
gdddgdddgg	dddgd�jddg�}tjddgddggddgd�jdg�}tjddgddgddgd!dgd
dgd"dgdtjgdtjgdtjgg	|jddgd�}tj|j|dd�|�tj|j|dd�|ddg�tj	j
ddgdddggddgd�}tjddgddgddgd#dgd
dgd$dgg|ddgd�}tj|j|dd�|�tj|j|dd�|ddg�dS)%Nr�xgR
���1�?�yg�����?�zg�<�+J	�?rg��4��?g^�9�S��?g?����?rIrrr�first�secondZvalue1)rrrZvalue2g�?g@g@)rrr)r!r)�namesg��4�ֿg?�����g��4�ֿg?�����g��4�ֿg?�����)�pdrZ	set_indexrrJrr$r%r#Z
MultiIndexZfrom_product)r[r?r@�expZexp_idxrrr�test_join_multiindex_leftright�sT


z0TestDataFrameJoin.test_join_multiindex_leftrightN)�__name__�
__module__�__qualname__r\rerrrrrT�srT)rZnumpyrr/ZpandasrcrrrZpandas._testingZ_testingr$Zfixturerrr�markZparametrizerJr(r7r:r>rArHrKrSrTrrrr�<module>sT
	""&&&&)