a
    PfM                 
   @   s  d dl mZ 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 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*m+Z+ d dl,m-Z. d dl/m0Z0m1Z1m2Z2 d dl3m4Z4 G dd dZ5G dd dZ6G dd dZ7dd Z8ej9: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d Z?ej9:dde@dd gd!e@dd"ggd#d$ ZAdS )%    )OrderedDict)Iterator)datetime	timedelta)tzoffsetN)ma)iNaTlib)np_version_gt2)IntCastingNaNError)CategoricalDtype)Categorical	DataFrameDatetimeIndexDatetimeTZDtypeIndexIntervalIntervalIndex
MultiIndexNaTPeriod
RangeIndexSeries	Timestamp
date_rangeisnaperiod_rangetimedelta_range)IntegerArrayIntervalArrayperiod_array)
NumpyBlockc                   @   s
  e Zd Zdd Zdd Zdd Zdd Zej	d	d
d dd dd dd dd dd dd dd dd dd dd gej	ddg 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d0d1 Zd2d3 Zd4d5 Zej	d6g d7d8d9 Zd:d; Zd<d= Zd>d? Z d@dA Z!dBdC Z"dDdE Z#dFdG Z$ej	d-g dHdIdJ Z%ej	dKdLdMgdNdOgee&dPdMdQdRee&dPdMdQdSdTe'dUdVdWggdXdY Z(dZd[ Z)d\d] Z*d^d_ Z+d`da Z,dbdc Z-ddde Z.dfdg Z/dhdi Z0djdk Z1dldm Z2dndo Z3dpdq Z4drds Z5dtdu Z6dvdw Z7dxdy Z8dzd{ Z9ej	d|g d}d}ee:d~e;g ddd e:d~D dd e:d~D gdd Z<dd Z=dd Z>dd Z?dd Z@dd ZAeBjCejj	d/e&dd~dSde&dd~deDdd~deEdd~ddReedeg d}eFdUd~gdd ddd ZGdd ZHdd ZIdd ZJdd ZKdd ZLej	dejMdLgejNdejMdLgejOdejMdLgejPdeNdLgeOdLgePdLggdd 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ӄ ZgddՄ Zhddׄ Ziddل Zjddۄ Zkdd݄ Zlej	dejmejngej	dddgej	dg ddd Zoej	ddepejdgdd Zqdd Zrej	desetgdd Zuejj	deejMgddgddd Zvejj	deejMgddgddd Zwdd Zxejj	deejMgddgddd Zyejjzdddd Z{dd Z|d d Z}dd Z~dd Zdd Zdd	 Zej	d
dMejded*gdd 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eDdd/deEd0d/ddRgd1d dd2d3 Zejj	d/e&d.d/deDdd/deEd0d/ddRgd4d dd5d6 Zej	d-ejejgd7d8 Zej	dg d9ej	dddgd:d; Zej	d-g d<d=d> Zd?d@ ZdAdB Zej	dCdDdEgdFdG ZdHdI ZdJdK Zej	dedLedMgdLdMgg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_ Zd`da Zdbdc Zddde Zdfdg Zdhdi Zdjdk Zdldm Zejjzdnddodp Zejjzdnddqdr Zejdsej	dteeeejMgdudv Zdwdx Zdydz Zej	d{dLd|gd}d~ Zej	d{dLd|gdd Zdd Zdd Zdd Zdd Zej	ddejejgdd Zdd Zdd Zdd Zdd ZÐdd ZĐdd ZdS (  TestSeriesConstructorsc                 C   sP   t d}||dd}||d}t|| |t|dd}t|| d S )N
   M8[s]dtype)nparangeastypetmassert_equallist)selfZindex_or_seriesvaluesresexpected r1   ^/var/www/ai-form-bot/venv/lib/python3.9/site-packages/pandas/tests/series/test_constructors.py'test_from_ints_with_non_nano_dt64_dtype5   s    
z>TestSeriesConstructors.test_from_ints_with_non_nano_dt64_dtypec                 C   s0   t d gdd}|  sJ |jdks,J d S )Nzinterval[datetime64[ns]]r%   zinterval[datetime64[ns], right])r   r   allr&   r-   serr1   r1   r2   1test_from_na_value_and_interval_of_datetime_dtype?   s    zHTestSeriesConstructors.test_from_na_value_and_interval_of_datetime_dtypec                 C   s`   t ddd}| | g}t|}t|td}t|| t|}t|td}t|| d S )Ni     r%   )	r   to_pydatetimedater   objectr*   assert_series_equalr   assert_index_equal)r-   tsvalsr6   r0   idxr1   r1   r2   !test_infer_with_date_and_datetimeE   s    z8TestSeriesConstructors.test_infer_with_date_and_datetimec                 C   s   dg}d}t jt|d t|dd W d    n1 s:0    Y  t jt|d& ttj|tddd W d    n1 s~0    Y  d S )NZaazD^Unknown datetime string format, unable to parse: aa, at position 0$matchdatetime64[ns]r%   )pytestraises
ValueErrorr   r'   arrayr;   )r-   r?   msgr1   r1   r2   'test_unparsable_strings_with_dt64_dtypeS   s    *z>TestSeriesConstructors.test_unparsable_strings_with_dt64_dtypeconstructorc                 C   s
   t | dS Nindexr   r@   r1   r1   r2   <lambda>d       zTestSeriesConstructors.<lambda>c                 C   s   t d | dS rL   rO   rP   r1   r1   r2   rQ   e   rR   c                 C   s   t i | dS rL   rO   rP   r1   r1   r2   rQ   f   rR   c                 C   s   t d| dS )Nr1   rM   rO   rP   r1   r1   r2   rQ   g   rR   c                 C   s   t g | dS rL   rO   rP   r1   r1   r2   rQ   h   rR   c                 C   s   t dd dD | dS )Nc                 s   s   | ]
}|V  qd S Nr1   .0_r1   r1   r2   	<genexpr>i   rR   2TestSeriesConstructors.<lambda>.<locals>.<genexpr>r1   rM   rO   rP   r1   r1   r2   rQ   i   rR   c                 C   s   t d | dS NdatarN   rO   rP   r1   r1   r2   rQ   j   rR   c                 C   s   t i | dS rY   rO   rP   r1   r1   r2   rQ   k   rR   c                 C   s   t d| dS )Nr1   rZ   rO   rP   r1   r1   r2   rQ   l   rR   c                 C   s   t g | dS rY   rO   rP   r1   r1   r2   rQ   m   rR   c                 C   s   t dd dD | dS )Nc                 s   s   | ]
}|V  qd S rS   r1   rT   r1   r1   r2   rW   n   rR   rX   r1   rZ   rO   rP   r1   r1   r2   rQ   n   rR   empty_indexNc                 C   sF   t |d}||}|jtks J t|jdks2J tj||dd d S )NrM   r   TZcheck_index_type)r   r&   r;   lenrN   r*   r<   )r-   rK   r\   r0   resultr1   r1   r2   test_empty_constructor]   s
    
z-TestSeriesConstructors.test_empty_constructorc              	   C   sX   d}t dtg}|D ]@}tjt|d tg d|d W d    q1 sH0    Y  qd S )Nznot understoodr   rB   time)namer&   )r   r,   rE   rF   	TypeErrorr   )r-   rI   Zinvalid_listr&   r1   r1   r2   test_invalid_dtype{   s
    
z)TestSeriesConstructors.test_invalid_dtypec                 C   sb   t ddg}t jddg|d}tjtdd  t|dd	gd
 W d    n1 sT0    Y  d S )N)ai8)bZf4)r8   g?)   ir%   zUse DataFrame insteadrB   ABrM   )r'   r&   rH   rE   rF   rG   r   )r-   Zc_dtypeZcdt_arrr1   r1   r2   test_invalid_compound_dtype   s    z2TestSeriesConstructors.test_invalid_compound_dtypec                 C   s   t d}t|trJ d S )Ng      ?)r   
