o
    i                 
   @   s  d dl mZ d dlmZmZ d dlmZ d dlZd dlm	Z	 d dl
Z
d dlmZmZ d dlmZ d dlmZ d dlm  mZ d dlmZmZ d d	lmZ d dlZd d
lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, d dl-m.Z/ d dl0m1Z1 d dl2m3Z3m4Z4 d dl5m6Z6 G dd dZ7G dd dZ8G dd dZ9dd Z:e
j;<dd d iej=d ggej>dfddiej=dgge?dfddiej=dggej>dfgdd Z@dS )    )OrderedDict)datetime	timedelta)tzoffsetN)iNaTlib)is_numpy_dev)np_version_gte1p24)is_categorical_dtypeis_datetime64tz_dtype)CategoricalDtype)Categorical	DataFrameDatetimeIndexIndexIntervalIntervalIndex
MultiIndexNaTPeriod
RangeIndexSeries	Timestamp
date_rangeisnaperiod_rangetimedelta_range)
Int64Index)IntervalArrayperiod_array)NumericBlockc                   @   sT	  e Zd Zejddd dfdd dfdd dfdd dfd	d dfd
d dfdd dfdd dfdd dfdd dfdd dfg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eegdd  Zejd!ejed"gd#d$ Zejd%g d&ejd'd(eg gd)d* Zd+d, Zd-d. Zejd/g d0d1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Zd=d> Zd?d@ Z ejd%g dAdBdC Z!ejdDdEdFgdGdHgee"dIdFdJdKee"dIdFdJdLdMe#dNdOdPggdQdR Z$dSdT Z%dUdV Z&dWdX Z'dYdZ Z(d[d\ Z)d]d^ Z*d_d` Z+dadb Z,dcdd Z-dedf Z.dgdh Z/didj Z0dkdl Z1dmdn Z2dodp Z3dqdr Z4dsdt Z5ejdug dvdvee6dwe7g dxdydz e6dwD e8d{d e6dwgd|d} Z9d~d Z:dd Z;dd Z<dd Z=dd Z>e?j@ejjd'e"ddwdLde"ddwdeAddwdeBddwddKeedeCg dveDdNdwgdd ddd ZEdd ZFdd ZGdd ZHdd ZIejdejJdEgejKdejJdEgejLdejJdEgejMdeKdEgeLdEgeMdEggdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`ddĄ ZaddƄ ZbddȄ Zcddʄ Zddd̄ Zedd΄ ZfddЄ Zgejdejhejigejd%ddgejdg dբddׄ Zjejddekejd(gddۄ Zldd݄ Zmejdeneogdd ZpejjdeejJgddgddd ZqejjdeejJgddgddd Zrdd ZsejjdeejJgddgddd Ztejjudddd Zvdd Zwdd Zxdd Zydd Zzdd Z{dd Z|ejddFejd(ed"gdd Z}dd  Z~dd Zdd Zdd Zdd Zd	d
 Zejddd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zejjd'e"d d!deAdd!deBd"d!ddKgd#d dd$d% Zejjd'e"d d!deAdd!deBd"d!ddKgd&d dd'd( Zejd%ejejgd)d* Zejd+d,d-gd.d/ Zejd%g d0d1d2 Zd3d4 Zd5d6 Zejd7ddgd8d9 Zd:d; Zd<d= Zejded>ed?gd>d?ggd@dA ZdBdC ZdDdE ZdFdG ZdHdI ZdJdK ZdLdM ZdNdO ZdPdQ ZdRdS ZdTdU ZdVdW ZdXdY ZdZd[ Zd\d] Zd^d_ Zejd`ejdaeeeejJgdbdc Zd(S (d  TestSeriesConstructorszconstructor,check_index_typec                   C   s   t  S Nr    r$   r$   `/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/pandas/tests/series/test_constructors.py<lambda>>   s    zTestSeriesConstructors.<lambda>Tc                   C   s   t d S r"   r#   r$   r$   r$   r%   r&   ?       c                   C   s   t i S r"   r#   r$   r$   r$   r%   r&   @   r'   c                   C   s   t dS )Nr$   r#   r$   r$   r$   r%   r&   A   r'   Fc                   C   s   t g S r"   r#   r$   r$   r$   r%   r&   B   r'   c                   C   s   t dd dD S )Nc                 s       | ]}|V  qd S r"   r$   .0_r$   r$   r%   	<genexpr>C       2TestSeriesConstructors.<lambda>.<locals>.<genexpr>r$   r#   r$   r$   r$   r%   r&   C       c                   C   s
   t d dS Ndatar#   r$   r$   r$   r%   r&   D      
 c                   C   s
   t i dS r0   r#   r$   r$   r$   r%   r&   E   r3   c                   C   s
   t ddS )Nr$   r1   r#   r$   r$   r$   r%   r&   F   r3   c                   C   s
   t g dS r0   r#   r$   r$   r$   r%   r&   G   r3   c                   C   s   t dd dD dS )Nc                 s   r(   r"   r$   r)   r$   r$   r%   r,   H   r-   r.   r$   r1   r#   r$   r$   r$   r%   r&   H       c                 C   s\   t t t }| }W d    n1 sw   Y  t|jdks$J t j|||d d S )Nr   check_index_type)tmassert_produces_warningFutureWarningr   lenindexassert_series_equal)selfconstructorr6   expectedresultr$   r$   r%   test_empty_constructor7   s   z-TestSeriesConstructors.test_empty_constructorc              	   C   sX   d}t dtg}|D ] }tjt|d tg d|d W d    n1 s$w   Y  q	d S )Nznot understoodr   matchtime)namedtype)r   listpytestraises	TypeErrorr   )r=   msginvalid_listrF   r$   r$   r%   test_invalid_dtypeT   s   
z)TestSeriesConstructors.test_invalid_dtypec                 C   sd   t ddg}t jddg|d}tjtdd t|dd	gd
 W d    d S 1 s+w   Y  d S )N)ai8)bf4)   g?)   irF   zUse DataFrame insteadrB   ABr;   )nprF   arrayrH   rI   
ValueErrorr   )r=   c_dtypecdt_arrr$   r$   r%   test_invalid_compound_dtype\   s
   "z2TestSeriesConstructors.test_invalid_compound_dtypec                 C   sF   t d}t|trJ tt dgdksJ tt dgdks!J d S )Ng      ?      ?rR   )r   
isinstancefloatint)r=   scalarr$   r$   r%   test_scalar_conversiond   s   z-TestSeriesConstructors.test_scalar_conversionc                 C   sH   |\}}t |tdd}t |gd |d}|j|ksJ t|| d S )N   rW   rT   )r   rangerF   r7   r<   )r=   ea_scalar_and_dtype	ea_scalarea_dtypeserr?   r$   r$   r%   test_scalar_extension_dtypen   s
   z2TestSeriesConstructors.test_scalar_extension_dtypec           	      C   s  t t t }W d    n1 sw   Y  |jjsJ t|}|jjs(J t |j|js2J t|jt|jks>J tdtj	gddgd}|j
tjksQJ |d tj	u sZJ |jjr`J t t t jjrmJ W d    n1 sww   Y  tjtdd ttjddtdd W d    n1 sw   Y  d|_t|j}d}||ksJ tdd	gdd
gg}d}tjt|d t| W d    d S 1 sw   Y  d S )Nhellor   rR   rW   zData must be 1-dimensionalrB   rd   r         z8initializing a Series from a MultiIndex is not supported)r7   r8   r9   r   r;   _is_all_datesequalContentsidrX   NaNrF   object_rH   rI   rZ   randomrandnarangerE   r   from_arraysNotImplementedError)	r=   datetime_seriesempty_seriesderivedmixedrsxpmrK   r$   r$   r%   test_constructory   s6   

"z'TestSeriesConstructors.test_constructorc                 C   sf   t ddgddgddggg dd}tjtd	d
 tg d|d W d    d S 1 s,w   Y  d S )NrR   rl   rd   rm         )rd   r   	   rW   z Index data must be 1-dimensionalrB   rR   rd   rl   )r   rH   rI   rZ   r   )r=   dfr$   r$   r%   'test_constructor_index_ndim_gt_1_raises   s   ""z>TestSeriesConstructors.test_constructor_index_ndim_gt_1_raisesinput_classc                 C   s`  t t t }t| }W d    n1 sw   Y  t j||dd tdd}t| dd}t j||dd tdd}t| dd}t j||dd |turt t ttdd}t| tdd}W d    n1 sqw   Y  t || ttjtdd}t| tddd}t || td	t	td
d}td	td
d}t || d S d S )NFr5   float64rT   category
   rW   r;   rF    rd   rF   r;   )
