U
    f/e
                     @   sj   d dl Zd dlZd dlmZmZmZmZmZm	Z	m
Z
 d dlmZ ejddgddd ZG dd	 d	ZdS )
    N)	DataFrameDatetimeIndexIndex
MultiIndexSeriesconcat
date_rangeTF)paramsc                 C   s   | j S )z5Boolean sort keyword for concat and DataFrame.append.)param)request r   K/tmp/pip-unpacked-wheel-tiezk1ph/pandas/tests/reshape/concat/test_series.pysort   s    r   c                   @   sl   e Zd Zdd Zdd ZefddZdd Zd	d
 Ze	j
deddfdgdd Zdd Zdd ZdS )TestSeriesConcatc                 C   s   t  }d|_|d d |dd |dd  g}t|}t || |j|jksTtt|dddgd}| }ttj	|j
jdd	|_
tdddgd
d |D tt|g}tdddg|j
g|d}||_
t || d S )Nfoo      r         )keyszM8[ns]Zdtypec                 S   s   g | ]}t |qS r   )len).0xr   r   r   
<listcomp>'   s     z7TestSeriesConcat.test_concat_series.<locals>.<listcomp>)levelscodes)tmmakeTimeSeriesnamer   assert_series_equalAssertionErrorcopyr   nparrayindexvaluesrepeatZaranger   r   )selftspiecesresultexpectedZ	exp_codesZ	exp_indexr   r   r   test_concat_series   s    "*z#TestSeriesConcat.test_concat_seriesc                 C   s6   t dg}t g td}|}t||g}t|| d S )Nr   r   )r   objectr   r   r    )r(   s1s2r,   r+   r   r   r   1test_concat_empty_and_non_empty_series_regression,   s
    
zBTestSeriesConcat.test_concat_empty_and_non_empty_series_regressionc                 C   sl  t  }|d d |dd  |dd g}t|dd}t|j}t || t|dddgdd}t|dddgd	j}t || ttj	d
dd}ttj	d
dd}t||gdd}t||d}t || d |_
t||gdd}t |jtddgdd ttj	ddddgdd}ttj	dddddgdd}t||gd|d}t||d}t || d S )Nr   r   axisABC)r   r4   )r%   r   r   )r5   r6   r   r.   r      cabr%   r      d)r4   r   )r   r   r   r   Tassert_frame_equalr   r#   randomrandnr   assert_index_equalcolumnsr   )r(   r   r)   r*   r+   r,   sr0   r   r   r   test_concat_series_axis15   s*    "
z)TestSeriesConcat.test_concat_series_axis1c                 C   s   t dddg}t dddg}t||gdddgd	gd
}tddgddgddggtddgd	dd}t|| t||gdddgd	dgd
}tddgddgddggtjddgd	dgdd}t|| d S )Nr   r   r9   r>   r      r;   r<   r5   )r4   r   namesr8   rE   )r;   r   )r<   r   r6   )rI   )r   r   r   r   r   rA   r   from_tuples)r(   rF   r0   r+   r,   r   r   r   &test_concat_series_axis1_names_appliedU   s     z7TestSeriesConcat.test_concat_series_axis1_names_appliedc                 C   s~   t dddddd }ttjt||dd}ttjt||dd}t||gd	d
d}ttd}t	j
|j|d
d d S )Nz01-Jan-2013z01-Jan-2014ZMS)freqr   valuer=   r   Tr4   Zignore_indexr   )exact)r   r   r#   rB   rC   r   r   r   ranger   rD   rE   )r(   datesr/   r0   r+   r,   r   r   r   0test_concat_series_axis1_same_names_ignore_indexf   s    zATestSeriesConcat.test_concat_series_axis1_same_names_ignore_indexzs1name,s2name   +   r   )rU   rV   c                 C   sR   t ddd|d}t ddd|d}t||g}t ddddd}t|| d S )	Nr   r   )r;   r<   r8   r   rH   )r:   r?   )r;   r<   r:   r?   )r   r   r   r    )r(   Zs1nameZs2namer/   r0   r+   r,   r   r   r   &test_concat_series_name_npscalar_tuplep   s
    z7TestSeriesConcat.test_concat_series_name_npscalar_tuplec                 C   s   t ddgdd}t ddg}t ddg}t|||gdd}tddgddgddgddd	dgd
}t|| t|||gddddgd}tddgddgddgddddgd
}t|| t|||gddd}tddgddgddgd}t|| d S )Nr   r   r   r8   r>   r   r3   )r   r   r   r   rJ   redblueyellow)r4   r   )rY   rZ   r[   TrP   )r   r   r   )r   r   r   r   rA   )r(   r   barZbazr+   r,   r   r   r   (test_concat_series_partial_columns_names{   s$     z9TestSeriesConcat.test_concat_series_partial_columns_namesc                 C   s0   |dg}t |jd d d g}t|| d S )Nd   rN   )r   Zilocr   Zassert_equal)r(   Zframe_or_seriesobjr+   r   r   r   &test_concat_series_length_one_reversed   s    
z7TestSeriesConcat.test_concat_series_length_one_reversedN)__name__
__module____qualname__r-   r1   r   rG   rL   rT   pytestmarkZparametrizer#   Zint64rX   r]   r`   r   r   r   r   r      s   	 
 
r   )Znumpyr#   rd   Zpandasr   r   r   r   r   r   r   Zpandas._testingZ_testingr   Zfixturer   r   r   r   r   r   <module>   s   $	