isinstancefloat)r-   Zscalarr1   r1   r2   test_scalar_conversion   s    z-TestSeriesConstructors.test_scalar_conversionc                 C   sH   |\}}t |tdd}t |gd |d}|j|ks8J t|| d S )N   rM   r%   )r   ranger&   r*   r<   )r-   ea_scalar_and_dtype	ea_scalarea_dtyper6   r0   r1   r1   r2   test_scalar_extension_dtype   s
    z2TestSeriesConstructors.test_scalar_extension_dtypec           
      C   sp  t  }|jjsJ t |}|jjs&J t|j|j t|jt|jksNJ t dtjgddgd}|sv|jtj	ks~nds~J t
|d sJ |jjrJ t  jjrJ tjtdd0 t tjdd	td
d W d    n1 s0    Y  d|_t |j}d}||ksJ tddgd
dgg}d}	tjt|	d t | W d    n1 sb0    Y  d S )NZhellor   r8   rM   stringzAData must be 1-dimensional, got ndarray of shape \(3, 3\) insteadrB      )ro   ro   ro   r      z8initializing a Series from a MultiIndex is not supported)r   rN   Z_is_all_datesr*   r=   idr'   nanr&   object_isnanrE   rF   rG   randomdefault_rngstandard_normalr(   rb   r   Zfrom_arraysNotImplementedError)
r-   datetime_seriesusing_infer_stringZempty_seriesZderivedmixedrsZxpmrI   r1   r1   r2   test_constructor   s0    >
z'TestSeriesConstructors.test_constructorc                 C   sd   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    n1 sV0    Y  d S )Nr8   rv   ro   rw         )ro   r   	   rM   z Index data must be 1-dimensionalrB   r8   ro   rv   )r   rE   rF   rG   r   )r-   dfr1   r1   r2   'test_constructor_index_ndim_gt_1_raises   s    "z>TestSeriesConstructors.test_constructor_index_ndim_gt_1_raisesinput_classc                 C   s$  t  }t | }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r t tdd}t | tdd}t|| t tjtdd}t | tddd}t|| t d	ttd
d}|rt d	td
td}nt d	td
d}t|| d S )NFr]   float64r%   categoryr#   rM   rN   r&    ro   r&   rN   )	r   r*   r<   r,   rp   r'   ry   strr;   )r-   r   r   emptyempty2r1   r1   r2   test_constructor_empty   s*    



z-TestSeriesConstructors.test_constructor_empty	input_argry   c                 C   s4   t dtdd}t |tdd}tj||dd d S )Nr   r#   r   rM   Fr]   r   rp   r*   r<   )r-   r   r   r   r1   r1   r2   test_constructor_nan   s    z+TestSeriesConstructors.test_constructor_nanr&   )Zf8rf   M8[ns]m8[ns]r   r;   zdatetime64[ns, UTC]rN   c                 C   s.   t ||d}|j|ksJ t|dks*J d S )Nr   r   )r   r&   r^   )r-   r&   rN   r_   r1   r1   r2   test_constructor_dtype_only   s    z2TestSeriesConstructors.test_constructor_dtype_onlyc                 C   s(   t g dd}|j g dks$J d S )Nrg   re   crM   )r   rN   tolistr-   r_   r1   r1   r2   $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 Nr8   r   r   )r   r   r'   r{   ilocr   r1   r1   r2   $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_   r1   r1   r2   +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 sBJ t dtjg|d}t|jd shJ d S )Nxr%   FTr8   )r   r   r*   r<   r   r'   ry   r{   )r-   string_dtyper6   r_   r0   r1   r1   r2   $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)drg   re   r   )rw      ro   rM   )sortedr   r*   r<   Z
sort_index)r-   Zindex1index2s1s2r1   r1   r2   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edddZdS )z>TestSeriesConstructors.test_constructor_iterable.<locals>.Iter)returnc                 s   s   t dE d H  d S )Nr#   )rp   r-   r1   r1   r2   __iter__$  s    zGTestSeriesConstructors.test_constructor_iterable.<locals>.Iter.__iter__N)__name__
__module____qualname__r   r   r1   r1   r1   r2   Iter#  s   r   r#   int64r%   r   r,   rp   r*   r<   )r-   r   r0   r_   r1   r1   r2   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   r%   r   r-   r0   r_   r1   r1   r2   test_constructor_sequence+  s    z0TestSeriesConstructors.test_constructor_sequencec                 C   s"   t dg}t d}t|| d S )Nabcr   r*   r<   r   r1   r1   r2   test_constructor_single_str1  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r8   rv   ro   r   r%   r   r8   rv   rM   )r   r'   rH   r*   r<   )r-   r0   objr_   r1   r1   r2   test_constructor_list_like7  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   )rw   r   r   rM   rv   r   )FTFr   )r-   r   rN   r_   r0   r1   r1   r2   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   rv   rw   r%   )r   r   r&   )r-   r&   sr1   r1   r2   test_constructor_index_dtypeI  s    z3TestSeriesConstructors.test_constructor_index_dtype
input_valsr8   rv   12z1/1/2011hperiodsfreq
US/Eastern)r   r   tzr   r   )leftrightc                 C   s*   t ||d}t ||}t|| d S Nr%   r   r)   r*   r<   )r-   r   r   r_   r0   r1   r1   r2   test_constructor_list_strP  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 sFJ d S )N      ?       @r%   z1.0z2.0rv   )r   r'   ry   r;   r*   r<   r{   )r-   r   r_   r0   r1   r1   r2   test_constructor_list_str_nab  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   s   | ]
}|V  qd S rS   r1   rU   ir1   r1   r2   rW   i  rR   zDTestSeriesConstructors.test_constructor_generator.<locals>.<genexpr>r#   c                 s   s   | ]
}|V  qd S rS   r1   r   r1   r1   r2   rW   p  rR      rM   rp   r   r*   r<   rN   )r-   genr_   expr1   r1   r2   test_constructor_generatorh  s    z1TestSeriesConstructors.test_constructor_generatorc                 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   s   | ]
}|V  qd S rS   r1   rU   r   r1   r1   r2   rW   w  rR   z>TestSeriesConstructors.test_constructor_map.<locals>.<genexpr>r#   c                 s   s   | ]
}|V  qd S rS   r1   r   r1   r1   r2   rW   ~  rR   r   rM   r   )r-   r   r_   r   r1   r1   r2   test_constructor_mapu  s    z+TestSeriesConstructors.test_constructor_mapc                 C   s\   t g dg d}t|}t|j| tt g ddd}tg ddd}t|| d S )N)r   r8   rv   r   r8   rv   re   rg   r   r   r   r%   )r   r   r*   Zassert_categorical_equalr.   r<   )r-   catr/   r_   r0   r1   r1   r2   test_constructor_categorical  s    z3TestSeriesConstructors.test_constructor_categoricalc                 C   s(   t tg ddd}t|jts$J d S Nr   r   r%   )r   r   rl   r&   r   r5   r1   r1   r2   *test_construct_from_categorical_with_dtype  s    zATestSeriesConstructors.test_construct_from_categorical_with_dtypec                 C   s$   t g ddd}t|jts J d S r   )r   rl   r&   r   r5   r1   r1   r2   ,test_construct_intlist_values_category_dtype  s    zCTestSeriesConstructors.test_construct_intlist_values_category_dtypec                 C   s&  t g d}t|dd}|jdks&J t|t|ks:J td|i}|d }t|| |jd d df }t|| t|t|ksJ td|i}|d }t|| t|t|ksJ t||dd}|d }|d }t|| tj||d	d
 |jdksJ t|t|ks"J d S )N)re   rg   rg   re   re   r   r   r   ri   rb   r   r   r8   ri   rj   Crj   F)Zcheck_names)	r   r   r&   r^   r   r*   r<   r   rb   )r-   factorr   r   r_   Zresult1Zresult2r1   r1   r2   *test_constructor_categorical_with_coercion  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sTJ |jd }||ksjJ |jjd }||ksJ d S )	Nr8   zJohn P. Doerv   z	Jane DoveZ	person_idperson_name)columnsr   )r   r   r   r   loc)r-   r   r0   r_   r1   r1   r2   +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   r%   r   )r-   seriesr_   r0   r1   r1   r2   &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ts,J t|jjtg d |jj	sPJ t ddgtddgd}t|jtsxJ t|jjtddg |jj	du sJ 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 )Nre   rg   r   T)orderedr%   Fr   r8   r   )r   r   rl   r&   r*   r=   r   
