a
    Pf                     @   sR   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 G dd dZdS )    N)	DataFrameDatetimeIndexIndex
MultiIndexSeriesconcat
date_rangec                   @   sx   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	e
jdeddfdgdd Zdd Zdd ZdS )TestSeriesConcatc                 C   s   t tjdtjdtddddd}d|_|d d |dd |dd  g}t|}t|| |j|jksnJ t|g d	d
}|	 }t
tj|jjdd|_tg d	dd |D tt|g}tg d	|jg|d}||_t|| d S )N   Zdtype
2020-01-01Zperiodsfooindexname      r         )keyszM8[ns]c                 S   s   g | ]}t |qS  )len).0xr   r   `/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pandas/tests/reshape/concat/test_series.py
<listcomp>$       z7TestSeriesConcat.test_concat_series.<locals>.<listcomp>)Zlevelscodes)r   nparangefloat64r   r   r   tmassert_series_equalcopyr   arrayr   valuesrepeatr   r   )selftspiecesresultexpectedZ	exp_codesZ	exp_indexr   r   r   test_concat_series   s"    
"(z#TestSeriesConcat.test_concat_seriesc                 C   sh   t dg}t g td}|}d}tjt|d t||g}W d    n1 sN0    Y  t|| d S )Nr   r   zDThe behavior of array concatenation with empty entries is deprecated)match)r   objectr#   Zassert_produces_warningFutureWarningr   r$   )r)   s1s2r-   msgr,   r   r   r   1test_concat_empty_and_non_empty_series_regression)   s    
*zBTestSeriesConcat.test_concat_empty_and_non_empty_series_regressionc                 C   s   t tjdtjdtdddd}|d d |dd  |dd g}t|dd	}t|j}t	|| t|g d
dd}t|g d
dj}t	|| d S )N
   r   r   r   r   r   r   axis)ABC)r   r:   )
r   r    r!   r"   r   r   r   Tr#   assert_frame_equal)r)   r*   r+   r,   r-   r   r   r   test_concat_series_axis14   s    "
z)TestSeriesConcat.test_concat_series_axis1c                 C   s   t tjdddd}t tjdddd}t||gdd}t||d}t|| d |_	t||gdd}t
|jtdd	gd
d d S )Nr   r   r;   r   r<   r   r9   r;   r<   r   r0   r   )r   r    randomdefault_rngstandard_normalr   r   r#   r?   r   assert_index_equalcolumnsr   r)   sr3   r,   r-   r   r   r   /test_concat_series_axis1_preserves_series_namesC   s    z@TestSeriesConcat.test_concat_series_axis1_preserves_series_namesc                 C   s   t tjddg ddd}t tjddg ddd}t||gd	|d
}t||dg dd}|rt| }t	|| d S )Nr      )cabr;   r      )drM   rN   rL   r<   r   )r:   sortrB   )rL   rM   rN   rP   r7   )
r   r    rC   rD   rE   r   r   Z
sort_indexr#   r?   )r)   rQ   rI   r3   r,   r-   r   r   r   %test_concat_series_axis1_with_reindexP   s    z6TestSeriesConcat.test_concat_series_axis1_with_reindexc                 C   s   t g d}t g d}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 )N)r   r   rK   )rO   r      r   rM   rN   r;   )r:   r   namesrO   r   r   rK   rS   rA   rG   )rM   r   )rN   r   r<   )rT   )r   r   r   r   r#   r?   r   from_tuplesrH   r   r   r   &test_concat_series_axis1_names_applied`   s    "z7TestSeriesConcat.test_concat_series_axis1_names_appliedc                 C   s   t dddddd }ttjdt||dd	}ttjd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   r   valuer   r   Tr:   Zignore_index)exact)r   r   r    rC   rD   rE   r   r   r   ranger#   rF   rG   )r)   datesr2   r3   r,   r-   r   r   r   0test_concat_series_axis1_same_names_ignore_indexq   s    zATestSeriesConcat.test_concat_series_axis1_same_names_ignore_indexzs1name,s2name   +   r   )r`   ra   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   )rM   rN   rA   r   rS   )rL   rP   )rM   rN   rL   rP   )r   r   r#   r$   )r)   Zs1nameZs2namer2   r3   r,   r-   r   r   r   &test_concat_series_name_npscalar_tuple   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g dd	}t|| t|||gdg d
d}tddgddgddgd
g d
d	}t|| t|||gddd}tddgddgddgd}t|| d S )Nr   r   r   rA   rO   r   r9   )r   r   r   rU   )redblueyellow)r:   r   Tr[   r   )r   r   r   r#   r?   )r)   Znamed_seriesZunnamed_series1Zunnamed_series2r,   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   rY   )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.   r5   r@   rJ   rR   rW   r_   pytestmarkZparametrizer    Zint64rc   rg   rj   r   r   r   r   r	      s   
r	   )numpyr    rn   Zpandasr   r   r   r   r   r   r   Zpandas._testingZ_testingr#   r	   r   r   r   r   <module>   s   $	