r7   r8   r9   r   r<   rG   re   rX   nanstr)r=   r   emptyempty2r$   r$   r%   test_constructor_empty   s0   

z-TestSeriesConstructors.test_constructor_empty	input_argr   c                 C   s4   t dtdd}t |tdd}tj||dd d S )Nr   r   r   rW   Fr5   r   re   r7   r<   )r=   r   r   r   r$   r$   r%   test_constructor_nan   s   z+TestSeriesConstructors.test_constructor_nanrF   )f8rO   M8[ns]m8[ns]r   objectzdatetime64[ns, UTC]r;   Nc                 C   s.   t ||d}|j|ksJ t|dksJ d S )Nr   r   )r   rF   r:   )r=   rF   r;   r@   r$   r$   r%   test_constructor_dtype_only   s   z2TestSeriesConstructors.test_constructor_dtype_onlyc                 C   sR   t t tg dd}W d    n1 sw   Y  |j g dks'J d S )NrP   rN   crW   )r7   r8   r9   r   r;   tolistr=   r@   r$   r$   r%   $test_constructor_no_data_index_order   s   z;TestSeriesConstructors.test_constructor_no_data_index_orderc                 C   s&   t dgtd}t|jd sJ d S NrR   r   r   )r   r   rX   isnanilocr   r$   r$   r%   $test_constructor_no_data_string_type   s   z;TestSeriesConstructors.test_constructor_no_data_string_typeitem)entryu   ѐ   c                 C   s*   t |dgtd}|jd t|ksJ d S r   )r   r   r   )r=   r   r@   r$   r$   r%   +test_constructor_string_element_string_type   s   zBTestSeriesConstructors.test_constructor_string_element_string_typec                 C   sl   t dd g|d}| }t ddg}t|| |jd d u s!J t dtjg|d}t|jd s4J d S )NxrT   FTrR   )r   r   r7   r<   r   rX   r   r   )r=   string_dtyperi   r@   r?   r$   r$   r%   $test_constructor_dtype_str_na_values   s   z;TestSeriesConstructors.test_constructor_dtype_str_na_valuesc                 C   s@   g d}t |}tg d|d}t||d}t||  d S )N)drP   rN   r   )rm      rd   rW   )sortedr   r7   r<   
sort_index)r=   index1index2s1s2r$   r$   r%   test_constructor_series   s
   z.TestSeriesConstructors.test_constructor_seriesc                 C   s@   G dd d}t ttddd}t | dd}t|| d S )Nc                   @   s   e Zd Zdd ZdS )z>TestSeriesConstructors.test_constructor_iterable.<locals>.Iterc                 s   s    t dE d H  d S )Nr   )re   r=   r$   r$   r%   __iter__  s   zGTestSeriesConstructors.test_constructor_iterable.<locals>.Iter.__iter__N)__name__
__module____qualname__r   r$   r$   r$   r%   Iter   s    r   r   int64rT   r   rG   re   r7   r<   )r=   r   r?   r@   r$   r$   r%   test_constructor_iterable   s   z0TestSeriesConstructors.test_constructor_iterablec                 C   s4   t ttddd}t tddd}t|| d S )Nr   r   rT   r   r=   r?   r@   r$   r$   r%   test_constructor_sequence  s   z0TestSeriesConstructors.test_constructor_sequencec                 C   s"   t dg}t d}t|| d S )Nabcr   r7   r<   r   r$   r$   r%   test_constructor_single_str  s   
z2TestSeriesConstructors.test_constructor_single_strc                 C   sR   t g ddd}g ddtjg dddfD ]}t |g dd}t|| qd S )NrR   rl   rd   r   rT   r   rR   rl   rW   r   rX   rY   r7   r<   )r=   r?   objr@   r$   r$   r%   test_constructor_list_like  s
    z1TestSeriesConstructors.test_constructor_list_likec                 C   sP   t g dg dd}|dk}t g d|d}t g dg dd}t|| d S )Nr   )rm   r   r   rW   rl   r   )FTFr   )r=   r   r;   r@   r?   r$   r$   r%   test_constructor_boolean_index  s
   z5TestSeriesConstructors.test_constructor_boolean_index)boolint32r   r   c                 C   s&   t tg d|d}|j|ksJ d S )N)r   rl   rm   rT   )r   r   rF   )r=   rF   sr$   r$   r%   test_constructor_index_dtype'  s   z3TestSeriesConstructors.test_constructor_index_dtype
input_valsrR   rl   12z1/1/2011Hperiodsfreq
US/Eastern)r   r   tzr   r   )leftrightc                 C   s*   t ||d}t ||}t|| d S NrT   r   astyper7   r<   )r=   r   r   r@   r?   r$   r$   r%   test_constructor_list_str.  s   z0TestSeriesConstructors.test_constructor_list_strc                 C   sJ   t ddtjg|d}t ddtjgtd}t|| t|d s#J d S )Nr^          @rT   z1.0z2.0rl   )r   rX   r   r   r7   r<   r   )r=   r   r@   r?   r$   r$   r%   test_constructor_list_str_na@  s   z3TestSeriesConstructors.test_constructor_list_str_nac                 C   sr   dd t dD }t|}tt d}t|| dd t dD }t|t ddd}t dd|_t|| d S )Nc                 s   r(   r"   r$   r*   ir$   r$   r%   r,   G  r-   zDTestSeriesConstructors.test_constructor_generator.<locals>.<genexpr>r   c                 s   r(   r"   r$   r   r$   r$   r%   r,   N  r-      rW   )re   r   r7   r<   r;   )r=   genr@   expr$   r$   r%   test_constructor_generatorF  s   z1TestSeriesConstructors.test_constructor_generatorc                 C   sr   t dd td}t|}ttd}t|| t dd td}t|tddd}tdd|_t|| d S )Nc                 S      | S r"   r$   r   r$   r$   r%   r&   U      z=TestSeriesConstructors.test_constructor_map.<locals>.<lambda>r   c                 S   r   r"   r$   r   r$   r$   r%   r&   \  r   r   rW   )mapre   r   r7   r<   r;   )r=   r~   r@   r   r$   r$   r%   test_constructor_mapS  s   z+TestSeriesConstructors.test_constructor_mapc                 C   s`   t g dg ddd}t|}t|j| tt g ddd}tg ddd}t|| d S )N)r   rR   rl   r   rR   rl   rN   rP   r   T)fastpathr   r   rT   )r   r   r7   assert_categorical_equalvaluesr<   )r=   catresr@   r?   r$   r$   r%   test_constructor_categoricala  s   z3TestSeriesConstructors.test_constructor_categoricalc                 C   s2   t tg ddd}t|sJ t|jsJ d S Nr   r   rT   )r   r   r
   rF   )r=   r   r$   r$   r%   *test_construct_from_categorical_with_dtypek  s   zATestSeriesConstructors.test_construct_from_categorical_with_dtypec                 C   s.   t g ddd}t|sJ t|jsJ d S r   )r   r
   rF   )r=   ri   r$   r$   r%   ,test_construct_intlist_values_category_dtypeq  s   zCTestSeriesConstructors.test_construct_intlist_values_category_dtypec                 C   sj  t g d}t|dd}|jdksJ t|t|ksJ t|j t| td|i}|d }t|| |j	d d df }t|| t|t|ksOJ t|j t| td|i}|d }t|| t|t|ksrJ t|j t| t||dd}|d }|d }t|| tj||d	d
 |j
dksJ t|t|ksJ t|j t| d S )N)rN   rP   rP   rN   rN   r   r   r   rU   rE   r   r   rR   rU   rV   CrV   F)check_names)r   r   rF   r:   r   r   r   r7   r<   r   rE   )r=   factorr   r   r@   result1result2r$   r$   r%   *test_constructor_categorical_with_coercionv  s:   



zATestSeriesConstructors.test_constructor_categorical_with_coercionc                 C   s   t ddgddgddggddgd}t|j|d< |jd j}|jjd }||ks*J |jd }||ks5J |jjd }||ksAJ d S )	NrR   zJohn P. Doerl   z	Jane Dove	person_idperson_name)columnsr   )r   r   r   r   loc)r=   r   r?   r@   r$   r$   r%   +test_constructor_categorical_with_coercion2  s   
zBTestSeriesConstructors.test_constructor_categorical_with_coercion2c                 C   s8   t g d}t |dd}t g ddd}t|| d S )Nr   r   rT   r   )r=   seriesr@   r?   r$   r$   r%   &test_constructor_series_to_categorical  s   z=TestSeriesConstructors.test_constructor_series_to_categoricalc                 C   s   t ddgtg dddd}t|jdu sJ t|jjtg d |jj	s)J t ddgtddgd}t|js<J t|jjtddg |jj	du sPJ t ddd	gtddgddd
}t ddgdd	gtddgddd
}t
|| d S )NrN   rP   r   T)orderedrT   Fr   rR   r   )r   r   r
   rF   r7   assert_index_equalr   