categoriesr   r   r<   r-   r_   r0   r1   r1   r2   "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 )NZdabcT)r   r   Zabcabcr%   r   )r   r,   r   r   r*   r<   )r-   Zcdtr0   r   r_   r1   r1   r2   #test_constructor_categorical_string  s    z:TestSeriesConstructors.test_constructor_categorical_stringc                 C   sR  t g d}t|dd}|j|us&J |jg d}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|d
d}|j|u sJ |jg d}|j|usJ tjg dtjd}t	|
 | d|d< tjg d	tjd}t	|
 | d S )N)re   rg   r   re   T)copyr   )r8   rv   ro   r8   r%   rv   r   )rv   rv   ro   r8   F)r   r   r   Zrename_categoriesr'   rH   r   rz   r*   assert_numpy_array_equalZ	__array__r.   )r-   r   r   Zexp_sZexp_catZexp_s2r1   r1   r2   !test_categorical_sideeffects_free  s,    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   re   rg   r%   )r   )r   r   r   r'   ry   r*   r<   )r-   r   r   r1   r1   r2   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	j
tdd t|| W d    n1 s0    Y  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	j
tdd t|| W d    n1 sd0    Y  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ro   r%           r   r   rv   r   rM   r   r8   )r   r   r   r   r   zSeries classes are differentrB   TFTTFr     ro   )r   
masked_allrm   r   r'   ry   r*   r<   intrE   rF   AssertionErrorr   r;   r   r   )r-   r[   r_   r0   rN   r1   r1   r2   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   r%   )	r   r  rm   Zharden_maskr   r'   ry   r*   r<   r-   r[   r_   r0   r1   r1   r2   %test_constructor_maskedarray_hardenedk  s    z<TestSeriesConstructors.test_constructor_maskedarray_hardenedc                 C   sP   t dddd}dd |D }t||d}|r>|j|sLJ n|j|u sLJ d S )NZ20090415Z20090519rj   r   c                 S   s   i | ]
}|d qS r8   r1   )rU   kr1   r1   r2   
<dictcomp>t  rR   zNTestSeriesConstructors.test_series_ctor_plus_datetimeindex.<locals>.<dictcomp>rM   )r   r   rN   is_)r-   using_copy_on_writerngr[   r_   r1   r1   r2   #test_series_ctor_plus_datetimeindexr  s    z:TestSeriesConstructors.test_series_ctor_plus_datetimeindexc                 C   s*   t g d}tj|jttddd d S )Nr   ro   T)exact)r   r*   r=   rN   r   rp   r-   r   r1   r1   r2   test_constructor_default_index|  s    z5TestSeriesConstructors.test_constructor_default_indexinputr   ro   )re   rg   re   c                 c   s   | ]
}|V  qd S rS   r1   r   r1   r1   r2   rW     rR   z TestSeriesConstructors.<genexpr>c                 c   s   | ]
}|V  qd S rS   r1   r   r1   r1   r2   rW     rR   c                 C   sH   d}t jt|d" t|tdd W d    n1 s:0    Y  d S )Nz;Length of values \(3\) does not match length of index \(4\)rB   rw   rM   )rE   rF   rG   r   r'   r(   )r-   r  rI   r1   r1   r2   test_constructor_index_mismatch  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   rw   r   r   )r   r'   rH   r(   r*   r<   r   r1   r1   r2   test_constructor_numpy_scalar  s    z4TestSeriesConstructors.test_constructor_numpy_scalarc                 C   sH   d}t jt|d" tdgg dd W d    n1 s:0    Y  d S )Nz;Length of values \(1\) does not match length of index \(3\)rB   foor   rM   )rE   rF   rG   r   r-   rI   r1   r1   r2   test_constructor_broadcast_list  s    z6TestSeriesConstructors.test_constructor_broadcast_listc                 C   sB   t tdtdddd}||g}t|ddgd}t|ts>J d S )Nr   
2020-01-01r   rM   r   r8   )r   rp   r   r   rl   )r-   r   objsr   r1   r1   r2   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 sn0    Y  d S )	N)r   r   g       @rf   r%   9Cannot convert non-finite values \(NA or inf\) to integerrB   r   Tr   r&   )r   r'   rH   r&   rE   rF   r   ry   )r-   r   rI   r1   r1   r2   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< ||rNJ |d dks^J |d dksJ qd S )Nr   Tr   r   r   )r'   rH   r   rm   r*   r<   equals)r-   r[   r   yr1   r1   r2   test_constructor_copy  s    z,TestSeriesConstructors.test_constructor_copyZ20170101r   r   r  z1 dayZ2012Q1Qr   c                 C   s
   t | jS rS   typer   r   r1   r1   r2   rQ     rR   )Zidsc                 C   s"   t |}|jjd j|usJ d S Nr   )r   _mgrblocksr.   )r-   rN   r   r1   r1   r2   test_constructor_limit_copies  s    z4TestSeriesConstructors.test_constructor_limit_copiesc                 C   sF   t g d}| }t |}|j|jus,J g d|_t|| d S )Nr   r   )r   r   r+  rN   r*   r<   )r-   r   Zs_origr   r1   r1   r2   test_constructor_shallow_copy  s    
z4TestSeriesConstructors.test_constructor_shallow_copyc                 C   st   t d tdd}|jtjks J t d tdtd}|jtjksBJ t td gd}t td gd}t	
|| d S )Nr   rM   r   )r   rp   r&   r'   r   r;   rz   rH   r   r*   r<   r-   r   r0   r1   r1   r2   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svJ 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 )Nr%   rD   )	r   r'   ry   r   r&   r*   r<   rH   r   )r-   r   r1   r1   r2   test_constructor_pass_nan_nat  s    z4TestSeriesConstructors.test_constructor_pass_nan_natc                 C   sF   d}t jt|d  tg dtd W d    n1 s80    Y  d S )Nz!could not convert string to floatrB   r   r%   )rE   rF   rG   r   rm   r  r1   r1   r2   test_constructor_cast  s    z,TestSeriesConstructors.test_constructor_castc                 C   s   t rd}t}nd}t}tj||d  tg ddd W d    n1 sJ0    Y  tj||d  tg ddd W d    n1 s0    Y  d S )NzCThe elements provided in the data cannot all be casted to the dtypez/Values are too large to be losslessly convertedrB   )r8      i2 int8r%   uint8)r
   OverflowErrorrG   rE   rF   r   )r-   rI   errr1   r1   r2   +test_constructor_signed_int_overflow_raises  s    .zBTestSeriesConstructors.test_constructor_signed_int_overflow_raisesr.   r%   c                 C   s8   |d }t |}|d j|jks$J |d |ks4J d S r*  )r   r&   )r-   r.   valuer_   r1   r1   r2   test_constructor_numpy_uints  s    z3TestSeriesConstructors.test_constructor_numpy_uintsc                 C   sT   t rd| }nd}tjt|d tdg|d W d    n1 sF0    Y  d S )NzDThe elements provided in the data cannot all be casted to the dtype z5Trying to coerce negative values to unsigned integersrB   r%   )r
   rE   rF   r6  r   )r-   Zany_unsigned_int_numpy_dtyperI   r1   r1   r2   (test_constructor_unsigned_dtype_overflow(  s    z?TestSeriesConstructors.test_constructor_unsigned_dtype_overflowc                 C   s  t jdd}d}tjt|d ||dd W d    n1 sF0    Y  tjt|d  |t|dd W d    n1 s0    Y  t j|d< d}tjt	|d ||dd W d    n1 s0    Y  t	}|t
u rt}d}tj||d  |t|dd W d    n1 s 0    Y  t jd	d
gdd}||d}||dd}t|| |t|dd}t|| d S )Nrv   (Trying to coerce float values to integerrB   rf   r%   r   r  #cannot convert float NaN to integerr   r   r   )r'   r|   r}   r~   rE   rF   rG   r,   ry   r   r   rH   r)   r*   r+   )r-   frame_or_seriesarrrI   excr0   r   r1   r1   r2   (test_constructor_floating_data_int_dtype4  s,    *.
*0z?TestSeriesConstructors.test_constructor_floating_data_int_dtypec                 C   s   g d}d}t jt|d t||d W d    n1 s<0    Y  t jt|d" tt||d W d    n1 s|0    Y  d S )Nr8   rv   g      @r=  rB   r%   )rE   rF   rG   r   r'   rH   r-   Zany_int_numpy_dtyper?   rI   r1   r1   r2   "test_constructor_coerce_float_fail`  s    *z9TestSeriesConstructors.test_constructor_coerce_float_failc                 C   s2   t g d|d}t g d|}t|| d S )NrC  r%   r   )r-   Zfloat_numpy_dtyper   r0   r1   r1   r2   #test_constructor_coerce_float_validm  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@0    Y  d}tjt|d" tt ||d W d    n1 s0    Y  d S )Nr8   rv   r>  rB   r%   r  )r'   ry   rE   rF   rG   r   r   rH   rD  r1   r1   r2   3test_constructor_invalid_coerce_ints_with_float_nanr  s    *zJTestSeriesConstructors.test_constructor_invalid_coerce_ints_with_float_nanc                 C   s   t g d}t |tjd}|r"tnd }t| d|d< W d    n1 sN0    Y  |rn|d dks~J n|d dks~J d S )Nr   r%   r   r8   rv   )r   r'   r   FutureWarningr*   assert_produces_warning)r-   r  Zwarn_copy_on_writer   r   warnr1   r1   r2   test_constructor_dtype_no_cast  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sJJ d S )N20130101ZNOVr%   r   r8   )r   r   r;   r   r&   r  r1   r1   r2   "test_constructor_datelike_coercion  s    z9TestSeriesConstructors.test_constructor_datelike_coercionc                 C   sn   d  }d  }d  }td  }t|||d|d}|jd }|jtksRJ |jd }|jtksjJ d S )	Nz216 3T19z	2T15 4H19z416 4T20z2016-01-22 2019-09-07)wing1wing2matrM   Z3T19Z216)splitpdto_datetimer   r   r&   r;   )r-   ZbellyrN  rO  rP  r   r_   r1   r1   r2   #test_constructor_datelike_coercion2  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   r%   )r   r   _valuer*   r+   )r-   r?  r  r_   r0   r1   r1   r2   (test_constructor_mixed_int_and_timestamp  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s0J q0d S )Nr   )r'   rH   r   nowr   r&   )r-   r@  r_   r1   r1   r2   %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| rBJ t tjdtdd}t| sfJ t tdddddtgdd	}t|d sJ |jdksJ t tdddddtjgdd	}t|d sJ |jdksJ d S )
Nr   r   r   rM   r  r8   rv   r   r%   )	r   r   rp   r   r4   r'   ry   r   r&   r  r1   r1   r2   !test_constructor_dtype_datetime64  s    z8TestSeriesConstructors.test_constructor_dtype_datetime64c                 C   s   t dddt dddt dddg}dd |D }t|}|jdksFJ tj|jd< |jdks`J t|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	|| d S )N  r8   rv   ro   c                 S   s   g | ]}t |qS r1   r'   
datetime64r   r1   r1   r2   
<listcomp>  rR   zOTestSeriesConstructors.test_constructor_dtype_datetime64_10.<locals>.<listcomp>r   r   zdatetime64[ms]r%   @B M8[ms]rD   )r   r   r&   r'   ry   r   r)   r   r*   r<   r   )r-   pydatesdatesr6   r0   r_   r1   r1   r2   $test_constructor_dtype_datetime64_10  s     "z;TestSeriesConstructors.test_constructor_dtype_datetime64_10c                 C   s   t dddt dddt dddg}dd |D }t|dd}|d	 d
}tjt|d |d W d    n1 sx0    Y  t|tjd}t|tj}t	|| d S )NrZ  r8   rv   ro   c                 S   s   g | ]}t |qS r1   r[  r   r1   r1   r2   r]    rR   zOTestSeriesConstructors.test_constructor_dtype_datetime64_11.<locals>.<listcomp>rD   r%   r   z:Converting from datetime64\[ns\] to int32 is not supportedrB   r   )
r   r   r)   rE   rF   rc   r'   r   r*   r<   )r-   r`  ra  dtsrI   r_   r0   r1   r1   r2   $test_constructor_dtype_datetime64_11  s    "
(z;TestSeriesConstructors.test_constructor_dtype_datetime64_11c                 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 )Nrv   r8   r   i  )r   r   r   r1   r1   r2   #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 )NrL  r8   re   rg   rM   )r   r   r   r1   r1   r2   #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 ]d}td| d	}|tj|}t||}|d
krttd}|j|ksJ t||| q0t||t	d}dD ]8}|tjd| d	}t||t	d}t|| qtj
dd | D t	d}t||}	t|	j| |	jt	ks&J d S )Nz01-Jan-2015z01-Dec-2015ZMEr	  rD   rM   )r   DmsusnszM8[]rg  r$   r   c                 S   s   g | ]}|  qS r1   )r:   )rU   r   r1   r1   r2   r]     rR   zNTestSeriesConstructors.test_constructor_dtype_datetime64_7.<locals>.<listcomp>r%   )r   viewr'   ndarrayr)   r   r&   r*   r<   r;   rH   r9   r   r.   )
r-   ra  Zvalues2r0   unitr&   Zvalues1r_   Zdates2Zseries1r1   r1   r2   #test_constructor_dtype_datetime64_7  s(    


z:TestSeriesConstructors.test_constructor_dtype_datetime64_7c                 C   sx   t d tdg}|jtksJ t tjtdg}|jtks:J t td dg}|jtksVJ t ttjdg}|jtkstJ d S )Nz2013-08-05 15:30:00.000001)r   r   r&   r;   r'   ry   r5   r1   r1   r2   #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sNJ t dddd}tt|jd jdksxJ d S )NrL  ro   r  r   UTCr%  r   )r   r   r   r   r   )r-   drr1   r1   r2   #test_constructor_dtype_datetime64_55  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;   rv   r   )r   r   r&   r   r5   r1   r1   r2   #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 sLJ d S )N  r8   rv   r;   r   )r   r   r   r&   r   r5   r1   r1   r2   #test_constructor_dtype_datetime64_3F  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 sPJ d S )Nru  r8   rv   r;   NaN)r   r   r'   ry   r&   r   r5   r1   r1   r2   #test_constructor_dtype_datetime64_2M  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s4J t|jtsDJ dt|v sTJ |j}t|tj	sjJ |jdksxJ t
|}|dj|jjd}t|| |jd	 }|td
ddksJ |d	 }|td
ddksJ |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 slJ | }dt|v sJ dt|v sJ t
|dd}t|| d S )NrL  ro   r   r%  datetime64[ns, US/Eastern]rD   rq  r   r   z2013-01-01 00:00:00-0500r  rM   rv   r8   r   Zinferr	  )r   r   r&   rb   rl   r   r   r.   r'   rm  r   tz_localize
tz_convertdtr   r*   r=   r   r   rN   r<   rR  concatshift)r-   rr  r   r_   r   r1   r1   r2   !test_constructor_with_datetime_tzT  s8    
"z8TestSeriesConstructors.test_constructor_with_datetime_tzc                 C   s&   t tdddd}dt|v s"J d S )NrL    r   r%  ry  )r   r   r   r5   r1   r1   r2   "test_constructor_with_datetime_tz5  s    z9TestSeriesConstructors.test_constructor_with_datetime_tz5c                 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/Pacificrz  2013-01-02 14:00:00-0800zdatetime64[ns, US/Pacific]TZskipnar\  r   r   r&   r	   Zinfer_dtyper5   r1   r1   r2   "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  rz  r  r   r;   Tr  r   r  r5   r1   r1   r2   "test_constructor_with_datetime_tz3  s    