categoriesr   r  r<   r=   r@   r?   r$   r$   r%   "test_constructor_categorical_dtype  s"   z9TestSeriesConstructors.test_constructor_categorical_dtypec                 C   sd   t tddd}ttd|d}ttd|d}t|dd}t|| t|dd}t|| d S )NdabcT)r  r  abcabcrT   r   )r   rG   r   r   r7   r<   )r=   cdtr?   r   r@   r$   r$   r%   #test_constructor_categorical_string  s   z:TestSeriesConstructors.test_constructor_categorical_stringc                 C   s  t g d}t|dd}|j|usJ tjtdd g d|j_W d    n1 s+w   Y  tjg dtj	d}tjg dtj
d}t| | t| | d	|d
< tjg dtj	d}t| | t| | t g d}t|}|j|u sJ tjtdd g d|j_W d    n1 sw   Y  tjg dtj	d}t| | t| | d	|d
< tjg dtj	d}t| | t| | d S )N)rN   rP   r   rN   T)copyzUse rename_categoriesrB   r   )rR   rl   rd   rR   rT   rl   r   )rl   rl   rd   rR   )r   r   r   r7   r8   r9   r  rX   rY   r   rr   assert_numpy_array_equal	__array__r   )r=   r   r   exp_sexp_catexp_s2r$   r$   r%   !test_categorical_sideeffects_free  s6   z8TestSeriesConstructors.test_categorical_sideeffects_freec                 C   sD   t g dtddgd}t tddtjgddgd}t|| d S )Nr   rN   rP   rT   )r  )r   r   r   rX   r   r7   r<   )r=   r   r   r$   r$   r%   test_unordered_compare_equal  s   z3TestSeriesConstructors.test_unordered_compare_equalc                 C   s  t jdtd}t|}ttjtjtjg}t|| d|d< d|d< g d}t||d}tdtjdg|d}t|| d	|d
< t||d}tg d|d}t|| t jdtd}t|}ttjtjtjgtd}t|| d|d< d|d< g d}t||d}tdtjdg|td}t|| d
|d
< t||d}tg d|td}t|| t jdt	d}t|}ttjtjtjgt
d}t|| d|d< d|d< g d}t||d}tdtjdg|t
d}t|| d|d
< t||d}tg d|t	d}t|| t jddd}t|}ttttgdd}t|| tdd
d
|d< tdd
d|d< g d}t||d}ttdd
d
ttdd
dg|dd}t|| tdd
d|d
< t||d}ttdd
d
tdd
dtdd
dg|dd}t|| d S )Nrd   rT           r   r   rl   r   rW   r^   rR   )r  r^   r   r   r   TFTTFr     rd   )ma
masked_allr`   r   rX   r   r7   r<   ra   r   r   r   r   )r=   r2   r@   r?   r;   r$   r$   r%   test_constructor_maskedarray  s    z3TestSeriesConstructors.test_constructor_maskedarrayc                 C   s>   t jdtd }t|}ttjtjtjg}t|| d S )Nr  rT   )	r  r  r`   harden_maskr   rX   r   r7   r<   r=   r2   r@   r?   r$   r$   r%   %test_constructor_maskedarray_hardenedP  s   z<TestSeriesConstructors.test_constructor_maskedarray_hardenedc                 C   s:   t dddd}dd |D }t||d}|j|u sJ d S )N2009041520090519rV   r   c                 S   s   i | ]}|d qS rR   r$   )r*   kr$   r$   r%   
<dictcomp>Y  r/   zNTestSeriesConstructors.test_series_ctor_plus_datetimeindex.<locals>.<dictcomp>rW   )r   r   r;   )r=   rngr2   r@   r$   r$   r%   #test_series_ctor_plus_datetimeindexW  s   z:TestSeriesConstructors.test_series_ctor_plus_datetimeindexc                 C   s*   t g d}tj|jttddd d S )Nr   rd   T)exact)r   r7   r  r;   r   re   r=   r   r$   r$   r%   test_constructor_default_index^  s   z5TestSeriesConstructors.test_constructor_default_indexinputr   rd   )rN   rP   rN   c                 c   r(   r"   r$   r   r$   r$   r%   r,   i  r-   z TestSeriesConstructors.<genexpr>c                 C   r   r"   r$   r   r$   r$   r%   r&   j  r   c                 C   sJ   d}t jt|d t|tdd W d    d S 1 sw   Y  d S )Nz;Length of values \(3\) does not match length of index \(4\)rB   rm   rW   )rH   rI   rZ   r   rX   ru   )r=   r'  rK   r$   r$   r%   test_constructor_index_mismatchb  s   "z6TestSeriesConstructors.test_constructor_index_mismatchc                 C   s>   t tdtddd}t dtddd}t|| d S )Nd   rm   r   r   )r   rX   rY   ru   r7   r<   r  r$   r$   r%   test_constructor_numpy_scalaru  s   z4TestSeriesConstructors.test_constructor_numpy_scalarc                 C   sJ   d}t jt|d tdgg dd W d    d S 1 sw   Y  d S )Nz;Length of values \(1\) does not match length of index \(3\)rB   foor   rW   )rH   rI   rZ   r   r=   rK   r$   r$   r%   test_constructor_broadcast_list}  s   "z6TestSeriesConstructors.test_constructor_broadcast_listc                 C   s2   t  }||g}t|ddgd}t|tsJ d S )Nr   rR   rW   )r7   makeTimeDataFramer   r_   )r=   r   objsr   r$   r$   r%   test_constructor_corner  s   z.TestSeriesConstructors.test_constructor_cornerc                 C   s   t tg ddd}|jtdksJ d}tjt|d t tddtjgddd}W d    n1 s7w   Y  |jtd	ksFJ d S )
N)r^   r^   g       @rO   rT   z6float-dtype values containing NaN and an integer dtyperB   r^   Tr
  rF   r   )r   rX   rY   rF   r7   r8   r9   r   )r=   r   rK   ri   r$   r$   r%   test_constructor_sanitize  s   z0TestSeriesConstructors.test_constructor_sanitizec                 C   st   dgt dgfD ].}t|}t|dtd}t|| d|d< ||r'J |d dks/J |d dks7J q	d S )Nr^   Tr1  r   r   )rX   rY   r   r`   r7   r<   equals)r=   r2   r   yr$   r$   r%   test_constructor_copy  s   z,TestSeriesConstructors.test_constructor_copy20170101r   r   r   z1 day2012Q1Qr   c                 C   
   t | jS r"   typer   r   r$   r$   r%   r&     r3   )idsc                 C   s"   t |}|jjd j|usJ d S Nr   )r   _mgrblocksr   )r=   r;   r   r$   r$   r%   test_constructor_limit_copies  s   z4TestSeriesConstructors.test_constructor_limit_copiesc                 C   s   t t td tdd}W d    n1 sw   Y  |jtjks%J td tdtd}|jtj	ks6J t t tt
d gd}ttd gd}W d    n1 sWw   Y  t || d S )Nr   rW   r   )r7   r8   r9   r   re   rF   rX   r   r   rr   rY   r   r<   r=   r   r?   r$   r$   r%   test_constructor_pass_none  s   z1TestSeriesConstructors.test_constructor_pass_nonec                 C   s  t tjtjgtjd}|jtjksJ tt tjtjg| tt ttjtjg| t ttg}|jdks;J tt ttg| tt tttg| tt ttjg| tt tttjg| tt tjtg| tt ttjtg| d S )NrT   datetime64[ns])	r   rX   r   r   rF   r7   r<   rY   r   )r=   r   r$   r$   r%   test_constructor_pass_nan_nat  s    z4TestSeriesConstructors.test_constructor_pass_nan_natc                 C   sH   d}t jt|d tg dtd W d    d S 1 sw   Y  d S )Nz!could not convert string to floatrB   r   rT   )rH   rI   rZ   r   r`   r,  r$   r$   r%   test_constructor_cast  s   "z,TestSeriesConstructors.test_constructor_castc                 C   s   d}t str
ttfnt}tj||dd tg ddd}W d    n1 s'w   Y  tg ddd}t|| tj||dd tg ddd}W d    n1 sUw   Y  tg d	dd}t|| d S )
Nz*Values are too large to be losslessly castF)rC   check_stacklevel)rR      i2 int8rT   )rR   i2   uint8)rR   rI  rK  )r   r	   r9   DeprecationWarningr7   r8   r   r<   )r=   rK   warnsri   r?   r$   r$   r%   0test_constructor_signed_int_overflow_deprecation  s"   
zGTestSeriesConstructors.test_constructor_signed_int_overflow_deprecationr   rT   c                 C   s8   |d }t |}|d j|jksJ |d |ksJ d S r?  )r   rF   )r=   r   valuer@   r$   r$   r%   test_constructor_numpy_uints  s   z3TestSeriesConstructors.test_constructor_numpy_uintsc                 C   sF   d}t jt|d tdg|d W d    d S 1 sw   Y  d S )Nz5Trying to coerce negative values to unsigned integersrB   rT   )rH   rI   OverflowErrorr   )r=   any_unsigned_int_numpy_dtyperK   r$   r$   r%   (test_constructor_unsigned_dtype_overflow  s   "z?TestSeriesConstructors.test_constructor_unsigned_dtype_overflowc                 C   s  t jd}|tu r)||}||dd}t|| |t|dd}t|| n>d}tjt|d ||dd W d    n1 sCw   Y  tjt|d |t|dd W d    n1 sbw   Y  t j	|d< ||}d}tjt|d ||dd}W d    n1 sw   Y  t|| tjt|d |t|dd}W d    n1 sw   Y  t|| t j
dd	gd
d}||d}||dd}t|| |t|dd}t|| d S )Nrl   rO   rT   z/passing float-dtype values and an integer dtyperB   r   z>passing float-dtype values containing NaN and an integer dtyper^   r   r   )rX   rs   rt   r   r7   assert_equalrG   r8   r9   r   rY   r   )r=   frame_or_seriesarrr?   r   rK   r   r$   r$   r%   (test_constructor_floating_data_int_dtype  s>   
z?TestSeriesConstructors.test_constructor_floating_data_int_dtypec                 C   sP   g d}t ||d}t t||d}t|| t t|}t|| d S N)rR   rl   g      @rT   r   )r=   any_int_numpy_dtypevalsr   r?   altr$   r$   r%   "test_constructor_coerce_float_fail<  s   z9TestSeriesConstructors.test_constructor_coerce_float_failc                 C   s2   t g d|d}t g d|}t|| d S rZ  r   )r=   float_numpy_dtyper   r?   r$   r$   r%   #test_constructor_coerce_float_validH  s   z:TestSeriesConstructors.test_constructor_coerce_float_validc                 C   s   ddt jg}d}tjt|d t||d}W d    n1 s w   Y  tjt|d tt ||d}W d    n1 s@w   Y  t|| t |j	d sUJ d S )NrR   rl   z>In a future version, passing float-dtype values containing NaNrB   rT   rR  )
rX   r   r7   r8   r9   r   rY   r<   r   r   )r=   r[  r\  rK   r   r?   r$   r$   r%   3test_constructor_invalid_coerce_ints_with_float_nanM  s   zJTestSeriesConstructors.test_constructor_invalid_coerce_ints_with_float_nanc                 C   s6   t g d}t |tjd}d|d< |d dksJ d S )Nr   rT   r   rR   )r   rX   r   )r=   r   r   r$   r$   r%   test_constructor_dtype_no_castZ  s   z5TestSeriesConstructors.test_constructor_dtype_no_castc                 C   sN   t tddgtd}|jd tdksJ |jd dksJ |jtks%J d S )N20130101NOVrT   r   rR   )r   r   r   r   rF   r%  r$   r$   r%   "test_constructor_datelike_coercionb  s   z9TestSeriesConstructors.test_constructor_datelike_coercionc                 C   sn   d  }d  }d  }td  }t|||d|d}|jd }|jtks)J |jd }|jtks5J d S )	Nz216 3T19z	2T15 4H19z416 4T20z2016-01-22 2019-09-07)wing1wing2matrW   3T19216)splitpdto_datetimer   r   rF   r   )r=   bellyrf  rg  rh  r   r@   r$   r$   r%   #test_constructor_datelike_coercion2l  s   

z:TestSeriesConstructors.test_constructor_datelike_coercion2c                 C   sB   t ddtjg}||dd}|t dt dtg}t|| d S )Nr   r   r   rT   )r   r   rP  r7   rV  )r=   rW  r/  r@   r?   r$   r$   r%   (test_constructor_mixed_int_and_timestampz  s   z?TestSeriesConstructors.test_constructor_mixed_int_and_timestampc                 C   sP   t d d d d t d gt d d t d gfD ]}t|}|jdks%J qd S Nr   )rX   rY   r   nowr   rF   )r=   rX  r@   r$   r$   r%   %test_constructor_datetimes_with_nulls  s   z<TestSeriesConstructors.test_constructor_datetimes_with_nullsc                 C   s   t tdtdd}t| sJ t ttdd}t| r!J t tjdtdd}t| s3J t tdddddtgdd	}t|d sIJ |jdksPJ t tdddddtjgdd	}t|d sgJ |jdksnJ d S )
Nr   r   r   rW   r  rR   rl   r   rT   )	r   r   re   r   allrX   r   r   rF   r%  r$   r$   r%   !test_constructor_dtype_datetime64  s   z8TestSeriesConstructors.test_constructor_dtype_datetime64c                 C   s  t tdddt tdddt tdddg}t|}|jdks%J t j|jd< |jdks2J ttdddtdddtdddgdd}tt|t jd	 d
d}t	
|| t|dd}t	
|| tttdddtdddgdd}tt jg|dd   dd}t	
|| t|dd}|d d}tjt|d |d W d    n1 sw   Y  t|t jd}t|t j}t	
|| d S )Ni  rR   rl   rd   r   r   rE  rT   @B zM8[ms]r   zCcannot astype a datetimelike from \[datetime64\[ns\]\] to \[int32\]rB   r   )rX   
datetime64r   r   rF   r   r   viewr   r7   r<   r   r   rH   rI   rJ   )r=   datesr   r?   r@   dtsrK   r$   r$   r%   $test_constructor_dtype_datetime64_10  s<    
z;TestSeriesConstructors.test_constructor_dtype_datetime64_10c                 C   s`   t tdddg}|d tdddddksJ t tdddg}|d tdddddks.J d S )Nrl   rR   r   i  )r   r   r   r$   r$   r%   #test_constructor_dtype_datetime64_9  s    z:TestSeriesConstructors.test_constructor_dtype_datetime64_9c                 C   s@   t tddgddgd}|d tdksJ |d dksJ d S )Nrc  rR   rN   rP   rW   )r   r   r   r$   r$   r%   #test_constructor_dtype_datetime64_8  s   z:TestSeriesConstructors.test_constructor_dtype_datetime64_8c           	      C   s   t dddd}|tjd}t||d}dD ]}|tjd| d	}t||}t|| qt||td
}dD ]}|tjd| d	}t||td
}t|| q<tj	dd |
 D td}t||}t|j| |jtkszJ d S )Nz01-Jan-2015z01-Dec-2015Mr  rE  rW   )r   DmsusnszM8[]r   c                 S   s   g | ]}|  qS r$   )date)r*   r   r$   r$   r%   
<listcomp>  r4   zNTestSeriesConstructors.test_constructor_dtype_datetime64_7.<locals>.<listcomp>rT   )r   rx  rX   ndarrayr   r   r7   r<   r   rY   to_pydatetimer  r   rF   )	r=   ry  values2r?   rF   values1r@   dates2series1r$   r$   r%   #test_constructor_dtype_datetime64_7  s    