z9TestSeriesConstructors.test_constructor_with_datetime_tz3c                 C   s@   t tddgdd}tddgddd}t |}t|| d S )	Nr   r8   ry  r   r   r   rz  rj  )r   r   r   as_unitr*   r<   )r-   r6   Zdtir0   r1   r1   r2   "test_constructor_with_datetime_tz2  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 )Nry   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 rS   r1   r   r6   r?   r1   r2   rW     rR   zVTestSeriesConstructors.test_constructor_no_partial_datetime_casting.<locals>.<genexpr>)r   r   r4   rp   r^   r   r1   r  r2   ,test_constructor_no_partial_datetime_casting  s    zCTestSeriesConstructors.test_constructor_no_partial_datetime_casting	arr_dtypekindMr   rn  )rj  ri  rh  r   r   r   rg  c           	      C   s   | d| d}t jg d|d}t|}||}t||}|dv rh|j|ksXJ |j|ksJ n(|j| dks|J |j| dksJ t|| d S )N8[rk  r   r%   )rj  ri  rh  r   z8[s])r'   rH   r   r)   r&   r*   r<   )	r-   r  r  rn  r&   r@  r6   r_   r0   r1   r1   r2   &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]r%   ZCET)r   r   r}  r{  r*   r<   )r-   r  r_   r0   r1   r1   r2   7test_constructor_with_naive_string_and_datetimetz_dtype  s    zNTestSeriesConstructors.test_constructor_with_naive_string_and_datetimetz_dtypec                 C   s^   t dd}t jt ddgdd}t|}tt|gd}|jdksNJ t|| d S )Nr8   rh  z>M8[ms]r%   r_  )	r'   r\  rH   r   r   r)   r&   r*   r<   )r-   rh  r@  r_   r0   r1   r1   r2   %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 )Nro   r   closedzinterval[int64, right])	Zfrom_breaksr'   r(   r   r&   r*   r=   r   r.   )r-   r  Z	intervalsr_   r1   r1   r2   test_construction_interval  s    z1TestSeriesConstructors.test_construction_intervaldata_constructorr,   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   r8   rv   zinterval[float64, right])r   r   r   r&   r*   r<   r-   r  r[   r_   r0   r1   r1   r2   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s6J | |ksFJ d S )Nr   r8   Zbothr  rv   Zneither)r   r   r&   r;   r   )r-   r  r[   r_   r1   r1   r2   &test_constructor_interval_mixed_closed  s    z=TestSeriesConstructors.test_constructor_interval_mixed_closedc                 C   s*  t tdddd}t ||jd}t|| t |jd|jd}t|| t |j|jd}t |jj|jj	}t|| t
d 2 t |jjd}|j|jj	}W d    n1 s0    Y  t|| t
d & t |jd|jd}W d    n1 s0    Y  t|| d S )NrL  ro   r   r%  r%   rq  r   )r   r   r&   r*   r<   r}  r|  r.   r{  r   rI  rl  )r-   r6   r_   r0   middler1   r1   r2   test_construction_consistency  s    .6z4TestSeriesConstructors.test_construction_consistencyc                 C   sL   t ddt ddd g}t||}tt|}t|| |jdksHJ d S )N2000rg  2001	Period[D])r   r   r    r*   r<   r&   r  r1   r1   r2   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 sDJ d S )Nr   r    z	period[D]r%   ro   rv   )r   rR  Z_libsr   r   r-   r   valr1   r1   r2   ;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  rg  r  Y)r   r   r&   r;   r   )r-   r[   r_   r1   r1   r2   .test_constructor_period_incompatible_frequency&  s    zETestSeriesConstructors.test_constructor_period_incompatible_frequencyc                 C   sp   t dddd}t|}|jdks$J tjtdd t|t}W d    n1 sV0    Y  t|| d S )NrL  r   rg  r   r  Dtype inferencerB   )	r   r   r&   r*   rI  rH  r)   r;   r<   )r-   pir   r0   r1   r1   r2   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	 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   rM   )rg   r   r   re   r8   rv   r   r  r#   rg  r   r%   )
r   r   keysr*   r<   r'   ry   r   r   r   )r-   r   r_   r0   Zpidxr1   r1   r2   test_constructor_dict7  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 )Nre   rv   ro   rw   r;   r   rM   r   r-   r   r_   r0   r1   r1   r2   /test_constructor_dict_list_value_explicit_dtypeJ  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 )Nr8   r   rv   r   )r8   r   rv   ZbacrM   )r   r,   r*   r<   r  r1   r1   r2   test_constructor_dict_orderQ  s    z2TestSeriesConstructors.test_constructor_dict_orderc           	      C   sn   |\}}t |tr*tjjdd}|| d|i}t|dgd}t|dg|d}|j|ks^J t	|| d S )NzMConstruction from dict goes through maybe_convert_objects which casts to nanor  re   rM   r   )
rl   r   rE   markxfailapplymarkerr   r&   r*   r<   )	r-   rq   requestrr   rs   r  r   r_   r0   r1   r1   r2   test_constructor_dict_extensionY  s    

z6TestSeriesConstructors.test_constructor_dict_extensionr9  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 )Nr8   re   rg   ry   r   rw   r   re   rg   r   r   rM   r8   r8   rv   ro   r   )rm   r   sort_valuesr'   ry   r*   r<   r   )r-   r9  r   r_   r0   r1   r1   r2   test_constructor_dict_nan_keyi  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 gtyZQAr;  c                    s   t t fddD S )Nc                 3   s   | ]} |V  qd S rS   r1   r   rK   r1   r2   rW     rR   zeTestSeriesConstructors.test_constructor_dict_datetime64_index.<locals>.create_data.<locals>.<genexpr>)dictzipr  Zdates_as_strr.   r  r2   create_data  s    zRTestSeriesConstructors.test_constructor_dict_datetime64_index.<locals>.create_datac                 S   s   t | dS )Nz%Y-%m-%d)r   strptimer)  r1   r1   r2   rQ     rR   zOTestSeriesConstructors.test_constructor_dict_datetime64_index.<locals>.<lambda>c                 s   s   | ]}t |V  qd S rS   )r   r   r1   r1   r2   rW     rR   zPTestSeriesConstructors.test_constructor_dict_datetime64_index.<locals>.<genexpr>)r'   r\  r   r   r*   r<   )	r-   r  Zdata_datetime64Zdata_datetimeZdata_Timestampr0   Zresult_datetime64Zresult_datetimeZresult_Timestampr1   r  r2   &test_constructor_dict_datetime64_indexy  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)r8   r8   Ng      r8   r   r;  )ZlevelscodesrM   )r   r   r'   ry   r*   r<   r  r1   r1   r2   #test_constructor_dict_tuple_indexer  s    &z:TestSeriesConstructors.test_constructor_dict_tuple_indexerc                 C   s4   |ddi}t |}t dgdgd}t|| d S )Nro   threerM   r   )r-   Znon_dict_mapping_subclassZndmr_   r0   r1   r1   r2   test_constructor_mapping  s    z/TestSeriesConstructors.test_constructor_mappingc                 C   s$   g d}t |}t||ks J d S N)r  )rv   rv   )rv   ro   )r   r,   r-   r[   r   r1   r1   r2   test_constructor_list_of_tuples  s    z6TestSeriesConstructors.test_constructor_list_of_tuplesc                 C   s    d}t |}t||ksJ d S r  )r   tupler  r1   r1   r2    test_constructor_tuple_of_tuples  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 )Nro   r   )r8   rv   Nr   r  r  rM   )r   r  r   from_tuplesr*   r<   r  r1   r1   r2   test_constructor_dict_of_tuples  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sLJ ddddd}t |}|st|jtjks|nd	s|J d
dd}t |t	d}|jtj
ksJ d S )Nr   r8   rv   ro   r  r   r   3ru   0re   rg   r%   )r   r*   Zassert_is_sortedrN   r   rW  r&   r'   rz   rm   r   )r-   r   r[   r   r1   r1   r2   test_fromDict  s    
z$TestSeriesConstructors.test_fromDictc           	      C   s  t tj|jtjd}|jtjks$J t|t|ks8J t d|jd}|sX|jtjks`nds`J t|t|kstJ t	 }t ||jd}|jdksJ t|t|ksJ t d|jdd}t d|jd
d}|jdksJ t|t|ksJ t|| d S )Nr   r  rM   ru   zM8[us]r   r   )r   r'   ry   rN   r   r&   r^   rz   r   rW  r)   r*   r<   )	r-   r   r   Znansstringsr   ra  Zcategoricalr0   r1   r1   r2   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sBJ t tddtddtddg}|jdksrJ t tddtgd	d
}|jdksJ t tddtjgd	d
}|jdksJ t tdtgd	d
}|jdksJ t tdtg}|jdksJ t tdtg}|jdks$J t tdtjg}|jdksHJ t ttdg}|jdksjJ t tddg}|jdksJ |	d d}t
jt|d |	d W d    n1 s0    Y  dddg}t
jt|d& t tdddgd	d
 W d    n1 s0    Y  t dd tdD dg }|jdksTJ t d tdg}|jtksrJ t tjtdg}|jtksJ t td dg}|jtksJ t ttjdg}|jtksJ d S )Nc                 S   s   g | ]}t |d qS daysr   r   r1   r1   r2   r]    rR   zMTestSeriesConstructors.test_constructor_dtype_timedelta64.<locals>.<listcomp>ro   timedelta64[ns]r8   r  rv   r   r   r%   i r;   r   z;Converting from timedelta64\[ns\] to int32 is not supportedrB   r   |z+Could not convert object to NumPy timedeltaz*Could not convert 'foo' to NumPy timedeltar  c                 S   s   g | ]}t |d qS r  r  r   r1   r1   r2   r]    rR   z1 Day)r   rp   r&   r   r'   timedelta64r   ry   r   r)   rE   rF   rc   joinrG   r;   )r-   tdrI   r6   r1   r1   r2   "test_constructor_dtype_timedelta64  sV    "