z:TestSeriesConstructors.test_constructor_dtype_datetime64_7c                 C   s4  d}t jt|d td tdg}W d    n1 sw   Y  |jdks'J t jt|d ttjtdg}W d    n1 sAw   Y  |jdksMJ t jt|d ttd dg}W d    n1 sfw   Y  |jdksrJ t jt|d tttjdg}W d    n1 sw   Y  |jdksJ d S )N containing strings is deprecatedrB   z2013-08-05 15:30:00.000001rE  )r7   r8   r9   r   r   rF   rX   r   )r=   rK   ri   r$   r$   r%   #test_constructor_dtype_datetime64_6  s"   z:TestSeriesConstructors.test_constructor_dtype_datetime64_6c                 C   s|   t ddd}t|jd jd u sJ t dddd}tt|jd jdks'J t dddd}tt|jd jdks<J d S )Nrc  rd   r8  r   UTCr7  r   )r   r   r   r   r   )r=   drr$   r$   r%   #test_constructor_dtype_datetime64_5  s    z:TestSeriesConstructors.test_constructor_dtype_datetime64_5c                 C   s@   t ddtg}|jdksJ |d tu sJ dt|v sJ d S )Nl   *}aiZlr   rl   r   )r   r   rF   r   r%  r$   r$   r%   #test_constructor_dtype_datetime64_4  s   z:TestSeriesConstructors.test_constructor_dtype_datetime64_4c                 C   sP   t tdddtdddtg}|jdksJ |d tu sJ dt|v s&J d S )N  rR   rl   r   r   )r   r   r   rF   r   r%  r$   r$   r%   #test_constructor_dtype_datetime64_3  s   z:TestSeriesConstructors.test_constructor_dtype_datetime64_3c                 C   sT   t tdddtdddtjg}|jdksJ |d tju s J dt|v s(J d S )Nr  rR   rl   r   rq   )r   r   rX   r   rF   r   r%  r$   r$   r%   #test_constructor_dtype_datetime64_2%  s    z:TestSeriesConstructors.test_constructor_dtype_datetime64_2c                 C   s  t dddd}t|}|jjdksJ |jdksJ t|js!J dt|v s)J |j}t|tj	s4J |jdks;J t
|}|dj|jjd}t|| |jd	 }|td
ddks_J |d	 }|td
ddksmJ |tg d|jd }t||d	d  |jd	d }t|t|d	d  t|jd	d |jdd  g}t|| dt|v sJ | }dt|v sJ dt|v sJ tt dddd}dt|v sJ t
|dd}t|| d S )Nrc  rd   r   r7  datetime64[ns, US/Eastern]rE  r  r   r   z2013-01-01 00:00:00-0500r  rW   rl   rR   r     inferr  )r   r   rF   rE   r   r   r   r_   rX   r  r   tz_localize
tz_convertdtr   r7   r  r   r   r;   r<   rl  concatshift)r=   r  r   r@   r   tr$   r$   r%   !test_constructor_with_datetime_tz,  s<   
"z8TestSeriesConstructors.test_constructor_with_datetime_tzc                 C   sD   t tdddtdddg}|jdksJ tj|dddks J d S )	N2013-01-01 13:00:00-0800
US/Pacificr  2013-01-02 14:00:00-0800zdatetime64[ns, US/Pacific]Tskipnarw  r   r   rF   r   infer_dtyper%  r$   r$   r%   "test_constructor_with_datetime_tz4`  s   

z9TestSeriesConstructors.test_constructor_with_datetime_tz4c                 C   sD   t tdddtdddg}|jdksJ tj|ddd	ks J d S )
Nr  r  r  r  r   r   Tr  r   r  r%  r$   r$   r%   "test_constructor_with_datetime_tz3k  s   

z9TestSeriesConstructors.test_constructor_with_datetime_tz3c                 C   s6   t tddgdd}t tddgdd}t|| d S )Nr   rR   r  r   r   r   r  )r   r   r   r7   r<   rC  r$   r$   r%   "test_constructor_with_datetime_tz2u  s   z9TestSeriesConstructors.test_constructor_with_datetime_tz2c                    sB   dt dddd gt t fddttD sJ d S )Nr   z
1990-01-01z2015-03-14T16:15:14.123-08:00z2019-03-04T21:56:32.620-07:00c                 3   s     | ]} | | u V  qd S r"   r$   r   ri   r\  r$   r%   r,     s    zVTestSeriesConstructors.test_constructor_no_partial_datetime_casting.<locals>.<genexpr>)r   r   rt  re   r:   r   r$   r  r%   ,test_constructor_no_partial_datetime_casting{  s   (zCTestSeriesConstructors.test_constructor_no_partial_datetime_casting	arr_dtypeM8m8unit)r  r  r  r   hr~   r  c                 C   sR   | d| d}t jg d|d}t|}||}t||}t|| d S )N[r  r   rT   )rX   rY   r   r   r7   r<   )r=   r  rF   r  rX  r   r@   r?   r$   r$   r%   &test_construction_to_datetimelike_unit  s   
z=TestSeriesConstructors.test_construction_to_datetimelike_unitargz2013-01-01 00:00:00c                 C   s2   t |gdd}t t|jd}t|| d S )Nzdatetime64[ns, CET]rT   CET)r   r   r  r  r7   r<   )r=   r  r@   r?   r$   r$   r%   7test_constructor_with_naive_string_and_datetimetz_dtype  s   zNTestSeriesConstructors.test_constructor_with_naive_string_and_datetimetz_dtypec                 C   sJ   t dd}t jt ddgdd}t|}tt|g}t|| d S )NrR   r  z>M8[ms]rT   )rX   rw  rY   r   r   r7   r<   )r=   r  rX  r@   r?   r$   r$   r%   %test_constructor_datetime64_bigendian  s
   z<TestSeriesConstructors.test_constructor_datetime64_bigendianinterval_constructorc                 C   sD   |j tddd}t|}|jdksJ tt|jt| d S )Nrd   r   closedzinterval[int64, right])	from_breaksrX   ru   r   rF   r7   r  r   r   )r=   r  	intervalsr@   r$   r$   r%   test_construction_interval  s   z1TestSeriesConstructors.test_construction_intervaldata_constructorrG   zndarray[object]c                 C   sL   t ddt ddd g}t||}tt|}|jdksJ t|| d S )Nr   rR   rl   zinterval[float64, right])r   r   r   rF   r7   r<   r=   r  r2   r@   r?   r$   r$   r%   test_constructor_infer_interval  s
   z6TestSeriesConstructors.test_constructor_infer_intervalc                 C   sJ   t ddddt ddddg}t||}|jtksJ | |ks#J d S )Nr   rR   bothr  rl   neither)r   r   rF   r   r   )r=   r  r2   r@   r$   r$   r%   &test_constructor_interval_mixed_closed  s   z=TestSeriesConstructors.test_constructor_interval_mixed_closedc                 C   sD  t tdddd}t ||jd}t|| t |jd|jd}t|| d}tjt|d t |j	|jd}W d    n1 sCw   Y  t|| td  t |j	j
d}|j|jj}W d    n1 sow   Y  t|| td  t |j	d	|jd}W d    n1 sw   Y  t|| d S )
Nrc  rd   r   r7  rT   r  z%will interpret the data as wall-timesrB   r   )r   r   rF   r7   r<   r  r  r8   r9   r   r  r   rx  )r=   ri   r@   rK   middler$   r$   r%   test_construction_consistency  s&   z4TestSeriesConstructors.test_construction_consistencyc                 C   sL   t ddt ddd g}t||}tt|}t|| |jdks$J d S )N2000r  2001	Period[D])r   r   r   r7   r<   rF   r  r$   r$   r%   test_constructor_infer_period  s
   z4TestSeriesConstructors.test_constructor_infer_periodz$PeriodDtype Series not supported yetreasonc                 C   sH   t dddtjjgdd}|d }t|sJ ||d< t|d s"J d S )Nr   r    z	period[D]rT   rd   rl   )r   rl  _libsr   r   r=   r   valr$   r$   r%   ;test_construct_from_ints_including_iNaT_scalar_period_dtype  s
   zRTestSeriesConstructors.test_construct_from_ints_including_iNaT_scalar_period_dtypec                 C   s>   t ddt ddg}t|}|jtksJ | |ksJ d S )Nr  r  r  rU   )r   r   rF   r   r   )r=   r2   r@   r$   r$   r%   .test_constructor_period_incompatible_frequency  s   zETestSeriesConstructors.test_constructor_period_incompatible_frequencyc                 C   sB   t dddd}t|}|jdksJ t|t}t|| d S )Nrc  r   r  r   r  )r   r   rF   r   r   r7   r<   )r=   pir   r?   r$   r$   r%   test_constructor_periodindex  s
   z3TestSeriesConstructors.test_constructor_periodindexc                 C   s   dddd}t |}t |t| d}t|| t |g dd}t ddtjd	gg dd}t|| td
}|d	 d	|d di}t ||d}t tj|tjd}d	|j	d	< d|j	d< t|| d S )Nr  r^   r   r   rW   )rP   r   r   rN   rR   rl   r   r)  rT   )
r   r   keysr7   r<   rX   r   makePeriodIndexr   r   )r=   r   r@   r?   pidxr$   r$   r%   test_constructor_dict  s   


z,TestSeriesConstructors.test_constructor_dictc                 C   sB   ddgdgdggi}t |dgdd}t |dgd}t|| d S )NrN   rl   rd   rm   r   r   rW   r   r=   r   r@   r?   r$   r$   r%   /test_constructor_dict_list_value_explicit_dtype  s   zFTestSeriesConstructors.test_constructor_dict_list_value_explicit_dtypec                 C   s8   dddd}t |}t g dtdd}t|| d S )NrR   r   rl   r   )rR   r   rl   bacrW   )r   rG   r7   r<   r  r$   r$   r%   test_constructor_dict_order  s   z2TestSeriesConstructors.test_constructor_dict_orderc                 C   sL   |\}}d|i}t |dgd}t |dg|d}|j|ksJ t|| d S )NrN   rW   r   )r   rF   r7   r<   )r=   rf   rg   rh   r   r@   r?   r$   r$   r%   test_constructor_dict_extension&  s   z6TestSeriesConstructors.test_constructor_dict_extensionrP  c                 C   s   dd|dt ddddi}t| }tg dd|tjdgd	}t|| d
ddtjfdd|fdi}t| }tg dtd
dtjfd|fgd	}t|| d S )NrR   rN   rP   r   r   rm   r   rN   rP   r   r   rW   rR   rR   rl   rd   r   )r`   r   sort_valuesrX   r   r7   r<   r   )r=   rP  r   r@   r?   r$   r$   r%   test_constructor_dict_nan_key0  s   z4TestSeriesConstructors.test_constructor_dict_nan_keyc           	         s   g d g d fdd}|t j}|dd }|t}tdd  D }t|}t|}t|}t|| t|| t|| d S )	N)z
1984-02-19z
1988-11-06z
1989-12-03z
1990-03-15)g{\IAi gtyZQArR  c                    s   t t fddD S )Nc                 3   s    | ]} |V  qd S r"   r$   r*   r   r>   r$   r%   r,   G      zeTestSeriesConstructors.test_constructor_dict_datetime64_index.<locals>.create_data.<locals>.<genexpr>)dictzipr  dates_as_strr   r  r%   create_dataF  s   zRTestSeriesConstructors.test_constructor_dict_datetime64_index.<locals>.create_datac                 S   s   t | dS )Nz%Y-%m-%d)r   strptimer   r$   r$   r%   r&   J  s    zOTestSeriesConstructors.test_constructor_dict_datetime64_index.<locals>.<lambda>c                 s   s    | ]}t |V  qd S r"   )r   r  r$   r$   r%   r,   M  r  zPTestSeriesConstructors.test_constructor_dict_datetime64_index.<locals>.<genexpr>)rX   rw  r   r   r7   r<   )	r=   r  data_datetime64data_datetimedata_Timestampr?   result_datetime64result_datetimeresult_Timestampr$   r  r%   &test_constructor_dict_datetime64_index@  s   
z=TestSeriesConstructors.test_constructor_dict_datetime64_indexc                 C   sN   ddi}t |}t dtdgdgtjggdgdgdggdd}t|| d S )N)rR   rR   Ng      rR   r   rR  )levelscodesrW   )r   r   rX   r   r7   r<   r  r$   r$   r%   #test_constructor_dict_tuple_indexerW  s   &z:TestSeriesConstructors.test_constructor_dict_tuple_indexerc                 C   s4   |ddi}t |}t dgdgd}t|| d S )Nrd   threerW   r   )r=   non_dict_mapping_subclassndmr@   r?   r$   r$   r%   test_constructor_mapping`  s   z/TestSeriesConstructors.test_constructor_mappingc                 C   s$   g d}t |}t||ksJ d S N)r  )rl   rl   )rl   rd   )r   rG   r=   r2   r   r$   r$   r%   test_constructor_list_of_tuplesh  s   z6TestSeriesConstructors.test_constructor_list_of_tuplesc                 C   s    d}t |}t||ksJ d S r  )r   tupler  r$   r$   r%    test_constructor_tuple_of_tuplesm  s   z7TestSeriesConstructors.test_constructor_tuple_of_tuplesc                 C   s@   ddd}t | }t ddgtddgd}t|| d S )Nrd   r   )rR   rl   Nr   r  r  rW   )r   r  r   from_tuplesr7   r<   r  r$   r$   r%   test_constructor_dict_of_tuplesr  s   
z6TestSeriesConstructors.test_constructor_dict_of_tuplesz+ignore:elementwise comparison:FutureWarningc                 C   s   ddddd}t |}t|j dddt d}t |}|jtjks&J ddddd}t |}|jtjks9J d	dd
}t |t	d}|jtj
ksLJ d S )Nr   rR   rl   rd   r  r   r   30rN   rP   rT   )r   r7   assert_is_sortedr;   r   rr  rF   rX   rr   r`   r   )r=   r2   r   r$   r$   r%   test_fromDicty  s   
z$TestSeriesConstructors.test_fromDictc                 C   s   t tj|jtjd}|jtjksJ t|t|ksJ t d|jd}|jtjks+J t|t|ks5J t	
 }t ||jd}|jdksGJ t|t|ksQJ t d|jdd}t d|jdd}|jdksjJ t|t|kstJ t|| d S )Nr   r+  rW   r   r   r   )r   rX   rq   r;   r   rF   float_r:   rr   r   rr  r   r7   r<   )r=   rx   nansstringsr   ry  categoricalr?   r$   r$   r%   test_fromValue  s   z%TestSeriesConstructors.test_fromValuec                 C   s  t dd tdD }|jdksJ t tddg}|jdks!J t tddtddtddg}|jdks9J t tddtgd	d
}|jdksKJ t tddtjgd	d
}|jdks^J t tdtgd	d
}|jdkspJ t tdtg}|jdksJ t tdtg}|jdksJ t tdtjg}|jdksJ t ttdg}|jdksJ t tddg}|jdksJ |	d d}t
jt|d |	d W d    n1 sw   Y  dddg}t
jt|d t tdddgd	d
 W d    n	1 s	w   Y  t dd tdD dg }|jdks$J d}tjt|d t d tdg}W d    n	1 s@w   Y  |jdksMJ tjt|d t tjtdg}W d    n	1 shw   Y  |jdksuJ tjt|d t td dg}W d    n	1 sw   Y  |jdksJ tjt|d t ttjdg}W d    n	1 sw   Y  |jdksJ d S )Nc                 S      g | ]}t |d qS daysr   r   r$   r$   r%   r        zMTestSeriesConstructors.test_constructor_dtype_timedelta64.<locals>.<listcomp>rd   timedelta64[ns]rR   r  rl   r   r   rT   i r   r   zDcannot astype a datetimelike from \[timedelta64\[ns\]\] to \[int32\]rB   r   |z+Could not convert object to NumPy timedeltaz*Could not convert 'foo' to NumPy timedeltar+  c                 S   r  r  r  r   r$   r$   r%   r    r  r  z1 Day)r   re   rF   r   rX   timedelta64r   r   r   r   rH   rI   rJ   joinrZ   r7   r8   r9   )r=   tdrK   ri   r$   r$   r%   "test_constructor_dtype_timedelta64  sl   "
z9TestSeriesConstructors.test_constructor_dtype_timedelta64c                 C   sD   t tdtdddg}t tdtdddgdd}t|| d S )Nrc  r   r  r   rT   )r   r   r7   r<   rC  r$   r$   r%   test_constructor_mixed_tz  s   z0TestSeriesConstructors.test_constructor_mixed_tzc                 C   sD   t dddtgdd}|d }t|sJ ||d< t|d s J d S )Nr   r  r  r   rT   rd   rl   )r   r   r   r  r$   r$   r%   test_NaT_scalar  s
   z&TestSeriesConstructors.test_NaT_scalarc                 C   s,   t tjgd}t tg}t|| d S rq  )r   rX   r   r   r   r7   r<   r  r$   r$   r%   test_NaT_cast  s   
z$TestSeriesConstructors.test_NaT_castc                 C   s\   dddt dddddfD ]}g dtd	d
ddfD ]}t||d}|j|ks*J qqd S )Ni	  g     H@rE   r     r  u   אr   rd   r   rR   r  r   )r   rX   onesr   rE   )r=   nr2   r   r$   r$   r%   test_constructor_name_hashable  s   z5TestSeriesConstructors.test_constructor_name_hashablec              
   C   sz   d}dgt dddifD ]-}dgt dddifD ]}tjt|d t||d W d    n1 s4w   Y  qqd S )Nz$Series\.name must be a hashable type	name_listrl   rR   rB   r   )rX   r  rH   rI   rJ   r   )r=   rK   r  r2   r$   r$   r%    test_constructor_name_unhashable  s   z7TestSeriesConstructors.test_constructor_name_unhashablec                 C   s&   t ttddd}|jdksJ d S )N1/1/2000r   r8  r   )r   rG   r   rF   r=   r   r$   r$   r%   test_auto_conversion  s   z+TestSeriesConstructors.test_auto_conversionc                 C   s   t jg ddd}t|}ttdddd}t|| t jg dd	d}t|}ttd
ddd}t|| t jg ddd}t|}ttdddd}t|| d S )Nr   timedelta64[s]rT   z00:00:01rd   r   r   )
2013-01-01z
2013-01-02z
2013-01-03zdatetime64[D]rc  r  )z2013-01-01 00:00:01z2013-01-01 00:00:02z2013-01-01 00:00:03zdatetime64[s]z20130101 00:00:01)rX   rY   r   r   r7   r<   r   )r=   rX  r   r?   ri   r$   r$   r%   test_convert_non_ns  s"   z*TestSeriesConstructors.test_convert_non_nsr   r   z2000-Q1c                 C   r;  r"   r<  r   r$   r$   r%   r&   ;  r3   c                 C   s   dt |jd d}tjt|d t|td W d    n1 s$w   Y  t|tj	d}t|
tj	}t|| d S )NzCannot cast r   z.*? to rB   rT   )r=  r   rstriprH   rI   rJ   r   r`   rX   r   r   r7   r<   )r=   r;   rK   r@   r?   r$   r$   r%   'test_constructor_cant_cast_datetimelike4  s   z>TestSeriesConstructors.test_constructor_cant_cast_datetimelikec                 C   r;  r"   r<  r   r$   r$   r%   r&   V  r3   c                 C   s   t |td}t |t}t|| t t|tdtd}t |t}t|| t |ttd}t |t}t|| d S r   )r   r   r   r7   r<   r   )r=   r;   r   r   r$   r$   r%   test_constructor_cast_objectO  s   
z3TestSeriesConstructors.test_constructor_cast_objectc                 C   sn   d}t |jdvrtjjdd}|j| tjt	|d t
g |d W d    d S 1 s0w   Y  d S )Nz!dtype has no unit. Please pass in)r  rw  zGH#33890 Is assigned ns unitr  rB   rT   )rX   rF   rE   rH   markxfailnode
add_markerrI   rZ   r   )r=   rF   requestrK   r)  r$   r$   r%   /test_constructor_generic_timestamp_no_frequencye  s   "zFTestSeriesConstructors.test_constructor_generic_timestamp_no_frequencyz	dtype,msg)zm8[ps]zcannot convert timedeltalike)zM8[ps]zcannot convert datetimelikec                 C   s@   t jt|d tg |d W d    d S 1 sw   Y  d S )NrB   rT   )rH   rI   rJ   r   )r=   rF   rK   r$   r$   r%   0test_constructor_generic_timestamp_bad_frequencyq  s   
"zGTestSeriesConstructors.test_constructor_generic_timestamp_bad_frequency)NrL  r   c                 C   s4   t g d|pdd}t td|d}t|| d S )N)r   rR   rl   rd   rm   r   rT   r   r   )r=   rF   r?   r@   r$   r$   r%   test_constructor_range_dtype~  s   z3TestSeriesConstructors.test_constructor_range_dtypec                 C   sH  t dd}t|}tt|}t|| t|t|ksJ |jtjks'J t ddd}t|}tt|}t|| t|t|ksGJ |jtjksOJ t ddd}t|}tt|}	t||	 t|t|ksoJ |jtksvJ t dd dd d }
t|
}tt|
}t|| t|t|
ksJ |jtksJ d S )	Nl            l           rR  l         l        rl   I   rm   )	re   r   rG   r7   r<   rF   rX   uint64r   )r=   r"  ri   r?   rng2ser2	expected2rng3ser3	expected3rng4ser4	expected4r$   r$   r%    test_constructor_range_overflows  s0   
z7TestSeriesConstructors.test_constructor_range_overflowsc                 C   s8   t dt dddg}t|}t|td}t|| d S )Nz2016-05-01 02:03:37z2016-04-30 19:03:37-0700r  r  rT   )r   r   r   r7   r<   )r=   dt_listr@   r?   r$   r$   r%   test_constructor_tz_mixed_data  s   
z5TestSeriesConstructors.test_constructor_tz_mixed_datapydtc                 C   sP  |}t d|d}|r| }t d}tt t|gdd}W d    n1 s)w   Y  t|g}t|| tt ttj|gt	ddd}W d    n1 sUw   Y  t|| tt td|idd}W d    n1 sxw   Y  t|| tt t|dgdd}W d    n1 sw   Y  t|| d S )N2019r  rE  rT   r   r   )
r   r  r7   r8   r9   r   r<   rX   rY   r   )r=   tz_aware_fixturer?  r   tsts_naiver@   r?   r$   r$   r%   'test_constructor_data_aware_dtype_naive  s,   
z>TestSeriesConstructors.test_constructor_data_aware_dtype_naivec                 C   s<   t dddd}t|}t|}t|jtdsJ d S )Nz1/1/2000 00:00:00z1/1/2000 1:59:5010sr  r   )r   rX   asarrayr   
issubdtyperF   )r=   r"  ry  r   r$   r$   r%   test_constructor_datetime64  s   
z2TestSeriesConstructors.test_constructor_datetime64c                 C   s8   t dg d|d}t g dg d|d}t|| d S )Nr~  r   r   )r~  r~  r~  r   )r=   nullable_string_dtyper@   r?   r$   r$   r%   4test_constructor_datetimelike_scalar_to_string_dtype  s   zKTestSeriesConstructors.test_constructor_datetimelike_scalar_to_string_dtypez
2012-01-01r$  c                 C   s>   t d}t||d}t jj||d}t|}t|| d S )NrE  rT   )rl  SparseDtyper   arraysSparseArrayr7   r<   )r=   r   rF   r@   rX  r?   r$   r$   r%   "test_constructor_sparse_datetime64  s
   
	z9TestSeriesConstructors.test_constructor_sparse_datetime64c                 C   sX   t ddd }t ddg}t|| t ddd }t ddg}t|| d S )NrR   rl   r  rN   rP   )r   r  r7   r<   r   r  r$   r$   r%   )test_construction_from_ordered_collection  s   z@TestSeriesConstructors.test_construction_from_ordered_collectionc                 C   s*   d}t |dgd}t |}t|| d S )Nl     @=7M.cr   rW   r   )r=   r  r@   r?   r$   r$   r%   3test_construction_from_large_int_scalar_no_overflow  s   zJTestSeriesConstructors.test_construction_from_large_int_scalar_no_overflowc                 C   sR   t ttdddd}|jdksJ t tdddtdddg}|jdks'J d S )	Nz