*6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 )NrL  r   rz  r;   r%   )r   r   r*   r<   r/  r1   r1   r2   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   r%   ro   rv   )r   r   r   r  r1   r1   r2   test_NaT_scalar0  s
    z&TestSeriesConstructors.test_NaT_scalarc                 C   s0   t tjgd}t tgdd}t|| d S )Nr   r%   )r   r'   ry   r)   r   r*   r<   r   r1   r1   r2   test_NaT_cast9  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s6J q6qd S )Ni	  g     H@rb   r     r
  u   אr   ro   r   r8   r  r   )r   r'   onesr   rb   )r-   nr[   r   r1   r1   r2   test_constructor_name_hashable?  s    z5TestSeriesConstructors.test_constructor_name_hashablec              
   C   sz   d}dgt dddifD ]Z}dgt dddifD ]>}tjt|d t||d W d    q41 sh0    Y  q4qd S )Nz$Series\.name must be a hashable type	name_listrv   r8   rB   r   )r'   r  rE   rF   rc   r   )r-   rI   r  r[   r1   r1   r2    test_constructor_name_unhashableE  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#   r  r   )r   r,   r   r&   r-   r   r1   r1   r2   test_auto_conversionL  s    z+TestSeriesConstructors.test_auto_conversionc                 C   s   t jg ddd}t|}|j|jks*J tddddd}t|}|j|jksVJ t|| t jg dd	d}t|}ttd
ddddd}|jdksJ t|| t jg ddd}t|}ttdddddd}|jdksJ t|| d S )Nr   timedelta64[s]r%   z00:00:01ro   r   r   )
2013-01-01z
2013-01-02z
2013-01-03zdatetime64[D]rL  rg  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)	r'   rH   r   r&   r   r  r*   r<   r   )r-   r@  r6   Ztdir0   r1   r1   r2   test_convert_non_nsP  s0    z*TestSeriesConstructors.test_convert_non_nsr  r#   z2000-Q1c                 C   s
   t | jS rS   r'  r)  r1   r1   r2   rQ   v  rR   c                 C   s   dt |jd d}tjt|d t|td W d    n1 sH0    Y  t|tj	d}t|