2000-01-01r   r  r   r  z
2011-01-01r  z
2011-02-01)r   rG   r   rF   r   r!  r$   r$   r%   4test_constructor_list_of_periods_infers_period_dtype  s   zKTestSeriesConstructors.test_constructor_list_of_periods_infers_period_dtypec                 C   s>   |dd t dD }t|}tt| }t|| d S )Nc                 s   s    | ]	}|d | fV  qdS )g      $@Nr$   r  r$   r$   r%   r,      s    zHTestSeriesConstructors.test_constructor_subclass_dict.<locals>.<genexpr>r   )re   r   r  itemsr7   r<   )r=   dict_subclassr2   r   r?   r$   r$   r%   test_constructor_subclass_dict  s   z5TestSeriesConstructors.test_constructor_subclass_dictc                 C   sp   t dd tdD }t|}tt| t| }t|| G dd dt }t||}t|| d S )Nc                 s   s$    | ]}d | t j fV  qdS )colN)rX   rs   r   r$   r$   r%   r,     s   " zFTestSeriesConstructors.test_constructor_ordereddict.<locals>.<genexpr>   c                   @   s   e Zd ZdS )z>TestSeriesConstructors.test_constructor_ordereddict.<locals>.AN)r   r   r   r$   r$   r$   r%   rU     s    rU   )r   re   r   rG   r   r  r7   r<   )r=   r2   r   r?   rU   r$   r$   r%   test_constructor_ordereddict  s   z3TestSeriesConstructors.test_constructor_ordereddictc                 C   s   dddd}t | }t|}tdd |D tdd |D d}t|| d	|d
< |dd
|d
 f t|}tdd |D tdd |D ddd}|j	|j