tj	}t|| d S )NzCannot cast r   z.*? to rB   r%   )r(  r   rstriprE   rF   rc   r   rm   r'   r   r)   r*   r<   )r-   rN   rI   r_   r0   r1   r1   r2   'test_constructor_cant_cast_datetimelikeo  s    *z>TestSeriesConstructors.test_constructor_cant_cast_datetimelikec                 C   s
   t | jS rS   r'  r)  r1   r1   r2   rQ     rR   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)   r*   r<   r   )r-   rN   r   r   r1   r1   r2   test_constructor_cast_object  s    
z3TestSeriesConstructors.test_constructor_cast_objectc                 C   sj   d}t |jdvr,tjjdd}|| tjt|d t	g |d W d    n1 s\0    Y  d S )Nz!dtype has no unit. Please pass in)r  r\  zGH#33890 Is assigned ns unitr  rB   r%   )
r'   r&   rb   rE   r  r  r  rF   rG   r   )r-   r&   r  rI   r  r1   r1   r2   /test_constructor_generic_timestamp_no_frequency  s    
zFTestSeriesConstructors.test_constructor_generic_timestamp_no_frequency)	Zpsasfsr  r  Wrg  r   r   c                 C   s   | d| d}d}t jt|d tg |d W d    n1 sD0    Y  t jt|d  tdgg|d W d    n1 s0    Y  d S )Nr  rk  z4dtype=.* is not supported. Supported resolutions arerB   r%   r   )rE   rF   rc   r   r   )r-   r  rn  r&   rI   r1   r1   r2   0test_constructor_generic_timestamp_bad_frequency  s    *zGTestSeriesConstructors.test_constructor_generic_timestamp_bad_frequency)Nr5  r   c                 C   s4   t g d|pdd}t td|d}t|| d S )N)r   r8   rv   ro   rw   r   r%   r   r   )r-   r&   r0   r_   r1   r1   r2   test_constructor_range_dtype  s    z3TestSeriesConstructors.test_constructor_range_dtypec                 C   sL  t dd}t|}tt|}t|| t|t|ks>J |jtjksNJ t ddd}t|}tt|}t|| t|t|ksJ |jtjksJ t ddd}t|}tt|}	t||	 t|t|ksJ |jtksJ t dd dd d }
t|
}tt|
}t|| t|t|
ks8J |jtksHJ d S )	Nl            l           r;  l         l        rv   I   rw   )	rp   r   r,   r*   r<   r&   r'   uint64r;   )r-   r  r6   r0   Zrng2ser2Z	expected2Zrng3Zser3Z	expected3Zrng4Zser4Z	expected4r1   r1   r2    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  rz  r%   )r   r   r;   r*   r<   )r-   Zdt_listr_   r0   r1   r1   r2   test_constructor_tz_mixed_data  s    
z5TestSeriesConstructors.test_constructor_tz_mixed_datapydtTFc                 C   s(  |}t d|d}|r| }d}tjt|d t|gdd W d    n1 sR0    Y  tjt|d( ttj|gtddd W d    n1 s0    Y  tjt|d  td|idd W d    n1 s0    Y  d}tjt	|d  t|dgdd	 W d    n1 s0    Y  d S )
NZ2019rz  zsCannot convert timezone-aware data to timezone-naive dtype. Use pd.Series\(values\).dt.tz_localize\(None\) instead.rB   rD   r%   r   z/Cannot unbox tzaware Timestamp to tznaive dtyper   )
r   r9   rE   rF   rG   r   r'   rH   r;   rc   )r-   Ztz_aware_fixturer  r   r>   rI   r1   r1   r2   'test_constructor_data_aware_dtype_naive  s    ,6.z>TestSeriesConstructors.test_constructor_data_aware_dtype_naivec                 C   s<   t dddd}t|}t|}t|jtds8J d S )Nz1/1/2000 00:00:00z1/1/2000 1:59:50Z10sr	  r   )r   r'   Zasarrayr   Z
issubdtyper&   )r-   r  ra  r   r1   r1   r2   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-   Znullable_string_dtyper_   r0   r1   r1   r2   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 )NrD   r%   )rR  ZSparseDtyper   ZarraysZSparseArrayr*   r<   )r-   r.   r&   r_   r@  r0   r1   r1   r2   "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 )Nr8   rv   r  re   rg   )r   r  r*   r<   r.   r   r1   r1   r2   )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   rM   r   )r-   r  r_   r0   r1   r1   r2   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sNJ d S )	Nz
2000-01-01r#   rg  r   r  z
2011-01-01r	  z
2011-02-01)r   r,   r   r&   r   r  r1   r1   r2   4test_constructor_list_of_periods_infers_period_dtype3  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      $@Nr1   r   r1   r1   r2   rW   =  rR   zHTestSeriesConstructors.test_constructor_subclass_dict.<locals>.<genexpr>r#   )rp   r   r  itemsr*   r<   )r-   Zdict_subclassr[   r   r0   r1   r1   r2   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d fV  qdS )colrv   N)r'   r|   r}   r   r1   r1   r2   rW   D  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   r1   r1   r1   r2   ri   M  s   ri   )r   rp   r   r,   r.   r  r*   r<   )r-   r[   r   r0   ri   r1   r1   r2   test_constructor_ordereddictB  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   ))re   re   )rg   re   )rg   r   c                 S   s   g | ]}|d  qS r
  r1   r   r1   r1   r2   r]  X  rR   zKTestSeriesConstructors.test_constructor_dict_multiindex.<locals>.<listcomp>c                 S   s   g | ]}|d  qS r   r1   r   r1   r1   r2   r]  X  rR   rM   g     [@zr   c                 S   s   g | ]}|d  qS r
  r1   r   r1   r1   r2   r]  `  rR   c                 S   s   g | ]}|d  qS r  r1   r   r1   r1   r2   r]  `  rR   F)Ztupleize_cols)r   r  r   r   r  r*   r<   insertr   ZreindexrN   )r-   r   Z_dr_   r0   r1   r1   r2    test_constructor_dict_multiindexS  s     z7TestSeriesConstructors.test_constructor_dict_multiindexc                 C   sB   dddt jd}t|}t|d d  |jd}t|| d S )Nr   r8   rv   ))r   r   )r   j)r  r   r  r;  rM   )r'   ry   r   to_dictrN   r*   r<   )r-   r[   r0   r_   r1   r1   r2   -test_constructor_dict_multiindex_reindex_flate  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   rn  rZ   r   ri   r#   rj   r   r   r   rR  Zto_timedeltar*   r<   r   r1   r1   r2   %test_constructor_dict_timedelta_indexm  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sRJ t|jd
  d S )Ng     g@g     t@i   i  r   r  )tzinfor	  rZ   r   )r   r   r   rN   r   repr)r-   r.   r  rN   r   r1   r1   r2   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
  )rv   r   r%   r   rH   r&   r*   r<   )r-   r?   r6   r&   r  r1   r1   r2   "test_constructor_with_pandas_dtype  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   r'   ry   r*   r<   r   r1   r1   r2   )test_constructor_int_dtype_missing_values  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   r1   r1   r2   *test_constructor_bool_dtype_missing_values  s    zATestSeriesConstructors.test_constructor_bool_dtype_missing_valuesc                 C   s0   t g d|d}t g d|d}t|| d S )N)r  r   r   r%   r   r   )r-   Zany_int_dtyper_   r0   r1   r1   r2   test_constructor_int64_dtype  s    z3TestSeriesConstructors.test_constructor_int64_dtypec                 C   sX   t stjtdd}ntjtdd}| tdgdd W d    n1 sJ0    Y  d S )Nz/string values cannot be losslessly cast to int8rB   z!The elements provided in the dataZ128r4  r%   )r
   rE   rF   rG   r6  r   )r-   rF   r1   r1   r2   5test_constructor_raise_on_lossy_conversion_of_strings  s    zLTestSeriesConstructors.test_constructor_raise_on_lossy_conversion_of_stringsc                 C   s6   t g ddd}t tjg ddd}t|| d S )Nr^  i@ i- r  r%   rj  r  r  r   r1   r1   r2   6test_constructor_dtype_timedelta_alternative_construct  s    zMTestSeriesConstructors.test_constructor_dtype_timedelta_alternative_constructzNot clear what the correct expected behavior should be with integers now that we support non-nano. ATM (2022-10-08) we treat ints as nanoseconds, then cast to the requested dtype. xref #48312c                 C   s0   t g ddd}t g ddd}t|| d S )Nr  r  r%   r  r   r   r1   r1   r2   %test_constructor_dtype_timedelta_ns_s  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 )Nr  r  r%   r   r  r   r   r1   r1   r2   2test_constructor_dtype_timedelta_ns_s_astype_int64  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 ]D}tjt|d" ||ddg|d W d    q1 sT0    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      @r%   )r  r*   ZNP_NAT_OBJECTSr   rE   rF   rc   )r-   r"  Zany_numeric_ea_dtyperI   nullr1   r1   r2   /test_constructor_mismatched_null_nullable_dtype  s    zFTestSeriesConstructors.test_constructor_mismatched_null_nullable_dtypec                 C   sh   t dddtjgdd}t dddtjgdd}t|| t g ddd}t g ddd}t|| d S )	NTFInt64r%   r8   r   )TFT)r8   r   r8   )r   rR  NAr*   r<   r   r1   r1   r2   (test_series_constructor_ea_int_from_bool  s    z?TestSeriesConstructors.test_series_constructor_ea_int_from_boolc                 C   sH   t jtdd& tdddtjgdd W d    n1 s:0    Y  d S )Nzinvalid literalrB   TrueFalser%  r%   )rE   rF   rG   r   rR  r&  r   r1   r1   r2   /test_series_constructor_ea_int_from_string_bool  s    zFTestSeriesConstructors.test_series_constructor_ea_int_from_string_boolr  r   c                 C   sL   t t jjd }t||gdd}tt j|dgdddd}t|| d S )Nr8   UInt64r%   r  )r'   iinfor  maxr   rH   r*   r<   r-   r  max_valr_   r0   r1   r1   r2   (test_series_constructor_overflow_uint_ea  s    z?TestSeriesConstructors.test_series_constructor_overflow_uint_eac                 C   sd   t t jjd }t||tjgdd}ttt j|ddgddt jg dt j	d}t
|| d S )Nr8   r+  r%   r   r  )r   r   r8   )r'   r,  r  r-  r   rR  r&  r   rH   bool_r*   r<   r.  r1   r1   r2   0test_series_constructor_overflow_uint_ea_with_na  s    zGTestSeriesConstructors.test_series_constructor_overflow_uint_ea_with_nac                 C   s`   t t jjd }t|t jgdd}ttt j|dgddt jddgt jd}t	
|| d S )Nr8   r+  r%   r  r   )r'   r,  r  r-  r   ry   r   rH   r1  r*   r<   )r-   r/  r_   r0   r1   r1   r2   .test_series_constructor_overflow_uint_with_nan  s    zETestSeriesConstructors.test_series_constructor_overflow_uint_with_nanc                 C   sP   t tjtjgdd}t ttjddgddtjddgtjd}t|| d S )Nr+  r%   r8   r  )r   r'   ry   r   rH   r1  r*   r<   r   r1   r1   r2   !test_series_constructor_ea_all_na  s    z8TestSeriesConstructors.test_series_constructor_ea_all_nac                 C   s>   t g d}|jdd}t|dd}d|jd< t|| d S )Nr   T)deepr   r%   r  r   )r   r   r   r   r*   r=   )r-   r@   r0   r6   r1   r1   r2   0test_series_from_index_dtype_equal_does_not_copy'  s
    
zGTestSeriesConstructors.test_series_from_index_dtype_equal_does_not_copyc                 C   s   t d d}tddg|d}tdd tddg}W d    n1 sL0    Y  t|| tddgd	d}tdd tddg}W d    n1 s0    Y  t|| d S )
Npyarrowstring[pyarrow_numpy]re   rg   r%   future.infer_stringTr8   r;   rE   importorskipr   rR  option_contextr*   r<   )r-   r&   r0   r6   r1   r1   r2   test_series_string_inference/  s    
**z3TestSeriesConstructors.test_series_string_inferencena_valuec                 C   sf   t d d}td|g|d}tdd td|g}W d    n1 sL0    Y  t|| d S )Nr7  r8  re   r%   r9  Tr:  )r-   r>  r&   r0   r6   r1   r1   r2   $test_series_string_with_na_inference=  s    
*z;TestSeriesConstructors.test_series_string_with_na_inferencec                 C   sd   t d tddgdd}tdd tddgd}W d    n1 sJ0    Y  t|| d S )	Nr7  re   r8   r8  r   r9  TrM   r:  r-   r0   r6   r1   r1   r2   #test_series_string_inference_scalarG  s
    
,z:TestSeriesConstructors.test_series_string_inference_scalarc                 C   sh   t d tddgdd}tdd" ttddg}W d    n1 sN0    Y  t|| d S )Nr7  re   rg   r8  r%   r9  T)	rE   r;  r   rR  r<  r'   rH   r*   r<   r@  r1   r1   r2   /test_series_string_inference_array_string_dtypeO  s
    
0zFTestSeriesConstructors.test_series_string_inference_array_string_dtypec                 C   sf   t d tddgdd}tdd  tddgdd}W d    n1 sL0    Y  t|| d S )	Nr7  re   rg   r8  r%   r9  Tru   r:  r   r1   r1   r2   /test_series_string_inference_storage_definitionW  s
    
.zFTestSeriesConstructors.test_series_string_inference_storage_definitionc                 C   st   t dd" tdddgdd}W d    n1 s40    Y  tddgddgdd}t|| |jjdkspJ d S )	Nr9  Tre   r8   rv   zstring[python]r   python)rR  r<  r   r*   r<   r&   Zstorage)r-   r6   r0   r1   r1   r2   +test_series_constructor_infer_string_scalar_  s
    0zBTestSeriesConstructors.test_series_constructor_infer_string_scalarc                 C   sf   t d ttjdgdd}tdd ttjdg}W d    n1 sL0    Y  t|| d S )Nr7  rg   r8  r%   r9  T)rE   r;  r   rR  r&  r<  r*   r<   r   r1   r1   r2   %test_series_string_inference_na_firstg  s
    
,z<TestSeriesConstructors.test_series_string_inference_na_firstc                 C   s   t tdgtd}td  t |}W d    n1 s:0    Y  |jtjksTJ ttdgtd}tjt	dd t |}W d    n1 s0    Y  |jtjksJ d S )Nz
2019-12-31r%   r  rB   )
r   r   r;   r*   rI  r&   r'   rz   r   rH  )r-   r6   r_   r@   r1   r1   r2    test_inference_on_pandas_objectso  s    &&z7TestSeriesConstructors.test_inference_on_pandas_objects)r   r   r   r3   r7   rA   rJ   rE   r  parametrizer`   rd   rk   rn   rt   r   r   r,   r  r   r   r'   ry   rm   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  rp   r   r  r  r  r  r!  r$  r  skip_array_manager_invalid_testr   r   r   r-  r.  r0  r1  r2  r8  rH   Zuint16Zuint32r  r:  r<  rB  rE  rF  rG  rK  rM  rT  rV  rX  rY  rb  rd  re  rf  ro  rp  rs  rt  rv  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  filterwarningsr  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   rR  r$  r'  r*  r0  r2  r3  r4  r6  r=  r&  r?  rA  rB  rC  rE  rF  rG  r1   r1   r1   r2   r"   4   s6  

	&
%


		



	!S







	



,		
/







		M			


	

	r"   c                   @   s   e Zd Zdd Zejddeje	e
gejddedgdd	 Zejje d
dejdg dddejggdd ZdS )"TestSeriesConstructorIndexCoercionc                 C   sB   t ddd}ttjdt||t}t	|j
tr>J d S )Nr  r   r  rv   )r   r   r'   r|   r}   r~   r^   r)   r;   rl   rN   r   )r-   r@   r6   r1   r1   r2   3test_series_constructor_datetimelike_index_coercion  s
    zVTestSeriesConstructorIndexCoercion.test_series_constructor_datetimelike_index_coercion	containerNr[   r   rw   c                    sJ   g dg dg} d ur* fdd|D }t ||d}t|jtsFJ d S )N)re   re   rg   rg   )r   r#  r   r#  c                    s   g | ]} |qS r1   r1   )rU   indrM  r1   r2   r]    rR   z_TestSeriesConstructorIndexCoercion.test_series_constructor_infer_multiindex.<locals>.<listcomp>rM   )r   rl   rN   r   )r-   rM  r[   Zindexesmultir1   rO  r2   (test_series_constructor_infer_multiindex  s
    zKTestSeriesConstructorIndexCoercion.test_series_constructor_infer_multiindexz/StringDType only available in numpy 2 and abover  r   re   rg   c                 C   sH   ddl m} tj|| d}t|}|jtjks4J ||k sDJ d S )Nr   )StringDTyper%   )Znumpy.dtypesrR  r'   rH   r   r&   rz   r4   )r-   r[   rR  r@  r/   r1   r1   r2    test_np_string_array_object_cast  s
    zCTestSeriesConstructorIndexCoercion.test_np_string_array_object_cast)r   r   r   rL  rE   r  rH  r'   rH   r   r   rp   rQ  Zskipifr
   ry   rS  r1   r1   r1   r2   rK  ~  s   		
rK  c                   @   s0   e Zd Zdd Zejdd Zejdd ZdS )TestSeriesConstructorInternalsc                 C   sR   t g d}t |j}t|| |sNt|jjd ts<J |jjd jsNJ d S )Nr   r   )	r   rH   r*   r<   rl   r+  r,  r!   Z
is_numeric)r-   Zusing_array_managerr6   r_   r1   r1   r2    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 sVJ d S 	NZ1hZ2hr  r%   r   FZ2015rD   )r   rR  rH   r+  r,  is_extensionr   r1   r1   r2   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 sJJ d S rV  )r   r+  r,  rW  r   r1   r1   r2   test_from_list_dtype  s    z3TestSeriesConstructorInternals.test_from_list_dtypeN)r   r   r   rU  r  rI  rX  rY  r1   r1   r1   r2   rT    s
   
rT  c                 C   s&   | }t |tsJ t |jts"J d S rS   )rl   r   rN   r   )Z(rand_series_with_duplicate_datetimeindexZdupsr1   r1   r2   r     s    r   zinput_dict,expectedr%   re   r8   c                 C   s    t t| g}t|| d S rS   )r'   rH   r   r*   r   )Z
input_dictr0   r_   r1   r1   r2   test_numpy_array  s    	rZ  c                  C   sJ   t ddg} tddg|  d}tddgtddgd}t|| d S )N)r  r   r   r8   ))re   Nr\  rv   r8   rv   rM   r[  r]  )r   r   r  r   r  r*   r<   )Zparam_indexr   r0   r1   r1   r2   test_index_ordered_dict_keys  s    r^  
input_listry   rv   y      ?      ?y       @       @c                 C   s0   t | }t |j}|jdks J t|| d S )NZ
complex128r  )r_  r6   r_   r1   r1   r2   test_series_with_complex_nan  s    	
r`  )Bcollectionsr   collections.abcr   r   r   Zdateutil.tzr   numpyr'   r   rE   Zpandas._libsr   r	   Zpandas.compat.numpyr
   Zpandas.errorsr   Zpandas.util._test_decoratorsutilZ_test_decoratorsr  Zpandas.core.dtypes.dtypesr   ZpandasrR  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zpandas._testingZ_testingr*   Zpandas.core.arraysr   r   r    Zpandas.core.internals.blocksr!   r"   rK  rT  r   r  rH  rH   r   r;   rZ  r^  complexr`  r1   r1   r1   r2   <module>   sh   L                Z(