d}t|| d S )Nr  r^   r   ))rN   rN   )rP   rN   )rP   r   c                 S      g | ]}|d  qS r  r$   r  r$   r$   r%   r    r4   zKTestSeriesConstructors.test_constructor_dict_multiindex.<locals>.<listcomp>c                 S   rX  r   r$   r  r$   r$   r%   r    r4   rW   g     [@zr   c                 S   rX  r  r$   r  r$   r$   r%   r  !  r4   c                 S   rX  rY  r$   r  r$   r$   r%   r  !  r4   F)tupleize_cols)r   rR  r   r   r  r7   r<   insertr   reindexr;   )r=   r   _dr@   r?   r$   r$   r%    test_constructor_dict_multiindex  s    z7TestSeriesConstructors.test_constructor_dict_multiindexc                 C   sB   dddt jd}t|}t|d d  |jd}t|| d S )Nr   rR   rl   ))r   r   )r   j)r`  r   r`  rR  rW   )rX   r   r   to_dictr;   r7   r<   )r=   r2   r?   r@   r$   r$   r%   -test_constructor_dict_multiindex_reindex_flat&  s   zDTestSeriesConstructors.test_constructor_dict_multiindex_reindex_flatc              	   C   sr   t g dtjg dddd}t tjddddtjdddd	tjd
ddditjg dddd}t|| d S )Nr   )r   r   r   r   r  r2   r;   r   rU   r   rV   r   r   r   rl  to_timedeltar7   r<   r   r$   r$   r%   %test_constructor_dict_timedelta_index.  s   z<TestSeriesConstructors.test_constructor_dict_timedelta_indexc                 C   sd   ddg}t d d}tdddd|dtdddd|dg}t||d	}|jj|ks)J t|jd
  d S )Ng     g@g     t@i   i  r   r  )tzinforV  rd  r   )r   r   r   r;   r   repr)r=   r   rh  r;   r   r$   r$   r%   test_constructor_infer_index_tz@  s   
z6TestSeriesConstructors.test_constructor_infer_index_tzc                 C   s4   g d}t |}|jj}t ||d}t|| d S )N)r  )rl   r  rT   )r   rY   rF   r7   r<   )r=   r\  ri   rF   r4  r$   r$   r%   "test_constructor_with_pandas_dtypeN  s
   z9TestSeriesConstructors.test_constructor_with_pandas_dtypec                 C   s0   t dgdd}t tjdgdd}t|| d S )Nr   r   r   r   )r   rX   r   r7   r<   r  r$   r$   r%   )test_constructor_int_dtype_missing_valuesV  s   z@TestSeriesConstructors.test_constructor_int_dtype_missing_valuesc                 C   s.   t dgdd}t ddgdd}t|| d S )Nr   r   r   Tr   r  r$   r$   r%   *test_constructor_bool_dtype_missing_values\  s   zATestSeriesConstructors.test_constructor_bool_dtype_missing_valuesc                 C   s6   t g ddd}t tjg ddd}t|| d S )Nrv  i@ i- r  rT   r  rc  re  r  r$   r$   r%   6test_constructor_dtype_timedelta_alternative_constructb  s   zMTestSeriesConstructors.test_constructor_dtype_timedelta_alternative_constructc                 C   s0   t g ddd}t g ddd}t|| d S )Nrn  r  rT   r#  r   r  r$   r$   r%   %test_constructor_dtype_timedelta_ns_sh  s   z<TestSeriesConstructors.test_constructor_dtype_timedelta_ns_sc                 C   s<   t g dddd}t g dddd}t|| d S )Nrn  r  rT   r   r#  r   r  r$   r$   r%   2test_constructor_dtype_timedelta_ns_s_astype_int64n  s   zITestSeriesConstructors.test_constructor_dtype_timedelta_ns_s_astype_int64z7ignore:elementwise comparison failed:DeprecationWarningfuncc              	   C   sd   d g d}tjtg D ]"}tjt|d ||ddg|d W d    n1 s*w   Y  qd S )Nr  )z(cannot safely cast non-equivalent objectzJint\(\) argument must be a string, a bytes-like object or a (real )?numberz[Cannot cast array data from dtype\('O'\) to dtype\('float64'\) according to the rule 'safe'z-object cannot be converted to a FloatingDtypez 'values' contains non-numeric NArB   r^   g      @rT   )r  r7   NP_NAT_OBJECTSr   rH   rI   rJ   )r=   rr  any_numeric_ea_dtyperK   nullr$   r$   r%   /test_constructor_mismatched_null_nullable_dtypex  s   zFTestSeriesConstructors.test_constructor_mismatched_null_nullable_dtype)r   r   r   rH   r)  parametrizerA   rM   r]   rc   rj   r   r   rG   r  r   r   rX   r   r`   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r  r  r#  r&  re   r   r   r(  r*  r-  r0  r2  r5  r  skip_array_manager_invalid_testr   r   r   r   rB  rD  rF  rG  rO  rY   uint16uint32r2  rQ  rU  rY  r^  r`  ra  rb  re  ro  rp  rs  ru  r{  r|  r}  r  r  r  r  r  r  r  r  r  r  r  r   r   r  r   r  r  r   r   r  r  r  r  r  r*  r  r  r  r  r  r  r  r  r  r  r  r  r  r   filterwarningsr  r
  r  r  r  r  r  r  r"  r%  r'  r(  rw  r  r.  r/  r0  r<  r>  rD  rH  rJ  rN  rO  rP  rQ  rT  rW  r_  rb  rg  rj  rk  rl  rm  ro  rp  rq  r   r   rl  rv  r$   r$   r$   r%   r!   6   s   











	
%
$



	



%	$M


	



	



/
	1
4

	




	
	


	R			


	
r!   c                   @   s   e Zd Zdd Zdd ZdS )"TestSeriesConstructorIndexCoercionc                 C   sp   t d}ttjt||t}t 	t
 |jjsJ W d    n1 s)w   Y  t|jts6J d S )Ni'  )r7   makeDateIndexr   rX   rs   rt   r:   r   r   r8   r9   r;   is_all_datesr_   r   )r=   idxri   r$   r$   r%   3test_series_constructor_datetimelike_index_coercion  s   
zVTestSeriesConstructorIndexCoercion.test_series_constructor_datetimelike_index_coercionc                 C   sv   g dg dg}t ddd |D d}t|jtsJ t d|d}t|jts)J t td|d}t|jts9J d S )N)rN   rN   rP   rP   )r   r4  r   r4  r^   c                 S   s   g | ]}t |qS r$   )rX   rY   r  r$   r$   r%   r    r  z_TestSeriesConstructorIndexCoercion.test_series_constructor_infer_multiindex.<locals>.<listcomp>rW   rm   )r   r_   r;   r   re   )r=   index_listsmultir$   r$   r%   (test_series_constructor_infer_multiindex  s   zKTestSeriesConstructorIndexCoercion.test_series_constructor_infer_multiindexN)r   r   r   r  r  r$   r$   r$   r%   r|    s    r|  c                   @   s0   e Zd Zdd Zejdd Zejdd ZdS )TestSeriesConstructorInternalsc                 C   sD   t g d}t |j}t|| |st|jjd ts J d S d S )Nr   r   )r   rY   r7   r<   r_   r@  rA  r    )r=   using_array_managerri   r@   r$   r$   r%    test_constructor_no_pandas_array  s   
z?TestSeriesConstructorInternals.test_constructor_no_pandas_arrayc                 C   sZ   t tjddgdd}|jjd jdu sJ t tjdgdd}|jjd jdu s+J d S 	N1H2Hr  rT   r   F2015rE  )r   rl  rY   r@  rA  is_extensionr   r$   r$   r%   test_from_array  s   z.TestSeriesConstructorInternals.test_from_arrayc                 C   sN   t ddgdd}|jjd jdu sJ t dgdd}|jjd jdu s%J d S r  )r   r@  rA  r  r   r$   r$   r%   test_from_list_dtype  s   z3TestSeriesConstructorInternals.test_from_list_dtypeN)r   r   r   r  r  rx  r  r  r$   r$   r$   r%   r    s    
r  c                 C   s&   | }t |ts	J t |jtsJ d S r"   )r_   r   r;   r   )(rand_series_with_duplicate_datetimeindexdupsr$   r$   r%   r     s   r   zinput_dict,expectedrT   rN   rR   c                 C   s    t t| g}t|| d S r"   )rX   rY   r   r7   r  )
input_dictr?   r@   r$   r$   r%   test_numpy_array  s   	r  )Acollectionsr   r   r   dateutil.tzr   numpyrX   numpy.mar  rH   pandas._libsr   r   pandas.compatr   pandas.compat.numpyr	   pandas.util._test_decoratorsutil_test_decoratorsr  pandas.core.dtypes.commonr
   r   pandas.core.dtypes.dtypesr   pandasrl  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   pandas._testing_testingr7   pandas.core.apir   pandas.core.arraysr   r   pandas.core.internals.blocksr    r!   r|  r  r   r)  rw  rY   r   r   r  r$   r$   r$   r%   <module>   sX    H              i