a
    oÝEb¹ ã                   @   sš  d dl mZmZ d dlmZmZmZ d dlZd dlZd dlZd dl	Z	d dl
Zd dlmZ d dlm  mZ d dlZd dlZd dlmZ d dlm  mZ d dlmZ d dlmZmZmZ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/ d dl0m1Z2 d dl3m4Z4m5Z5m6Z6m7Z7 d d	l8m9Z9 g d
¢Z:g d¢Z;G dd„ dƒZ<G dd„ dƒZ=G dd„ dƒZ>G dd„ dƒZ?dd„ Z@G dd„ dƒZAdS )é    )ÚOrderedDictÚabc)ÚdateÚdatetimeÚ	timedeltaN)Únp_version_under1p19)Úis_integer_dtype)ÚDatetimeTZDtypeÚIntervalDtypeÚPandasDtypeÚPeriodDtype)ÚCategoricalÚCategoricalIndexÚ	DataFrameÚDatetimeIndexÚIndexÚIntervalÚ
MultiIndexÚPeriodÚ
RangeIndexÚSeriesÚ	TimedeltaÚ	TimestampÚcutÚ
date_rangeÚisna)ÚDatetimeArrayÚIntervalArrayÚPeriodArrayÚSparseArray)Ú
Int64Index)Zfloat16Zfloat32Úfloat64)Úuint8Zuint16Zuint32Úuint64Zint8Zint16Úint32Úint64c                   @   sN  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Ze	j
 dddg¡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„ d!d„ d"d„ g¡d#d$„ ƒZe	j
 d%g ged&ƒed'ƒfg g ged(ƒed'ƒfd)d*„ d+D ƒged&ƒed'ƒfg¡d,d-„ ƒZd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zejd8d9„ ƒZejd:d;„ ƒZd<d=„ Ze	j
jed>d?�d@dA„ ƒZdBdC„ ZdDdE„ ZdFdG„ Z dHdI„ Z!dJdK„ Z"dLdM„ Z#e	j
 dNe$j%dOge&dP�e$ %d(dQ g¡dRge$j%dSge&dP�e$ %dTg¡d(dQ  d( gg¡dUdV„ ƒZ'dWdX„ Z(dYdZ„ Z)d[d\„ Z*d]d^„ Z+d_d`„ Z,dadb„ Z-dcdd„ Z.dedf„ Z/e	j
 dgd(e$j0dhdig¡djdk„ ƒZ1e	j
 dld(e$j0dhe2dmƒg¡dndo„ ƒZ3e	j
 dle$j0dhe2dmƒg¡dpdq„ ƒZ4drds„ Z5dtdu„ Z6dvdw„ Z7dxdy„ Z8dzd{„ Z9d|d}„ Z:d~d„ Z;d€d�„ Z<d‚dƒ„ Z=d„d…„ Z>d†d‡„ Z?dˆd‰„ Z@dŠd‹„ ZAdŒd�„ ZBdŽd�„ ZCd�d‘„ ZDd’d“„ ZEd”d•„ ZFd–d—„ ZGd˜d™„ ZHdšd›„ ZIe	j
 dœeJd�ƒeKdƒfeLd'dždŸ�eMd d¡ƒfeNd¢d£d¤�eOd£d¤�fg¡d¥d¦„ ƒZPd§d¨„ ZQd©dª„ ZRd«d¬„ ZSd­d®„ ZTd¯d°„ ZUd±d²„ ZVd³d´„ ZWe	j
jXdµd¶„ ƒZYd·d¸„ ZZe	j
 d¹dhe[e\dºƒƒd»d¼ge&e$j]fdhdhd»d¼gd e$ ^d ¡fdhe[e\dºƒƒd»d¼ge_e$ ^d½¡fi dhd¾d¿gdhe$j]fd¼d&ie[e\dºƒƒe[dÀƒe_e$ ^d½¡fg¡dÁdÂ„ ƒZ`e	j
 dÃg dÄ¢dÅeajbfg dÆ¢dÇeajcfg dÈ¢dÉeajdfg dÊ¢dËeajeff¡dÌdÍ„ ƒZfdÎdÏ„ ZgdÐdÑ„ ZhdÒdÓ„ ZidÔdÕ„ ZjdÖd×„ ZkdØdÙ„ ZldÚdÛ„ ZmdÜdÝ„ ZndÞdß„ Zodàdá„ Zpdâdã„ Zqe	j
 däeNdåƒggdæeNdåƒigdæeNdåƒgidæeNdåƒig¡dçdè„ ƒZrdédê„ Zsdëdì„ Ztdídî„ Zudïdð„ Zvdñdò„ Zwdódô„ Zxdõdö„ Zyd÷dø„ Zzdùdú„ Z{e	j
 dûe|e}g¡düdý„ ƒZ~e	j
 dûe|e}g¡dþdÿ„ ƒZ�d �d„ Z€�d�d„ Z��d�d„ Z‚�d�d„ Zƒ�d�d	„ Z„�d
�d„ Z…�d�d„ Z†e	j
 �dd+g fd+g f�dd+d+gf�dg g gfg g fg g gfd&gd(gfd&gd(ggfg �d¢g �d¢fg �d¢g �d¢gfg¡�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%„ Z�e	j
 �d&g �d'¢¡�d(�d)„ ƒZ‘�d*�d+„ Z’�d,�d-„ Z“�d.�d/„ Z”�d0�d1„ Z•�d2�d3„ Z–�d4�d5„ Z—�d6�d7„ Z˜�d8�d9„ Z™�d:�d;„ Zš�d<�d=„ Z›�d>�d?„ Zœ�d@�dA„ Z��dB�dC„ Zž�dD�dE„ ZŸe	j
 �dFe$ %dhdhdhdhe  ¡¡ dhg¡e$ %dhdhe  ¡¡ dhg¡e$ ¢�dG¡gdhgge$ ¢�dG¡geaj£ggdhge$ ¢�dG¡ggdhgeaj£ggeaj£ge$ ¢�dG¡ggeaj£gdhggg¡�dH�dI„ ƒZ¤e	j
 �dJg �dK¢¡e	j
 �dLg �dM¢¡�dN�dO„ ƒƒZ¥e	j
 �dJg �dK¢¡e	j
 �dLg �dP¢¡�dQ�dR„ ƒƒZ¦�dS�dT„ Z§�dU�dV„ Z¨�dW�dX„ Z©ejª�dY�dZ„ ƒZ«e	j
 �d[e¬g �d¢g �d¢gd&e$j0g�d\�e¬g �d¢g �d¢g�d]�d^e$j0g�d_�e¬g �d`¢g �da¢ge$j0�d]�d^e$j0g�d_�e¬g �db¢g �da¢ge$j0�d]�d^e$j0g�d_�e¬g �db¢g �da¢ge$j0d&d(d(g�d_�g¡�dc�dd„ ƒZ­�de�df„ Z®�dg�dh„ Z¯�di�dj„ Z°�dk�dl„ Z±�dm�dn„ Z²�do�dp„ Z³�dq�dr„ Z´�ds�dt„ Zµe	j
 �dLe¶j·e¶j¸ e¶j¹ e¶jº e¶j» e¶j¼ e¶j½ ¡�du�dv„ ƒZ¾e	j
 �dLe¶j¿e¶jÀ e¶jÁ ¡�dw�dx„ ƒZÂ�dy�dz„ ZÃe	j
jÄe	j
 �dLg �d{¢¡�d|�d}„ ƒƒZÅ�d~�d„ ZÆe	j
 �d€eÇe[�d�ƒƒeÈd&e$j0e$j0e$j0gƒeÉeLd'd&ƒeLd&džƒgƒeÊeajË�d‚�dƒd�d„�ƒg¡�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Ôe	j
 �d—d&d(g�d˜�d™ge[eÕ�dšd(�d›�dœ�ƒe[eÕ�dšd(�d›d£�d��ƒeLd'dždŸ�gg¡�dž�dŸ„ ƒZÖ�d �d¡„ Z×e	j
 �d¢�d£�d¤g¡�d¥�d¦„ ƒZØ�d§�d¨„ ZÙ�d©�dª„ ZÚ�d«�d¬„ ZÛe	j
 �d­d&gd(gge$ %d&gd(gg¡fe$ %d&gd(gg¡d&gd(ggfe$ %d&gd(gg¡e$ %d&gd(gg¡fg¡�d®�d¯„ ƒZÜ�d°�d±„ ZÝdhS (²  ÚTestDataFrameConstructorsc                 C   sr   t dddd�}|j dd¡}t|ƒ}t|d d …df |d d …df d	œƒ}t ||¡ |snt|jjƒdksnJ ‚d S )
Nú
2016-01-01é   ú
US/Pacific©ÚperiodsÚtzé   é   r   é   ©r   r/   )	r   Ú_dataÚreshaper   ÚtmÚassert_frame_equalÚlenÚ_mgrÚblocks)ÚselfÚusing_array_managerÚdtiZdtaÚdfÚexpected© r=   úd/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/pandas/tests/frame/test_constructors.pyÚ&test_constructor_from_2d_datetimearrayI   s    &z@TestDataFrameConstructors.test_constructor_from_2d_datetimearrayc                 C   sl   t dƒ d¡}td|idgd�}td|giƒ}t ||¡ t|dgdœƒ}t|gdgdœƒ}t ||¡ d S )Nz2019-11-03 01:00:00-0700zAmerica/Los_AngelesÚdtr   ©Úindexr/   )r@   Úvalue)r   Z
tz_convertr   r3   r4   )r8   r@   r;   r<   r=   r=   r>   Ú)test_constructor_dict_with_tzaware_scalarT   s    zCTestDataFrameConstructors.test_constructor_dict_with_tzaware_scalarc                 C   sÈ   t  dt jgddgg¡}t t¡� t|dd�}W d   ƒ n1 sD0    Y  |jj|jks`J ‚t	|j
d ƒsrJ ‚t t¡�" t|d ddd�}W d   ƒ n1 s¤0    Y  |j
d }t ||¡ d S )	Nr/   r.   r-   Úi8©Údtyper0   r   ©rG   Úname)ÚnpÚarrayÚnanr3   Úassert_produces_warningÚFutureWarningr   ÚvaluesrG   r   Úilocr   Úassert_series_equal)r8   Úarrr;   Úserr<   r=   r=   r>   Ú-test_construct_ndarray_with_nas_and_int_dtypea   s    *0
zGTestDataFrameConstructors.test_construct_ndarray_with_nas_and_int_dtypec                 C   s0   t t ¡ t ¡ gƒ}|d jt d¡ks,J ‚d S )Nr   úM8[ns])r   r   ÚnowrG   rJ   ©r8   r;   r=   r=   r>   Ú%test_construct_from_list_of_datetimeso   s    z?TestDataFrameConstructors.test_construct_from_list_of_datetimesc                 C   s\   t ddgdd�}| d¡}ttj| ¡ dd�dd�}|j|jksDJ ‚t|ƒ}t ||¡ d S )Nz2013-1-1 13:00z2013-1-2 14:00ÚB©rI   r)   ÚobjectrF   )	r   Útz_localizer   rJ   rK   ÚtolistrG   r3   rQ   )r8   ZnaiveÚidxr<   Úresultr=   r=   r>   Ú+test_constructor_from_tzaware_datetimeindexs   s    
zETestDataFrameConstructors.test_constructor_from_tzaware_datetimeindexc                 C   s|   t  dd¡}t j|gtd�}|tu r0| dd¡}d ddg¡}tjt	|d�� ||d	d� W d   ƒ n1 sn0    Y  d S )
NÚNaTÚnsrF   r/   ú|z+Could not convert object to NumPy timedeltaz=Invalid type for timedelta scalar: <class 'numpy.datetime64'>©Úmatchúm8[ns])
rJ   Ú
datetime64rK   r[   r   r2   ÚjoinÚpytestÚraisesÚ
ValueError)r8   Úframe_or_seriesZnatrR   Úmsgr=   r=   r>   Ú,test_array_of_dt64_nat_with_td64dtype_raises€   s    þÿzFTestDataFrameConstructors.test_array_of_dt64_nat_with_td64dtype_raisesÚkindÚmÚMc                 C   s|  |dkrd}t }nd}t}tjddd� |¡ dd¡}|tu rN|d d …d	f }||td�}|jj	d	 j
tkspJ ‚t|jj	d	  ¡ d	 |ƒsŽJ ‚|||ƒtd�}|jj	d	 j
tks´J ‚t|jj	d	  ¡ d	 |ƒsÒJ ‚|||ƒttƒd�}|jj	d	 j
tksüJ ‚t|jj	d	  ¡ d	 |ƒ�sJ ‚|tu �rxd
d„ |D ƒ}||td�}|jj	d	 j
tk�sXJ ‚t|jj	d	  ¡ d	 |ƒ�sxJ ‚d S )Nrq   rU   rf   r(   rE   rF   r-   r.   r   c                 S   s   g | ]}t |ƒ‘qS r=   ©r   ©Ú.0Úxr=   r=   r>   Ú
<listcomp>­   ó    zXTestDataFrameConstructors.test_datetimelike_values_with_object_dtype.<locals>.<listcomp>)r   r   rJ   ÚarangeÚviewr2   r   r[   r6   ÚarraysrG   Ú
isinstanceÚravelr   r   )r8   ro   rl   rG   Zscalar_typerR   ÚobjZsersr=   r=   r>   Ú*test_datetimelike_values_with_object_dtype�   s,     
zDTestDataFrameConstructors.test_datetimelike_values_with_object_dtypec                 C   st   t tdƒdd�}t tdƒdd�}t|dgd�}tg dgd�}t ||¡ t|dgd�}tg dgd�}t ||¡ d S )Né   r/   rZ   r   ©Úcolumns)r   Úranger   r3   r4   )r8   ru   Úyr_   r<   r=   r=   r>   Ú)test_series_with_name_not_matching_column²   s    zCTestDataFrameConstructors.test_series_with_name_not_matching_columnÚconstructorc                   C   s   t ƒ S ©N©r   r=   r=   r=   r>   Ú<lambda>Â   rw   z"TestDataFrameConstructors.<lambda>c                   C   s   t d ƒS r†   r‡   r=   r=   r=   r>   rˆ   Ã   rw   c                   C   s   t i ƒS r†   r‡   r=   r=   r=   r>   rˆ   Ä   rw   c                   C   s   t dƒS )Nr=   r‡   r=   r=   r=   r>   rˆ   Å   rw   c                   C   s   t g ƒS r†   r‡   r=   r=   r=   r>   rˆ   Æ   rw   c                   C   s   t dd„ dD ƒƒS )Nc                 s   s   | ]
}|V  qd S r†   r=   ©rt   Ú_r=   r=   r>   Ú	<genexpr>Ç   rw   ú5TestDataFrameConstructors.<lambda>.<locals>.<genexpr>r=   r‡   r=   r=   r=   r>   rˆ   Ç   rw   c                   C   s   t tdƒƒS ©Nr   ©r   r‚   r=   r=   r=   r>   rˆ   È   rw   c                   C   s
   t d d�S ©N©Údatar‡   r=   r=   r=   r>   rˆ   É   rw   c                   C   s
   t i d�S r�   r‡   r=   r=   r=   r>   rˆ   Ê   rw   c                   C   s
   t dd�S )Nr=   r�   r‡   r=   r=   r=   r>   rˆ   Ë   rw   c                   C   s
   t g d�S r�   r‡   r=   r=   r=   r>   rˆ   Ì   rw   c                   C   s   t dd„ dD ƒd�S )Nc                 s   s   | ]
}|V  qd S r†   r=   r‰   r=   r=   r>   r‹   Í   rw   rŒ   r=   r�   r‡   r=   r=   r=   r>   rˆ   Í   rw   c                   C   s   t tdƒd�S )Nr   r�   rŽ   r=   r=   r=   r>   rˆ   Î   rw   c                 C   s@   t ƒ }|ƒ }t|jƒdksJ ‚t|jƒdks0J ‚t ||¡ d S r�   )r   r5   rB   r�   r3   r4   )r8   r…   r<   r_   r=   r=   r>   Útest_empty_constructor¿   s
    z0TestDataFrameConstructors.test_empty_constructorz)emptylike,expected_index,expected_columnsr/   r   r.   c                 c   s   | ]
}|V  qd S r†   r=   r‰   r=   r=   r>   r‹   Ý   rw   z#TestDataFrameConstructors.<genexpr>r=   c                 C   s$   t ||d�}t |ƒ}t ||¡ d S )N©rB   r�   ©r   r3   r4   )r8   Z	emptylikeZexpected_indexZexpected_columnsr<   r_   r=   r=   r>   Útest_emptylike_constructorØ   s    	z4TestDataFrameConstructors.test_emptylike_constructorc                 C   s8   t  ¡ \}}t||d�}t|ƒ}|d jtjks4J ‚d S )NrA   Úfoo)r3   ZgetMixedTypeDictr   rG   rJ   Úobject_)r8   Zfloat_string_framerB   r‘   Zindexed_frameZunindexed_framer=   r=   r>   Útest_constructor_mixedå   s    z0TestDataFrameConstructors.test_constructor_mixedc                 C   sÐ   d}t jt|d��& tdg d¢itjd�}W d   ƒ n1 s>0    Y  |d jtksZJ ‚tt d¡ƒ}t d¡ 	¡ |d< d}t
jt|d�� t d¡|d	< W d   ƒ n1 s°0    Y  t d¡ 	¡ |d
< d S )NúBeither all columns will be cast to that dtype, or a TypeError willrd   Úa©rš   ÚbÚcrF   )é   r.   r–   z5Expected a 1D array, got an array with shape \(4, 2\)ÚtestZfoo2)r3   rM   rN   r   rJ   r!   rG   r[   Úonesr]   ri   rj   rk   )r8   rm   r–   r;   r=   r=   r>   Útest_constructor_cast_failureî   s    4,z7TestDataFrameConstructors.test_constructor_cast_failurec                 C   sD   t dgdgdgdœƒ}t |tdd�}d|d< |d d	 dks@J ‚d S )
Nç      ð?ç       @ç      @)Úcol1Úcol2Úcol3T)rG   Úcopyg      i@r¥   r   )r   Úfloat)r8   Zorig_dfZnew_dfr=   r=   r>   Útest_constructor_dtype_copy  s    z5TestDataFrameConstructors.test_constructor_dtype_copyc                 C   sB   t ddggƒ}t ||d jd�}d|d d< |jd dks>J ‚d S )Nr/   r.   r   rF   éc   ©r   r   )r   rG   rO   )r8   r;   Úshould_be_viewr=   r=   r>   Ú,test_constructor_dtype_nocast_view_dataframe
  s    zFTestDataFrameConstructors.test_constructor_dtype_nocast_view_dataframec                 C   s|   t ddgddggdd�}|sPt |j|d jd�}d|d d< |jd	 dksxJ ‚n(t |j|d jd�}|jjd jjsxJ ‚d S )
Nr/   r.   r-   rž   r%   rF   r   éa   r¬   )r   rO   rG   r6   rz   ÚflagsÚc_contiguous)r8   r9   r;   r­   Údf2r=   r=   r>   Ú+test_constructor_dtype_nocast_view_2d_array  s    zETestDataFrameConstructors.test_constructor_dtype_nocast_view_2d_arrayc                 C   s0   t jddgdd�}t|ƒ}t  |j|¡s,J ‚d S )Nrš   rœ   r[   rF   ©rJ   rK   r   Úshares_memoryrO   ©r8   rR   r;   r=   r=   r>   Ú"test_1d_object_array_does_not_copy  s    z<TestDataFrameConstructors.test_1d_object_array_does_not_copyc                 C   s8   t jddgddggdd�}t|ƒ}t  |j|¡s4J ‚d S )Nrš   rœ   r�   Údr[   rF   r´   r¶   r=   r=   r>   Ú"test_2d_object_array_does_not_copy#  s    z<TestDataFrameConstructors.test_2d_object_array_does_not_copyc                 C   s@   t ddgd dggtd�}|jd d u s*J ‚|jd dks<J ‚d S )Nr/   Ú2rš   rF   ©r/   r   r0   )r   r[   ÚlocrW   r=   r=   r>   Ú test_constructor_dtype_list_data*  s    z:TestDataFrameConstructors.test_constructor_dtype_list_datazNumPy change.)Úreasonc                 C   sÎ   t ƒ }t d¡}tjtdd�� t |gƒ W d   ƒ n1 s>0    Y  tjtdd�� t |gƒ W d   ƒ n1 sv0    Y  t dddgiƒ}tjtdd�� t ||gƒ W d   ƒ n1 sÀ0    Y  d S )Nr¬   zshape=\(1, 0, 0\)rd   ÚAr/   r.   zshape=\(2, 2, 1\))r   rJ   Úemptyri   rj   rk   )r8   rš   rœ   r=   r=   r>   Ú"test_constructor_list_of_2d_raises/  s    
((z<TestDataFrameConstructors.test_constructor_list_of_2d_raisesc                 C   sR   ddd„}ddd„}|dƒ}||ƒ |ddddd	œƒ}||ƒ |d
ƒ}||ƒ d S )Nc                 S   s†   | dkrt }dd„ |D ƒ}n| dkr6t}dd„ |D ƒ}t||ƒD ]\}}|j|ks@J ‚q@|d u rdi }| dd„ t||ƒD ƒ¡ t|ƒS )NÚintc                 S   s"   g | ]}t jt j d ¡|d�‘qS )é
   rF   )rJ   rK   ÚrandomÚrand©rt   r¸   r=   r=   r>   rv   C  rw   zjTestDataFrameConstructors.test_constructor_mixed_dtypes.<locals>._make_mixed_dtypes_df.<locals>.<listcomp>r©   c                 S   s&   g | ]}t jt jjd d d�|d�‘qS )rÃ   )ÚsizerF   )rJ   rK   rÄ   ÚrandintrÆ   r=   r=   r>   rv   F  s   c                 S   s   i | ]\}}||“qS r=   r=   )rt   r¸   rš   r=   r=   r>   Ú
<dictcomp>N  rw   zjTestDataFrameConstructors.test_constructor_mixed_dtypes.<locals>._make_mixed_dtypes_df.<locals>.<dictcomp>)ÚMIXED_INT_DTYPESÚMIXED_FLOAT_DTYPESÚziprG   Úupdater   )ÚtypÚadÚdtypesrz   r¸   rš   r=   r=   r>   Ú_make_mixed_dtypes_df?  s    ÿzVTestDataFrameConstructors.test_constructor_mixed_dtypes.<locals>._make_mixed_dtypes_dfc                 S   s8   |d u rt t }|D ]}|| v r| j| |ksJ ‚qd S r†   )rË   rÊ   rÐ   )r;   rÐ   r¸   r=   r=   r>   Ú_check_mixed_dtypesQ  s
    zTTestDataFrameConstructors.test_constructor_mixed_dtypes.<locals>._check_mixed_dtypesr©   r/   r–   Úbar©r¿   rY   ÚCrÂ   )N)Nr=   )r8   rÑ   rÒ   r;   r=   r=   r>   Útest_constructor_mixed_dtypes>  s    

z7TestDataFrameConstructors.test_constructor_mixed_dtypesc                 C   s^   t j d¡ t j¡}t j d¡ t j¡}t||dœƒ}|j|jjksHJ ‚|j|j	jksZJ ‚d S )NrÃ   ©rš   rœ   )
rJ   rÄ   rÅ   ÚastypeZ	complex64Ú
complex128r   rG   rš   rœ   ©r8   rš   rœ   r;   r=   r=   r>   Útest_constructor_complex_dtypesd  s
    z9TestDataFrameConstructors.test_constructor_complex_dtypesc                 C   sx   t ddd gi|d�}| ¡ }t dddgiƒ}t ||¡ |jd d u sJJ ‚t ddtjgi|d�}t |jd ¡stJ ‚d S )Nr¿   ru   rF   FTr»   )r   r   r3   r4   rP   rJ   rL   Úisnan)r8   Ústring_dtyper;   r_   r<   r=   r=   r>   Ú$test_constructor_dtype_str_na_valuesm  s    z>TestDataFrameConstructors.test_constructor_dtype_str_na_valuesc           	      C   sÌ   |j dd�}t|jjƒd d d… |j_|j}t|ƒ}t |jt	|jjƒ¡ t||d�}t |jt	|jjƒ¡ t |j|¡ t
 t|ƒ¡d d d… }t||ddgd�}t||d�jddgd�}t ||¡ d S )NFrA   éÿÿÿÿrÕ   rY   r“   r€   )Z
to_recordsÚlistrG   ÚnamesrB   r   r3   Úassert_index_equalr�   r   rJ   rx   r5   Úreindexr4   )	r8   Úfloat_frameZrecrB   r;   r²   ÚrngÚdf3r<   r=   r=   r>   Útest_constructor_recx  s    z.TestDataFrameConstructors.test_constructor_recc                 C   s8   t tjdtd�tjdtd�dœƒ}|jjtjks4J ‚d S )NrÃ   rF   r0   )r   rJ   r    ÚboolÚzerosrO   rG   Úbool_rW   r=   r=   r>   Útest_constructor_bool‹  s    "z/TestDataFrameConstructors.test_constructor_boolc                 C   s�   t jdd„ tddƒD ƒt jd�}td|iƒ}|d jt jks@J ‚g d¢}dd	g}t jt|ƒf|d�}||d d …< t|ƒ}|d
 jt jksŒJ ‚d S )Nc                 S   s   g | ]}d | ‘qS )ì            r=   ©rt   Úir=   r=   r>   rv   ‘  rw   zMTestDataFrameConstructors.test_constructor_overflow_int64.<locals>.<listcomp>r/   rÃ   rF   rš   ))l   –Yª2­< é  )l   FJLW]L* é   )l   ´MÏ:M…^ é-   )l   8²€M�a i  )l   r*R3_PvN rï   )ÚuidÚu8)Zscoreró   rò   )rJ   rK   r‚   r#   r   rG   ré   r5   )r8   rO   r_   Zdata_scoresrG   r‘   Z	df_crawlsr=   r=   r>   Útest_constructor_overflow_int64�  s     z9TestDataFrameConstructors.test_constructor_overflow_int64rO   rì   rF   éA   l           lûÿÿÿ        lûÿÿÿ        c                 C   s:   |d }t |ƒ}|d jtks"J ‚|d d |ks6J ‚d S r�   )r   rG   r[   )r8   rO   rC   r_   r=   r=   r>   Útest_constructor_int_overflow¤  s    z7TestDataFrameConstructors.test_constructor_int_overflowc                 C   s`   dd l }d}tt|ƒƒ}| |¡ dd„ |D ƒ}ttt|dgg| ƒƒƒ}|t|jƒks\J ‚d S )Nr   éd   c                 S   s   g | ]}d |d›�‘qS )r¿   r¸   r=   rí   r=   r=   r>   rv   ½  rw   zJTestDataFrameConstructors.test_constructor_ordereddict.<locals>.<listcomp>)rÄ   rà   r‚   Úshuffler   r   rÌ   r�   )r8   rÄ   ZnitemsÚnumsr<   r;   r=   r=   r>   Útest_constructor_ordereddict·  s    
z6TestDataFrameConstructors.test_constructor_ordereddictc                 C   sD  t jdd�}t jdd�dd … }t||dœƒ}t|ƒdks>J ‚t|ƒdksNJ ‚t  |d | d¡¡ tt tj	gd |j
g¡|jdd�}t  ||d ¡ t||dœg d	¢d
�}t|ƒt|ƒksÂJ ‚d|vsÎJ ‚t|d ƒ ¡ sâJ ‚ttƒ ƒdksôJ ‚d}tjt|d��( tdddœg d¢dœƒ W d   ƒ n1 �s60    Y  d S )Né   ©Znperr   ©r¥   r¦   é   r¥   r¦   ©rB   rI   )r¦   r§   Zcol4r€   r§   r   ú<Mixing dicts with non-Series may lead to ambiguous ordering.rd   rš   rœ   r×   r›   ©r¿   rY   )r3   ÚmakeTimeSeriesr   r5   rQ   Úrenamer   rJ   ZconcatenaterL   rO   rB   r   Úallri   rj   rk   )r8   Údatetime_seriesÚdatetime_series_shortÚframeÚexprm   r=   r=   r>   Útest_constructor_dictÁ  s.    ýþz/TestDataFrameConstructors.test_constructor_dictc                 C   s,   t ddddœiƒ}t |jtddgƒ¡ d S )Nr¿   r/   r.   ©Ú1rº   r  rº   )r   r3   râ   rB   r   ©r8   r  r=   r=   r>   Útest_constructor_dict_length1ç  s    z7TestDataFrameConstructors.test_constructor_dict_length1c                 C   s*   t g d¢ƒ}ti |d�}|j|u s&J ‚d S )N©r   r/   r.   rA   )r   r   rB   ©r8   r^   r  r=   r=   r>   Ú test_constructor_dict_with_indexì  s    z:TestDataFrameConstructors.test_constructor_dict_with_indexc                 C   sL   t g d¢ƒ}ti ||d�}|j|u s(J ‚|j|u s6J ‚t|jƒdksHJ ‚d S )Nr  r“   r-   )r   r   rB   r�   r5   Ú_seriesr  r=   r=   r>   Ú,test_constructor_dict_with_index_and_columnsò  s
    zFTestDataFrameConstructors.test_constructor_dict_with_index_and_columnsc                 C   s0   t g g dœddgd�}tj|jtdƒdd� d S )Nr  r¿   rY   r€   r   T©Úexact)r   r3   râ   rB   r   r  r=   r=   r>   Ú$test_constructor_dict_of_empty_listsú  s    z>TestDataFrameConstructors.test_constructor_dict_of_empty_listsc                 C   s^   t dd idgd�}t dd gidgd�}| dd¡d u s:J ‚| dd¡d u sNJ ‚t ||¡ d S )Nrš   r   rA   )r   Ú
_get_valuer3   r4   )r8   Z
frame_noneZframe_none_listr=   r=   r>   Útest_constructor_dict_with_noneÿ  s
    z9TestDataFrameConstructors.test_constructor_dict_with_nonec                 C   s‚   d}t jt|d�� tddiƒ W d   ƒ n1 s40    Y  t jt|d��" tddidgd� W d   ƒ n1 st0    Y  d S )Nú2If using all scalar values, you must pass an indexrd   rš   gffffffæ?r€   ©ri   rj   rk   r   )r8   rm   r=   r=   r>   Útest_constructor_dict_errors  s
    *z6TestDataFrameConstructors.test_constructor_dict_errorsÚscalarNÚDc                 C   s.   t d|idgd�}t dgd�}t ||¡ d S )Nrš   rœ   r€   r”   )r8   r  r_   r<   r=   r=   r>   Ú%test_constructor_invalid_items_unused  s    z?TestDataFrameConstructors.test_constructor_invalid_items_unusedrC   rL   c                    sÆ   d|dg‰ d|g‰ddgddgddgg‰‡ ‡‡fdd	„t dƒD ƒ}t|ƒ d¡jddd
�}ttjddd� dd¡ˆˆ d�}t ||¡ t|ˆd�jddd
�}t ||¡ t|ˆˆ d�}t ||¡ d S )Nr/   r-   rš   r   rž   r.   r   c                    s"   i | ]}ˆ | t ˆ| ˆd �“qS ©rA   rr   ©rt   r�   ©Úcolsr^   rO   r=   r>   rÉ     rw   zKTestDataFrameConstructors.test_constructor_dict_nan_key.<locals>.<dictcomp>©Zaxisr(   r%   rF   r“   rA   )r‚   r   Úsort_valuesrJ   rx   r2   r3   r4   ©r8   rC   r‘   r_   r<   r=   r   r>   Útest_constructor_dict_nan_key  s    
ÿz7TestDataFrameConstructors.test_constructor_dict_nan_keyc                    sæ   t d|dfd|fgƒ‰ t d|f|dfgƒ‰ddgdd	gdd
gg‰‡ ‡‡fdd„tdƒD ƒ}t|ƒ d¡jd|fdd�}ttjddd� dd¡ˆˆ d�}t ||¡ t|ˆd�jd|fdd�}t ||¡ t|ˆˆ d�}t ||¡ d S )N)é   é   é   é   rš   r.   r   r-   r/   rž   r   c                    s"   i | ]}ˆ | t ˆ| ˆd �“qS r  rr   r  r   r=   r>   rÉ   2  rw   zQTestDataFrameConstructors.test_constructor_dict_nan_tuple_key.<locals>.<dictcomp>r"  r(   r%   rF   r“   rA   )	r   r‚   r   r#  rJ   rx   r2   r3   r4   r$  r=   r   r>   Ú#test_constructor_dict_nan_tuple_key,  s    ÿz=TestDataFrameConstructors.test_constructor_dict_nan_tuple_keyc                 C   sL   t jdd�}t jdd�}||dœ}t|d�}t|tdƒd�}t  ||¡ d S )Nrû   rü   rþ   ©rœ   rš   r�   Úba©r‘   r�   )r3   r  r   rà   r4   )r8   r  r  r¸   r  r<   r=   r=   r>   Ú%test_constructor_dict_order_insertion?  s    

z?TestDataFrameConstructors.test_constructor_dict_order_insertionc                 C   sR   t tjddgdddgitjdgd�}t ddgddggtjdgd�}t ||¡ d S )Nr/   r.   r-   r€   )r   rJ   rL   r3   r4   ©r8   r_   r<   r=   r=   r>   Ú)test_constructor_dict_nan_key_and_columnsJ  s    $zCTestDataFrameConstructors.test_constructor_dict_nan_key_and_columnsc                 C   sl   g d¢}t  |¡}t||d�}t|ƒj ¡  ¡ s4J ‚g d¢}t  |¡}t||d�}t|ƒj ¡  ¡ shJ ‚d S )N)©r.   r-   ©r-   r-   r2  r“   )r2  r1  r2  )r   Úfrom_tuplesr   r   rO   r|   r  )r8   ÚtuplesÚmir;   r=   r=   r>   Útest_constructor_multi_indexP  s    

z6TestDataFrameConstructors.test_constructor_multi_indexc                 C   s¶   t dggdggddgd�}t ddgtddgdd�tdggdggd�d�}t ||¡ t dggdggddggd�}t ddgtddggddggd�tdggdggd�d�}t ||¡ d S )	Nr/   r.   ©r�   rB   r%   rF   r   )ZlevelsÚcodesr“   )r   r    r   r3   r4   ©r8   r;   r<   r=   r=   r>   Útest_constructor_2d_index]  s    ýýz3TestDataFrameConstructors.test_constructor_2d_indexc                 C   s   d}t jt|d��& tt d¡tdƒd� W d   ƒ n1 s>0    Y  d}t jt|d��( tddd	œg d
¢dœƒ W d   ƒ n1 sˆ0    Y  d}t jt|d��6 tt d¡ d¡g d¢t	ddd�d� W d   ƒ n1 sà0    Y  t 
g d¢g¡}d}t jt|d��& tdgtddƒ|d� W d   ƒ n1 �s:0    Y  t 
g d¢¡}d}t jt|d��& tdgtddƒ|d� W d   ƒ n1 �s’0    Y  t jtdd��* tt d¡g d¢dgd� W d   ƒ n1 �sÜ0    Y  d}t jt|d��. ttj dd¡g d¢dgd� W d   ƒ n1 �s.0    Y  d}t jt|d��0 ttj dd¡d d!gddgd� W d   ƒ n1 �s‚0    Y  d"}t jt|d��* ttd#ƒtd#d$ƒfd%d� W d   ƒ n1 �sÐ0    Y  d&}t jt|d�� td'd(d	œƒ W d   ƒ n1 �s0    Y  d S ))Nz)Empty data passed with indices specified.rd   r   r   r€   r   rš   rœ   r×   r›   r  z:Shape of passed values is \(4, 3\), indices imply \(3, 3\)é   )rž   r-   ©r–   rÓ   Úbazú
2000-01-01r-   ©r+   r7  ©rž   r   r(   z:Shape of passed values is \(1, 3\), indices imply \(1, 4\)rž   ©rB   r�   r‘   z:Shape of passed values is \(3, 1\), indices imply \(1, 4\)úMust pass 2-d input©r-   r-   r-   rÔ   r/   ú:Shape of passed values is \(2, 3\), indices imply \(1, 3\)r.   ú:Shape of passed values is \(2, 3\), indices imply \(2, 2\)r¿   rY   z,2 columns passed, passed data had 10 columnsrÃ   é   )r    Ztwosr  FT)ri   rj   rk   r   rJ   rÀ   rà   rx   r2   r   rK   r‚   ré   rÄ   rÅ   )r8   rm   rR   r=   r=   r>   Útest_constructor_error_msgsp  sF    46
ý$66:>@:z5TestDataFrameConstructors.test_constructor_error_msgsc                 C   s|   |dd„ t dƒD ƒƒ|dd„ t dƒD ƒƒdœ}t|ƒ}tdd„ | ¡ D ƒƒ}t ||¡ || ¡ ƒ}t|ƒ}t ||¡ d S )Nc                 s   s   | ]}|d | fV  qdS )g      $@Nr=   rs   r=   r=   r>   r‹   §  rw   zKTestDataFrameConstructors.test_constructor_subclass_dict.<locals>.<genexpr>rÃ   c                 s   s   | ]}|d | fV  qdS )g      4@Nr=   rs   r=   r=   r>   r‹   ¨  rw   rý   c                 S   s   i | ]\}}|t | ¡ ƒ“qS r=   )ÚdictÚitems)rt   ÚcolÚvalr=   r=   r>   rÉ   «  rw   zLTestDataFrameConstructors.test_constructor_subclass_dict.<locals>.<dictcomp>)r‚   r   rI  r3   r4   )r8   Zdict_subclassr‘   r;   Zrefdfr=   r=   r>   Útest_constructor_subclass_dict¤  s    þz8TestDataFrameConstructors.test_constructor_subclass_dictc           	      C   sx   ddl m} i }tj|d d d…< | ¡ D ]&\}}|tƒ}| | ¡ ¡ |||< q*t|ƒ}|j	|j
d�}t ||¡ d S )Nr   )ÚdefaultdictrY   rÃ   rA   )ÚcollectionsrM  rJ   rL   rI  rH  rÍ   Úto_dictr   rã   rB   r3   r4   )	r8   rä   rM  r‘   ÚkÚvÚdctr  r<   r=   r=   r>   Útest_constructor_defaultdict²  s    
z6TestDataFrameConstructors.test_constructor_defaultdictc                 C   sD   t  g d¢g¡}tdgdgdgdgdœg d¢d�}t |j|¡ d S )N)ç      @r¤   r£   r¢   rT  r¤   r£   r¢   )r¸   r�   rœ   rš   r€   )rJ   rK   r   r3   Úassert_numpy_array_equalrO   ©r8   r<   r;   r=   r=   r>   Útest_constructor_dict_blockÀ  s    þz5TestDataFrameConstructors.test_constructor_dict_blockc                 C   s    dddœddddœdœ}t |td	�}t|ƒd
ks4J ‚|d jtjksHJ ‚|d jtjks\J ‚t |ƒ}t|ƒd
kstJ ‚|d jtjksˆJ ‚|d jtjksœJ ‚d S )Nr/   r.   r
  r  rº   Ú3)r  rº   rX  r  rF   r-   rY   r¿   )r   r©   r5   rG   rJ   r!   r—   )r8   Ú	test_datar  r=   r=   r>   Útest_constructor_dict_castÈ  s    z4TestDataFrameConstructors.test_constructor_dict_castc                 C   s®   t ttdƒt d¡ƒƒt ttdƒtj d¡ƒƒdœ}d}tjt	|d�� t
|td�}W d   ƒ n1 sh0    Y  t|ƒdks‚J ‚|d jtjks–J ‚|d jtjksªJ ‚d S )	NrF  é   r  r™   rd   rF   r¿   rY   )rH  rÌ   r‚   r3   ZmakeStringIndexrJ   rÄ   ÚrandnrM   rN   r   r©   r5   rG   r—   r!   )r8   rY  rm   r  r=   r=   r>   Útest_constructor_dict_cast2Õ  s    þ*z5TestDataFrameConstructors.test_constructor_dict_cast2c                 C   s2   ddt jdœi}t|ƒ}t|d d tƒs.J ‚d S )NZCol1zA String)ZRow1ÚRow2r^  )rJ   rL   r   r{   r©   )r8   r¸   r;   r=   r=   r>   Ú!test_constructor_dict_dont_upcastã  s    z;TestDataFrameConstructors.test_constructor_dict_dont_upcastc                 C   s<   t ddgddggddgddgd�}t|d d tƒs8J ‚d S )Nr/   r.   rš   rœ   r“   )r   r{   rÂ   )r8   Údmr=   r=   r>   Ú"test_constructor_dict_dont_upcast2è  s    "z<TestDataFrameConstructors.test_constructor_dict_dont_upcast2c                 C   s<   dddœ}t |ƒ}t dd„ | ¡ D ƒƒ}tj||dd� d S )N©r/   r.   r-   r@  r×   c                 S   s   i | ]\}}|t |ƒ“qS r=   )rà   ©rt   rP  rQ  r=   r=   r>   rÉ   ñ  rw   zMTestDataFrameConstructors.test_constructor_dict_of_tuples.<locals>.<dictcomp>F©Zcheck_dtype)r   rI  r3   r4   ©r8   r‘   r_   r<   r=   r=   r>   Útest_constructor_dict_of_tuplesì  s    
z9TestDataFrameConstructors.test_constructor_dict_of_tuplesc                 C   sB   t dƒt ddƒdœ}t|ƒ}tg d¢g d¢dœƒ}t ||¡ d S )Nr-   r(   r×   r  )r-   rž   r   ©r‚   r   r3   r4   re  r=   r=   r>   Útest_constructor_dict_of_rangesô  s    z9TestDataFrameConstructors.test_constructor_dict_of_rangesc                 C   sH   t tdƒƒttdƒƒdœ}t|ƒ}tg d¢g d¢dœƒ}t ||¡ d S )Nr-   r×   r  ©r.   r/   r   )Úiterr‚   Úreversedr   r3   r4   re  r=   r=   r>   Ú"test_constructor_dict_of_iteratorsü  s    z<TestDataFrameConstructors.test_constructor_dict_of_iteratorsc                 C   sX   dd„ t dƒD ƒdd„ tt dƒƒD ƒdœ}t|ƒ}tg d¢g d¢dœƒ}t ||¡ d S )Nc                 s   s   | ]
}|V  qd S r†   r=   rí   r=   r=   r>   r‹     rw   zPTestDataFrameConstructors.test_constructor_dict_of_generators.<locals>.<genexpr>r-   r×   r  ri  )r‚   rk  r   r3   r4   re  r=   r=   r>   Ú#test_constructor_dict_of_generators  s    *z=TestDataFrameConstructors.test_constructor_dict_of_generatorsc                 C   s  ddddœddddœdd	d
dœdœ}t | ¡ ƒ}t|ƒ}tdd„ |D ƒt dd„ |D ƒ¡d�j}t |j¡|_t ||¡ dddddœ|d< | 	dd|d f¡ tdd„ |D ƒt
dd„ |D ƒdd�d�j}t
|jdd�|_t|ƒ}|j|j|jd�}t ||¡ d S )Nr   r/   r.   )©rî   rî   ©rî   Új©rp  rî   r(   r   rž   é   é   é	   ))rš   rš   r+  )rœ   r�   c                 S   s   g | ]}|d  ‘qS ©r/   r=   rs   r=   r=   r>   rv     rw   zNTestDataFrameConstructors.test_constructor_dict_multiindex.<locals>.<listcomp>c                 S   s   g | ]}|d  ‘qS ©r   r=   rs   r=   r=   r>   rv     rw   rA   g     À^@éo   )rƒ   rn  ro  rq  Úzc                 S   s   g | ]}|d  ‘qS ru  r=   rs   r=   r=   r>   rv     rw   c                 S   s   g | ]}|d  ‘qS rv  r=   rs   r=   r=   r>   rv     rw   F)Ztupleize_colsr7  )ÚsortedrI  r   r   r3  ÚTrB   r3   r4   Úinsertr   rã   r�   )r8   r¸   Z_dr;   r<   r=   r=   r>   Ú test_constructor_dict_multiindex  s.    


ýÿþ ÿz:TestDataFrameConstructors.test_constructor_dict_multiindexc           	   	      s¸   g d¢‰ ‡ fdd„}|t jƒ}|dd„ ƒ}|tƒ}tdd d d dœd dd d dœd d d	d dœd d d d
dœgdd„ ˆ D ƒd�}t|ƒ}t|ƒ}t|ƒ}t ||¡ t ||¡ t ||¡ d S )N)z
1984-02-19z
1988-11-06z
1989-12-03z
1990-03-15c                    s   ‡ fdd„t ˆƒD ƒS )Nc                    s"   i | ]\}}|ˆ |ƒd | i“qS ©r.   r=   ©rt   rî   Ús©r…   r=   r>   rÉ   +  rw   ziTestDataFrameConstructors.test_constructor_dict_datetime64_index.<locals>.create_data.<locals>.<dictcomp>©Ú	enumerater€  ©Zdates_as_strr€  r>   Úcreate_data*  s    zUTestDataFrameConstructors.test_constructor_dict_datetime64_index.<locals>.create_datac                 S   s   t  | d¡S )Nz%Y-%m-%d)r   Ústrptime©ru   r=   r=   r>   rˆ   .  rw   zRTestDataFrameConstructors.test_constructor_dict_datetime64_index.<locals>.<lambda>r   ©r   r/   r.   r-   r.   rž   r(   c                 S   s   g | ]}t |ƒ‘qS r=   )r   )rt   r@   r=   r=   r>   rv   8  rw   zTTestDataFrameConstructors.test_constructor_dict_datetime64_index.<locals>.<listcomp>rA   )rJ   rg   r   r   r3   r4   )	r8   r„  Zdata_datetime64Zdata_datetimeZdata_Timestampr<   Zresult_datetime64Zresult_datetimeZresult_Timestampr=   rƒ  r>   Ú&test_constructor_dict_datetime64_index&  s&    
üù
z@TestDataFrameConstructors.test_constructor_dict_datetime64_indexc           	   	      s¾   g d¢‰ ‡ fdd„}|dd„ ƒ}|dd„ ƒ}|dd„ ƒ}t dd d d d	œd d
d d d	œd d dd d	œd d d dd	œgdd„ ˆ D ƒd�}t |ƒ}t |ƒ}t |ƒ}t ||¡ t ||¡ t ||¡ d S )N©r/   r.   r-   rž   c                    s   ‡ fdd„t ˆƒD ƒS )Nc                    s"   i | ]\}}|ˆ |ƒd | i“qS r}  r=   r~  r€  r=   r>   rÉ   G  rw   zjTestDataFrameConstructors.test_constructor_dict_timedelta64_index.<locals>.create_data.<locals>.<dictcomp>r�  r€  ©Z	td_as_intr€  r>   r„  F  s    zVTestDataFrameConstructors.test_constructor_dict_timedelta64_index.<locals>.create_datac                 S   s   t  | d¡S ©Nr  )rJ   Útimedelta64r†  r=   r=   r>   rˆ   I  rw   zSTestDataFrameConstructors.test_constructor_dict_timedelta64_index.<locals>.<lambda>c                 S   s
   t | d�S )N)Údays)r   r†  r=   r=   r>   rˆ   J  rw   c                 S   s
   t | dƒS r‹  ©r   r†  r=   r=   r>   rˆ   K  rw   r   r‡  r.   rž   r(   c                 S   s   g | ]}t |d ƒ‘qS )r  rŽ  )rt   Útdr=   r=   r>   rv   T  rw   zUTestDataFrameConstructors.test_constructor_dict_timedelta64_index.<locals>.<listcomp>rA   r”   )	r8   r„  Zdata_timedelta64Zdata_timedeltaZdata_Timedeltar<   Zresult_timedelta64Zresult_timedeltaZresult_Timedeltar=   rŠ  r>   Ú'test_constructor_dict_timedelta64_indexB  s&    üù
zATestDataFrameConstructors.test_constructor_dict_timedelta64_indexc                 C   s¨   t jg d¢dd�}t jg d¢dd�}t||dœƒ}|d j|jksFJ ‚|d j|jksZJ ‚t| t¡ ¡ | t¡ ¡ dœƒ}|d j|jks�J ‚|d j|jks¤J ‚d S )	N)z2012-01ra   z2012-04rq   ©Úfreq)z
2012-02-01z
2012-03-01ra   r  r×   rš   rœ   )ÚpdZPeriodIndexr   rG   rØ   r[   r]   rÚ   r=   r=   r>   Útest_constructor_period_dict^  s    "z6TestDataFrameConstructors.test_constructor_period_dictc                 C   sN   |\}}t d|idgd�}|d j|ks,J ‚t dgdg|d�}t ||¡ d S )Nrš   r   rA   rA  )r   rG   r3   r4   )r8   Zea_scalar_and_dtypeZ	ea_scalarZea_dtyper;   r<   r=   r=   r>   Ú&test_constructor_dict_extension_scalark  s
    z@TestDataFrameConstructors.test_constructor_dict_extension_scalarz
data,dtypez2020-01r   )ÚleftÚrightr%   r—  z
2011-01-01ú
US/Eastern©r,   c                 C   sl   t ddgddg|d�}|d j|ks(J ‚|d j|ks:J ‚tj|gd |d�}t ||dœƒ}t ||¡ d S )	Nr   r/   rš   rœ   rA  r.   rF   r×   )r   rG   r“  rK   r3   r4   )r8   r‘   rG   r;   rR   r<   r=   r=   r>   Ú&test_constructor_extension_scalar_datat  s    z@TestDataFrameConstructors.test_constructor_extension_scalar_datac                 C   sÂ   t jddd�}ttj dd¡|d�}i }|jD ](}|jD ]}| ||¡| 	|i ¡|< q8q.t||d�}t
 ||¡ i }|jD ](}|jD ]}| ||¡| 	|i ¡|< q„qzt||d�j}t
 ||¡ d S )Nz1/1/2000r   r?  rÃ   r€   rA   )r“  Úperiod_ranger   rJ   rÄ   r\  r�   rB   r  Ú
setdefaultr3   r4   rz  )r8   rå   r;   r‘   rJ  Úrowr_   r=   r=   r>   Ú"test_nested_dict_frame_constructor‹  s    



z<TestDataFrameConstructors.test_nested_dict_frame_constructorc                 C   sâ  |dt d�}t|g d¢ddgd�}t|jƒdks4J ‚t|jƒdksFJ ‚t|dƒd	gg d
¢d�}t|jƒdkspJ ‚t|jƒdks‚J ‚|tju r�d nt}t 	|¡�* t|g d¢ddgtj
d�}W d   ƒ n1 sÎ0    Y  |tju rö|jjtj
ksôJ ‚n>| ¡  ¡  ¡ �sJ ‚|jjtjk�s J ‚t|jƒ ¡ �s4J ‚d}tjt|d��$ t|g d¢dgd� W d   ƒ n1 �sr0    Y  d}tjt|d��& t|d	dgddgd� W d   ƒ n1 �s¼0    Y  tjtdd��( t|dƒg d¢dgd� W d   ƒ n1 �s0    Y  t|ƒ}tj|jttdƒƒdd� tj|jttdƒƒdd� t|ddgd�}tj|jttdƒƒdd� t|g d¢d�}tj|jttdƒƒdd� t|dƒƒ}t|jƒdk�s¾J ‚t|dƒƒ}t|jƒdk�sÞJ ‚d S )Nr1  rF   rÔ   r/   r.   r7  r-   )r-   r¿   rb  ©r�   rB   rG   rD  rd   rE  rY   rB  rC  Tr  rA   r€   )r   r-   r   )r-   r   )r©   r   r5   rB   r�   rJ   r    rN   r3   rM   r%   rO   rG   r   r  r!   ri   rj   rk   râ   r   r‚   )r8   rÀ   Úmatr  Úwarnrm   r=   r=   r>   Ú_check_basic_constructorŸ  sH    ÿ$
468z2TestDataFrameConstructors._check_basic_constructorc                 C   s8   |   tj¡ tddgddgdgd�}t|ƒdks4J ‚d S )Nr–   rÓ   r   r/   r¿   r“   r.   )r¢  rJ   r    r   r5   r  r=   r=   r>   Útest_constructor_ndarrayÜ  s    z2TestDataFrameConstructors.test_constructor_ndarrayc                 C   sª   |   tj¡ tjdtd�}d|d< d|d< t|g d¢dd	gd
�}d|d d ksTJ ‚d|d d	 kshJ ‚tjdtd�}t|g d¢dd	gd
�}t t ||k¡ ¡s¦J ‚d S )Nr1  rF   r¢   r¬   r£   ©r/   r.   rÔ   r/   r.   r7  r¿   rÕ   )r¢  ÚmaÚ
masked_allr©   r   rJ   r  Úasarray)r8   r   r  r=   r=   r>   Útest_constructor_maskedarrayâ  s    z6TestDataFrameConstructors.test_constructor_maskedarrayc              	   C   s<  t jdtd�}t|g d¢ddgd�}t|jƒdks6J ‚t|jƒdksHJ ‚t t 	||k¡ ¡sbJ ‚t|g d¢ddgtj
d�}|jjtj
ksŽJ ‚t  |¡}d|d	< d|d
< t|g d¢ddgd�}d|d d ksÒJ ‚d|d d ksæJ ‚t jddd�}t|g d¢ddgd�}t|jƒdk�sJ ‚t|jƒdk�s2J ‚t|ƒj ¡ �sFJ ‚d}tjt|d��d t ¡ �: tjdtdd� t|g d¢ddgtjd�}W d   ƒ n1 �s¤0    Y  W d   ƒ n1 �sÄ0    Y  |jjtjk�sâJ ‚t  |¡}d|d	< d|d
< t|g d¢ddgd�}d|d  d¡d k�s.J ‚d|d  d¡d k�sJJ ‚t jdtd�}t|g d¢ddgd�}t|jƒdk�s‚J ‚t|jƒdk�s–J ‚t t 	||k¡ ¡�s²J ‚t|g d¢ddgtd�}|jjtk�sÜJ ‚t  |¡}d|d	< d|d
< t|g d¢ddgd�}|d d du �s"J ‚|d d du �s8J ‚d S )Nr1  rF   rÔ   r/   r.   r7  r-   rŸ  r¬   r¤  r¿   rÕ   rU   z'datetime64\[ns\] values and dtype=int64rd   Úignorezelementwise comparison failed)ÚcategoryÚmessagerE   TF)r¥  r¦  rÂ   r   r5   rB   r�   rJ   r  r§  r!   rO   rG   r¨   r   r3   rM   rN   ÚwarningsÚcatch_warningsÚfilterwarningsÚDeprecationWarningr%   ry   rè   r[   )r8   r   r  Zmat2rm   r=   r=   r>   Ú%test_constructor_maskedarray_nonfloatò  sb    

ýÿF

z?TestDataFrameConstructors.test_constructor_maskedarray_nonfloatc                 C   sÀ   t jdtd� ¡ }t|ddgddgd�}ttjtjgtjtjgdœddgddgtd	�}t ||¡ t j	dtd� ¡ }t|ddgddgd�}td
d
gd
d
gdœddgddgtd	�}t ||¡ d S )N)r.   r.   rF   r¿   rY   r/   r.   r7  r  rŸ  r¢   )
r¥  r¦  r©   Zharden_maskr   rJ   rL   r3   r4   r    )r8   Zmat_hardr_   r<   r=   r=   r>   Ú%test_constructor_maskedarray_hardened<  s$    üüz?TestDataFrameConstructors.test_constructor_maskedarray_hardenedc                    s¼   t jjt jjdddgd�dgd d�‰ ˆ  tj¡‰ t t	¡� t
ˆ td�}W d   ƒ n1 s^0    Y  t
t jdtd�dd	gd
�}t ||¡ t
‡ fdd„ˆ jjD ƒtd�}t ||¡ d S )Nr   )r   ú<f8)Úpricer²  rF   F©Úmask©r   r.   r   r³  r€   c                    s   i | ]}|ˆ | “qS r=   r=   )rt   rI   r�   r=   r>   rÉ   b  rw   zSTestDataFrameConstructors.test_constructor_maskedrecarray_dtype.<locals>.<dictcomp>)rJ   r¥  rK   ré   ry   ÚmrecordsZ	mrecarrayr3   rM   rN   r   rÂ   r4   rG   rá   )r8   r_   r<   Zaltr=   r�   r>   Ú%test_constructor_maskedrecarray_dtypeR  s    ÿ*z?TestDataFrameConstructors.test_constructor_maskedrecarray_dtypec              	   C   sö  t jtjddd�}dt ddg¡fdt ddg¡fd	t d
dg¡fg}|d d … D ]*\}}| d| tjj|ddgd�f¡ qR| dtj 	d¡f¡ | dtjjddgdd�f¡ t
 |d¡D �]0}t|Ž \}}tj||d�}dd„ |D ƒ}t t¡� t|ƒ}	W d   ƒ n1 �s0    Y  t||d�}
||	|
ƒ t t¡�& t||d d d… d�}	W d   ƒ n1 �sn0    Y  t||d d d… d�}
||	|
ƒ t t¡�  t|ddgd�}	W d   ƒ n1 �sÊ0    Y  t||ddgd�}
||	|
ƒ q¾d S )NT)Zcheck_index_typeZcheck_column_typer©   ç      ø?r£   rÂ   r/   r.   Ústrr   ÚdefZmasked1_Fr´  r¦  r}  Zmasked_noner¢   g      @r-   )rá   c                 S   s(   i | ] \}}|t |d ƒr | ¡ n|“qS )Úfilled)Úhasattrr¼  rc  r=   r=   r>   rÉ     rw   zHTestDataFrameConstructors.test_constructor_mrecarray.<locals>.<dictcomp>r€   rß   rA   r7  )Ú	functoolsÚpartialr3   r4   rJ   rK   Úappendr¥  Zmasked_arrayr¦  Ú	itertoolsÚcombinationsrÌ   r·  Z
fromarraysrM   rN   r   )r8   Zassert_fr_equalrz   rI   rR   Úcombrá   r‘   Zmrecsr_   r<   r=   r=   r>   Útest_constructor_mrecarraye  s:    ÿýÿ(
6
0z4TestDataFrameConstructors.test_constructor_mrecarrayc                 C   s   t g d�}|jjdksJ ‚d S )NrA   r¬   )r   rO   ÚshaperW   r=   r=   r>   Útest_constructor_corner_shape•  s    
z7TestDataFrameConstructors.test_constructor_corner_shapez%data, index, columns, dtype, expectedrÃ   rš   rœ   r!   r–   rÓ   r   c                 C   s"   t ||||ƒ}|jj|ksJ ‚d S r†   )r   rO   rG   )r8   r‘   rB   r�   rG   r<   r;   r=   r=   r>   Útest_constructor_dtype™  s    z0TestDataFrameConstructors.test_constructor_dtypezdata,input_dtype,expected_dtype)TFNÚboolean©r¢   r£   NZFloat64)r/   r.   NZInt64r›   Ústringc                 C   s(   t d|i|d�}|d j|ƒ ks$J ‚d S )Nrš   rF   )r   rG   )r8   r‘   Zinput_dtypeZexpected_dtyper;   r=   r=   r>   Ú0test_constructor_dtype_nullable_extension_arrays§  s    zJTestDataFrameConstructors.test_constructor_dtype_nullable_extension_arraysc                 C   sŠ   ddddddœ}t |t d¡d�}|d	 jtjks6J ‚|d
 jtjksJJ ‚|d jtjks^J ‚|d jtjksrJ ‚|d jtjks†J ‚d S )Nr/   Tr¤   y              @r–   )rÂ   rè   r©   Úcomplexr[   rÃ   rA   rÂ   rè   r©   rÌ  r[   )	r   rJ   rx   rG   r%   rê   r!   rÙ   r—   )r8   r‘   r;   r=   r=   r>   Ú!test_constructor_scalar_inference¶  s    z;TestDataFrameConstructors.test_constructor_scalar_inferencec                 C   s|   t tj d¡ddœƒ}t |d jdgd dœƒ}t ||¡ tjt	dd�� t dddœƒ W d   ƒ n1 sn0    Y  d S )NrÃ   Tr×   rš   zmust pass an indexrd   F)
r   rJ   rÄ   r\  rO   r3   r4   ri   rj   rk   )r8   r;   r  r=   r=   r>   Ú#test_constructor_arrays_and_scalarsÀ  s
    z=TestDataFrameConstructors.test_constructor_arrays_and_scalarsc                 C   s8   t |ƒ}t ||¡ t |tjd�}|jjtjks4J ‚d S ©NrF   )r   r3   r4   rJ   r%   rO   rG   )r8   rä   r;   Z	df_castedr=   r=   r>   Útest_constructor_DataFrameÈ  s    z4TestDataFrameConstructors.test_constructor_DataFramec                 C   s*   t t ƒ dd�}t g dd�}t ||¡ d S )Nr[   rF   r”   )r8   Úactualr<   r=   r=   r>   Ú test_constructor_empty_dataframeÏ  s    z:TestDataFrameConstructors.test_constructor_empty_dataframec                 C   s¢  t j d¡}t|dgt  d¡d�}|jjdks2J ‚t j d¡}t|ƒ}|jjdksVJ ‚|jjdksfJ ‚tddgt  d¡d�}|jjdksŒJ ‚tddgd�}|jjd	ksªJ ‚tt  d¡d
�}|jjdksÊJ ‚t jddgt	d� 
dd¡}d}tjt|d��& t|ddgdgtd� W d   ƒ n1 �s$0    Y  tt|jƒƒ}t ||¡ tt jdtd�t jdt jd�dœt  d¡d
�}t|jƒdk�sŠJ ‚|jjt jk�sžJ ‚d S )NrÃ   r¿   r7  r.   r   rY   )rÃ   r.   r€   ©r   r.   rA   )rÃ   r   r–   rÓ   rF   r/   z(could not convert string to float: 'foo'rd   ©rB   r�   rG   r  )rJ   rÄ   r\  r   rx   rO   ÚndimrÅ  rK   r[   r2   ri   rj   rk   r©   r  r3   r4   r    rÂ   r!   r5   r�   rG   )r8   rä   rR   r`  r   rm   r=   r=   r>   Útest_constructor_moreÕ  s2    6þz/TestDataFrameConstructors.test_constructor_morec                 C   sx   t g g d�}t g d�}t ||¡ t g ddgd�}t i ddgd�}t ||¡ dd„ }t |ƒ ddgd�}t ||¡ d S )NrA   r¿   rY   r€   c                   s   s   d S r†   r=   r=   r=   r=   r>   Ú	empty_gen  s    zHTestDataFrameConstructors.test_constructor_empty_list.<locals>.empty_genr”   )r8   r;   r<   r×  r=   r=   r>   Útest_constructor_empty_listü  s    
z5TestDataFrameConstructors.test_constructor_empty_listc                 C   s|   t ddgddggddgd�}t|d ƒs,J ‚|d jtjks@J ‚t dt d	¡iƒ}d
d„ td	ƒD ƒ}t |ƒ}t ||¡ d S )Nr/   rš   r.   rœ   Únumrº  r-  r   rÃ   c                 S   s   g | ]}t  |¡‘qS r=   ©rJ   rK   rs   r=   r=   r>   rv     rw   zLTestDataFrameConstructors.test_constructor_list_of_lists.<locals>.<listcomp>)	r   r   rG   rJ   r—   rx   r‚   r3   r4   )r8   r;   r<   r‘   r_   r=   r=   r>   Útest_constructor_list_of_lists  s    z8TestDataFrameConstructors.test_constructor_list_of_listsc                 C   sx   t ddgƒ}tjd d gtd�}||d< |d |d< t|ƒ}tt |¡ƒ}t ||¡ |jdksbJ ‚t 	|d j
|¡ d S )Nr/   r.   rF   r   )r.   r/   )r   rJ   rK   r[   r   r“  r3   r4   rÅ  rU  rO   )r8   rS   rR   r;   r<   r=   r=   r>   Ú.test_nested_pandasarray_matches_nested_ndarray  s    zHTestDataFrameConstructors.test_nested_pandasarray_matches_nested_ndarrayc                 C   sZ   t dƒt dƒg}tg d¢g d¢g|d�}t |¡}tg d¢g d¢g|d�}t ||¡ d S )NÚabcdZcdefr‰  ©rž   r   r(   rr  r€   )rà   r   r   Zfrom_arraysr3   r4   )r8   rz   r_   r5  r<   r=   r=   r>   Ú2test_constructor_list_like_data_nested_list_column)  s
    
zLTestDataFrameConstructors.test_constructor_list_like_data_nested_list_columnc                 C   s^   t dƒt dƒg}d}tjt|d��( tg d¢g d¢g|d� W d   ƒ n1 sP0    Y  d S )Nr   Úcdez#3 columns passed, passed data had 4rd   r‰  rÞ  r€   ©rà   ri   rj   rk   r   ©r8   rz   rm   r=   r=   r>   Ú0test_constructor_wrong_length_nested_list_column3  s    zJTestDataFrameConstructors.test_constructor_wrong_length_nested_list_columnc                 C   s^   t dƒt dƒg}d}tjt|d��( tg d¢g d¢g|d� W d   ƒ n1 sP0    Y  d S )NrÝ  rà  zall arrays must be same lengthrd   r‰  rÞ  r€   rá  râ  r=   r=   r>   Ú2test_constructor_unequal_length_nested_list_column;  s    zLTestDataFrameConstructors.test_constructor_unequal_length_nested_list_columnr‘   ú
2021-01-01ru   c                 C   s:   t |g d¢dgd�}t dtdƒgd iƒ}t ||¡ d S )Nr  ru   r“   rå  r-   )r   r   r3   r4   re  r=   r=   r>   Ú&test_constructor_one_element_data_listD  s    z@TestDataFrameConstructors.test_constructor_one_element_data_listc                 C   sj   G dd„ dt jƒ}|ddgƒ|ddgƒg}ddg}t||d	�}tddgddgg|d	�}tj||d
d� d S )Nc                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )zPTestDataFrameConstructors.test_constructor_sequence_like.<locals>.DummyContainerc                 S   s
   || _ d S r†   )Ú_lst)r8   Úlstr=   r=   r>   Ú__init__X  s    zYTestDataFrameConstructors.test_constructor_sequence_like.<locals>.DummyContainer.__init__c                 S   s   | j  |¡S r†   )rç  Ú__getitem__©r8   Únr=   r=   r>   rê  [  s    z\TestDataFrameConstructors.test_constructor_sequence_like.<locals>.DummyContainer.__getitem__c                 S   s
   | j  ¡ S r†   )rç  Ú__len__rë  r=   r=   r>   rí  ^  s    zXTestDataFrameConstructors.test_constructor_sequence_like.<locals>.DummyContainer.__len__N)Ú__name__Ú
__module__Ú__qualname__ré  rê  rí  r=   r=   r=   r>   ÚDummyContainerW  s   rñ  r/   rš   r.   rœ   rÙ  rº  r€   Frd  )r   ÚSequencer   r3   r4   )r8   rñ  Zlst_containersr�   r_   r<   r=   r=   r>   Útest_constructor_sequence_likeS  s    
z8TestDataFrameConstructors.test_constructor_sequence_likec                 C   s˜   dd l }td|  dtdƒ¡iƒ}tdttdƒƒiƒ}tj||dd� tttdƒƒttdƒƒgƒ}t|  dtdƒ¡|  dtdƒ¡gƒ}tj||dd� d S )Nr   r¿   rî   rÃ   Frd  )rK   r   r‚   rà   r3   r4   )r8   rK   r_   r<   r=   r=   r>   Útest_constructor_stdlib_arrayg  s    $z7TestDataFrameConstructors.test_constructor_stdlib_arrayc                 C   s,   t tdƒƒ}t ttdƒƒƒ}t ||¡ d S ©NrÃ   ©r   r‚   rà   r3   r4   r/  r=   r=   r>   Útest_constructor_ranget  s    z0TestDataFrameConstructors.test_constructor_rangec                 C   s@   t tdƒtdƒgƒ}t ttdƒƒttdƒƒgƒ}t ||¡ d S rõ  rö  r/  r=   r=   r>   Útest_constructor_list_of_rangesz  s    z9TestDataFrameConstructors.test_constructor_list_of_rangesc                 C   s:   G dd„ dƒ}t g d¢gd ƒ}t |ƒ ƒ}t ||¡ d S )Nc                   @   s   e Zd Zdd„ ZdS )zATestDataFrameConstructors.test_constructor_iterable.<locals>.Iterc                 s   s   t dƒD ]}g d¢V  qd S )NrÃ   rb  )r‚   )r8   rî   r=   r=   r>   Ú__iter__‚  s    zJTestDataFrameConstructors.test_constructor_iterable.<locals>.Iter.__iter__N)rî  rï  rð  rù  r=   r=   r=   r>   ÚIter�  s   rú  rb  rÃ   r”   )r8   rú  r<   r_   r=   r=   r>   Útest_constructor_iterable  s    
z3TestDataFrameConstructors.test_constructor_iterablec                 C   s0   t ttdƒƒƒ}t ttdƒƒƒ}t ||¡ d S rõ  ©r   rj  r‚   rà   r3   r4   r/  r=   r=   r>   Útest_constructor_iteratorŠ  s    z3TestDataFrameConstructors.test_constructor_iteratorc                 C   sH   t ttdƒƒttdƒƒgƒ}t ttdƒƒttdƒƒgƒ}t ||¡ d S rõ  rü  r/  r=   r=   r>   Ú"test_constructor_list_of_iterators�  s    z<TestDataFrameConstructors.test_constructor_list_of_iteratorsc                 C   s˜   dd„ t dƒD ƒ}dd„ t dƒD ƒ}ttt dƒƒtt dƒƒgƒ}t||gƒ}t ||¡ dd„ t dƒD ƒ}t|ƒ}tt dƒddœƒ}tj||dd	� d S )
Nc                 s   s   | ]
}|V  qd S r†   r=   rí   r=   r=   r>   r‹   —  rw   zGTestDataFrameConstructors.test_constructor_generator.<locals>.<genexpr>rÃ   c                 s   s   | ]
}|V  qd S r†   r=   rí   r=   r=   r>   r‹   ˜  rw   c                 s   s   | ]}|d gV  qdS )rš   Nr=   rí   r=   r=   r>   r‹   ž  rw   rš   r0   Frd  )r‚   r   rà   r3   r4   )r8   Zgen1Zgen2r<   r_   Úgenr=   r=   r>   Útest_constructor_generator”  s    z4TestDataFrameConstructors.test_constructor_generatorc                 C   s&   t i gƒ}t dgd�}t ||¡ d S )Nr   rA   r”   r/  r=   r=   r>   Útest_constructor_list_of_dicts£  s    
z8TestDataFrameConstructors.test_constructor_list_of_dictsÚ	dict_typec                 C   st   t ddggddgd�}|ƒ }dg|d< dg|d< t |ƒ}t ||¡ |ƒ }d|d< d|d< t |gƒ}t ||¡ d S )Nr.   r/   rœ   rš   r€   r”   )r8   r  r<   r‘   r_   r=   r=   r>   Ú,test_constructor_ordered_dict_preserve_order©  s    


zFTestDataFrameConstructors.test_constructor_ordered_dict_preserve_orderc                 C   sª   |ƒ }d|d< d|d< |ƒ }d|d< d|d< dddœ}t ddgddggddgd�}t ||gƒ}t ||¡ t ddgddgddggddgd�}t |||gƒ}t ||¡ d S )Nr.   rœ   r/   rš   r+  r€   r”   )r8   r  Zrow_oneZrow_twoZ	row_threer<   r_   r=   r=   r>   Ú0test_constructor_ordered_dict_conflicting_orders¼  s    
"zJTestDataFrameConstructors.test_constructor_ordered_dict_conflicting_ordersc                 C   sT   dd„ t dƒD ƒ}t|ƒ}tg d¢g d¢g d¢dœg d¢g d¢d�}t ||¡ d S )Nc                 S   s"   g | ]}t |g d ¢t|ƒd�‘qS )©rœ   rš   r�   rÿ   )r   rº  rí   r=   r=   r>   rv   Ó  rw   z[TestDataFrameConstructors.test_constructor_list_of_series_aligned_index.<locals>.<listcomp>r-   r  r  )Ú0r  rº   r7  rg  )r8   Úseriesr_   r<   r=   r=   r>   Ú-test_constructor_list_of_series_aligned_indexÒ  s    ýzGTestDataFrameConstructors.test_constructor_list_of_series_aligned_indexc                 C   sJ   G dd„ dt ƒ}dddœ}||ƒg}|g}t|ƒ}t|ƒ}t ||¡ d S )Nc                   @   s   e Zd ZdS )zTTestDataFrameConstructors.test_constructor_list_of_derived_dicts.<locals>.CustomDictN©rî  rï  rð  r=   r=   r=   r>   Ú
CustomDictÝ  s   r
  r¹  r-   r×   )rH  r   r3   r4   )r8   r
  r¸   Zdata_customr‘   Zresult_customr_   r=   r=   r>   Ú&test_constructor_list_of_derived_dictsÜ  s    

z@TestDataFrameConstructors.test_constructor_list_of_derived_dictsc                 C   sT   t j d¡t j d¡dœ}tjtdd�� t|ƒ W d   ƒ n1 sF0    Y  d S )NrÃ   rs  r  z%All arrays must be of the same lengthrd   )rJ   rÄ   r\  ri   rj   rk   r   )r8   r‘   r=   r=   r>   Útest_constructor_raggedé  s    z1TestDataFrameConstructors.test_constructor_raggedc                 C   sD   t tdƒƒ}tddi|d�}tdg d¢i|d�}tj||dd� d S )Nr-   rš   r   rA   )r   r   r   Frd  )r   r‚   r   r3   r4   )r8   r^   r;   r<   r=   r=   r>   Útest_constructor_scalarî  s    z1TestDataFrameConstructors.test_constructor_scalarc                 C   s"   t |d |jdgd�}| ¡  d S )Nr¿   r“   )r   rB   r¨   )r8   rä   r;   r=   r=   r>   Ú test_constructor_Series_copy_bugô  s    z:TestDataFrameConstructors.test_constructor_Series_copy_bugc                 C   sÖ   i }ddddœ|d< t g d¢g d¢d�|d	< t|ƒ}|jjs@J ‚tjtd
d��( tddgdddœdœƒ W d   ƒ n1 s|0    Y  tddgt ddgddgd�dœƒ}tddgddgdœddgd�}t ||¡ d S )Nr/   r.   r-   r<  r¿   )rž   r-   r.   r/   )rÓ   Zquxr=  r–   rA   rY   zambiguous orderingrd   rš   rœ   r×   r  )	r   r   rB   Zis_monotonicri   rj   rk   r3   r4   re  r=   r=   r>   Ú&test_constructor_mixed_dict_and_Seriesø  s    6"z@TestDataFrameConstructors.test_constructor_mixed_dict_and_Seriesc                 C   s8   ddgdg}t |ƒ}t ddgddggƒ}t ||¡ d S )Nr/   r.   ©r-   rž   r-   rž   r”   re  r=   r=   r>   Ú test_constructor_mixed_type_rows	  s    z:TestDataFrameConstructors.test_constructor_mixed_type_rowsztuples,lists)r=   r=   rb  r@  c                 C   s    t |ƒ}t |ƒ}t ||¡ d S r†   r”   )r8   r4  Úlistsr_   r<   r=   r=   r>   Útest_constructor_tuple  s    z0TestDataFrameConstructors.test_constructor_tuplec                 C   s4   t dddgiƒ}t dtddgƒiƒ}t ||¡ d S )Nr¿   r¤  r  ©r   r   r3   r4   r/  r=   r=   r>   Útest_constructor_list_of_tuples"  s    z9TestDataFrameConstructors.test_constructor_list_of_tuplesc                 C   sŽ   ddl m} |dtdƒƒ}|ddƒ|ddƒg}tddgddgd	œƒ}t|ƒ}t ||¡ tddgddgd
œƒ}t|ddgd�}t ||¡ d S )Nr   )Ú
namedtupleZPandasÚabr/   r-   r.   rž   r×   )rƒ   rx  rƒ   rx  r€   )rN  r  rà   r   r3   r4   )r8   r  Znamed_tupler4  r<   r_   r=   r=   r>   Ú$test_constructor_list_of_namedtuples'  s    z>TestDataFrameConstructors.test_constructor_list_of_namedtuplesc                 C   sd   ddl m} |ddtfdtfgƒ}|ddƒ|ddƒg}tddgddgdœƒ}t|ƒ}t ||¡ d S )	Nr   ©Úmake_dataclassÚPointru   rƒ   r-   r/   ©ru   rƒ   )Údataclassesr  rÂ   r   r3   r4   )r8   r  r  r‘   r<   r_   r=   r=   r>   Ú$test_constructor_list_of_dataclasses6  s    z>TestDataFrameConstructors.test_constructor_list_of_dataclassesc                 C   s”   ddl m} |ddtfdtfgƒ}|ddtfdtfdtfgƒ}|dd	ƒ|d
d	d	ƒg}tdtjgd	d	gtjd
gtjd	gdœƒ}t|ƒ}t ||¡ d S )Nr   r  r  ru   rƒ   ÚHLineÚx0Úx1r-   r/   )ru   rƒ   r   r!  )r  r  rÂ   r   rJ   rL   r3   r4   )r8   r  r  r  r‘   r<   r_   r=   r=   r>   Ú7test_constructor_list_of_dataclasses_with_varying_typesA  s    "ÿzQTestDataFrameConstructors.test_constructor_list_of_dataclasses_with_varying_typesc                 C   sv   ddl m} |ddtfdtfgƒ}d}tjtt |¡d��( t|ddƒddd	œgƒ W d   ƒ n1 sh0    Y  d S )
Nr   r  r  ru   rƒ   z0asdict() should be called on dataclass instancesrd   r/   r  )	r  r  rÂ   ri   rj   Ú	TypeErrorÚreÚescaper   )r8   r  r  rm   r=   r=   r>   Ú1test_constructor_list_of_dataclasses_error_thrownQ  s
    zKTestDataFrameConstructors.test_constructor_list_of_dataclasses_error_thrownc              	   C   sr   dddddœdddd	d
œdddddddœg}t g d¢g d¢g d¢g d¢g d¢g d¢dœƒ}t |ƒ}t ||¡ d S )Nr/   rž   rr  rÃ   )ÚFirstÚSecondÚThirdÚFourthr   r.   r&  rs  )r(  r'  r*  r)  r(   r-   r;  rt  é   r)  )r(  r'  r*  r)  ÚYYYÚXXXrb  r@  )rr  rs  rt  )rÃ   r&  r;  )NNr+  )NNr)  )r'  r(  r)  r*  r,  r-  r”   )r8   r‘   r<   r_   r=   r=   r>   Ú#test_constructor_list_of_dict_order\  s    ýúÿ
z=TestDataFrameConstructors.test_constructor_list_of_dict_orderc                 C   s†  t g d¢g d¢dd�}t|ƒ}|jd dks0J ‚t |j|j¡ tj d¡}t |dd�}t|ƒ}td|iƒ}t 	||¡ t |t
dd	ƒd
�}t|ƒ}td|iƒ}t 	||¡ d}tjt|d��  t|ddgd� W d   ƒ n1 sâ0    Y  t g dtd�}t|ƒ}|jd dk�sJ ‚t |dd�}t||gƒj}t||dœddgd�}t 	||¡ t||gƒj}t||dœddgd�}t 	||¡ d S )Nrb  r›   ru   rÿ   r   rÃ   rZ   r-   r)  rA   z<Shape of passed values is \(10, 1\), indices imply \(10, 2\)rd   r/   r.   r€   ©rI   rG   )ru   ú	Unnamed 0r0  r»   )r   r   r�   r3   râ   rB   rJ   rÄ   r\  r4   r‚   ri   rj   rk   r[   rz  )r8   rš   r;   rR   r  r<   rm   Ús1r=   r=   r>   Útest_constructor_Series_namedp  s4    .z7TestDataFrameConstructors.test_constructor_Series_namedc                 C   s€   t tdƒdd�}t tdƒdd�}t t|dgd�| ¡ ¡ t t|dgd�| ¡ ¡ t|dgd�jshJ ‚t|dgd�js|J ‚d S )Nr   r   rZ   r/   r€   )r   r‚   r3   r4   r   Úto_framerÀ   )r8   Ús0r1  r=   r=   r>   Ú)test_constructor_Series_named_and_columns–  s    zCTestDataFrameConstructors.test_constructor_Series_named_and_columnsc                 C   s¸   t g d¢g d¢dd�}t g d¢g d¢d�}tddgƒ}t||d�}t| |¡ƒ}|jd dksbJ ‚t ||¡ t||d�}t| |¡ƒ}|jd dksšJ ‚t |j|¡ t ||¡ d S )	Nrb  r›   ru   rÿ   rA   rš   rœ   r   )	r   r   r   rã   r�   r3   r4   râ   rB   )r8   r1  Ús2Zother_indexÚdf1Zexp1r²   Zexp2r=   r=   r>   Ú+test_constructor_Series_differently_indexed¤  s    zETestDataFrameConstructors.test_constructor_Series_differently_indexedz#name_in1,name_in2,name_in3,name_out))r^   r^   r^   r^   )r^   r^   NN)r^   NNN)Úidx1Úidx2NN)r9  r9  r:  N)r9  r:  Zidx3N)NNNNc           
      C   s¬   t g d¢|d�t g d¢|d�t g d¢|d�g}dd„ t|g d¢ƒD ƒ}t|ƒ}t g d¢|d�}td	d
dtjtjgtjd	d
dtjgtjtjd	d
dgdœ|d�}	t ||	¡ d S )Nr›   rZ   )rœ   r�   r¸   )r�   r¸   Úec                 S   s"   i | ]\}}|t g d ¢|d�“qS )r  rA   rr   )rt   rî   r�   r=   r=   r>   rÉ   Ë  s   zJTestDataFrameConstructors.test_constructor_index_names.<locals>.<dictcomp>)ru   rƒ   rx  ©rš   rœ   r�   r¸   r;  r   r/   r.   rA   )r   rÌ   r   rJ   rL   r3   r4   )
r8   Zname_in1Zname_in2Zname_in3Zname_outÚindicesr  r_   Zexp_indr<   r=   r=   r>   Útest_constructor_index_names¸  s"    ýÿýú	z6TestDataFrameConstructors.test_constructor_index_namesc                 C   s\   t |jd d… ƒ}t |jd d… ƒ}t|j||d�}t |jt|ƒ¡ t |jt|ƒ¡ d S )Nr   r-   r“   )rà   rB   r�   r   r6   r3   râ   r   )r8   rä   rB   r�   r_   r=   r=   r>   Útest_constructor_manager_resizeÜ  s
    z9TestDataFrameConstructors.test_constructor_manager_resizec                 C   s˜   t |d t|d ƒdœddgd�}t ||jd d …ddgf ¡ d}tjt|d��2 t |d t|d ƒd d… dœƒ W d   ƒ n1 sŠ0    Y  d S )Nr¿   rY   r  r€   zdoes not match index lengthrd   éþÿÿÿ)r   rà   r3   r4   r¼   ri   rj   rk   )r8   rä   r;   rm   r=   r=   r>   Ú%test_constructor_mix_series_nonseriesä  s    ÿz?TestDataFrameConstructors.test_constructor_mix_series_nonseriesc                 C   st   d}t jt|d��, ttjdgddggtjd�}W d   ƒ n1 sD0    Y  ttjdgddggƒ}t  ||¡ d S )Nz6float-dtype values containing NaN and an integer dtyperd   r/   r   rF   )r3   rM   rN   r   rJ   rL   r%   r4   ©r8   rm   r;   r<   r=   r=   r>   Ú%test_constructor_miscast_na_int_dtypeî  s
    :z?TestDataFrameConstructors.test_constructor_miscast_na_int_dtypec                 C   s^   t ddggddgd�}t ddggƒ}ddg|_t ||¡ t jdgddgd�}t ||¡ d S )Nrs  r   rš   r€   )rs  r   )r   r�   r3   r4   Zfrom_records)r8   r;   ZedfZidfr=   r=   r>   Ú"test_constructor_column_duplicatesõ  s    
z<TestDataFrameConstructors.test_constructor_column_duplicatesc                 C   s¦   t ddgddgtd�}t ddgddgtd�}t ||¡ t ddgddgtjd�}t ||¡ t ddgddgtjd�}t ||¡ t ddgddgdd�}t ||¡ d S )Nr   r/   rÔ  ZU5)r   r[   rº  r3   r4   rJ   Zstr_Zunicode_rV  r=   r=   r>   Ú(test_constructor_empty_with_string_dtype  s    zBTestDataFrameConstructors.test_constructor_empty_with_string_dtypec                 C   s.   t g dg|d�}t dg|d�}t ||¡ d S )NÚc1rÔ  ©r�   rG   r”   )r8   Znullable_string_dtyper<   r;   r=   r=   r>   Ú,test_constructor_empty_with_string_extension  s    zFTestDataFrameConstructors.test_constructor_empty_with_string_extensionc                 C   s�  t dg d¢g d¢d�}t |t t |j¡ d¡|j|jƒ¡ t dg d¢g d¢d�}t |t t |j¡ d¡|j|jƒ¡ t dd	d
gddgd�}t |t tj	ddgddggt
d�d	d
gddgd�¡ d}tjt|d�� t dd	d
gƒ W d   ƒ n1 sø0    Y  tjt|d��  t dddgd� W d   ƒ n1 �s80    Y  d}tjt|d��& t dd	d
gddgtƒ W d   ƒ n1 �s‚0    Y  d S )Nç        rb  r›   r“   r!   r   r%   rš   r/   r.   r�   rF   z*DataFrame constructor not properly called!rd   r€   zincompatible data and dtype)r   r3   r4   rJ   ré   rÅ  rØ   rB   r�   rK   r[   ri   rj   rk   r#  r©   )r8   r;   rm   r=   r=   r>   Útest_constructor_single_value  s2    ÿÿýþ	,0z7TestDataFrameConstructors.test_constructor_single_valuec                 C   sò  t  t j¡j}t  t j¡j}t  d¡j}t  t j¡j}tdddtdƒtdddddƒd	œt  	d
¡d�}|j
}tt  d¡gt  |¡gd  t  |¡gd  tdƒd�}t ||¡ tdddddd|t jd|d�|t jd|d�it  	d
¡d�}|j
}tt  d¡gt  d¡g t  d¡g t  d¡g t  |¡g ddd||gd�}t ||¡ tdddddd|t jdgd
 |d�|t jdgd
 |d�it  	d
¡d�}|j
}tt  d¡gt  d¡g t  d¡g t  d¡g t  |¡g ddd||gd�}t ||¡ d S )NrU   r/   r–   rÓ   Z20010101éÑ  r.   r   )r¿   rY   rÕ   r  ÚErÃ   rA   r%   ZABCDErš   r¢   rœ   r�   rF   r!   r[   )rJ   rG   Úint_rI   Zfloat_r—   r   r   r   rx   rÐ   r   rà   r3   rQ   rK   )r8   ZintnameZ	floatnameZdatetime64nameZ
objectnamer;   r_   r<   r=   r=   r>   Útest_constructor_with_datetimes4  sŠ    ûø

ÿþüûø


ÿ
þ
ý
üúûø


ÿ
þ
ý
üúz9TestDataFrameConstructors.test_constructor_with_datetimesc                 C   s6   t dddd�}dd„ |D ƒ}t|ƒ}|jdks2J ‚d S )Nr>  r  rÃ   ©Ústartr’  r+   c                 S   s   g | ]}|  ¡ ‘qS r=   ©Úto_pydatetime©rt   Útsr=   r=   r>   rv     rw   zNTestDataFrameConstructors.test_constructor_with_datetimes1.<locals>.<listcomp>rU   )r   r   rG   )r8   ÚindÚ	datetimesZ
datetime_sr=   r=   r>   Ú test_constructor_with_datetimes1{  s    z:TestDataFrameConstructors.test_constructor_with_datetimes1c                 C   sv   t dddd�}dd„ |D ƒ}dd„ |D ƒ}t|dgd	�}||d
< |j}tt d¡t d¡gdd
gd�}t ||¡ d S )Nr>  r  rÃ   rO  c                 S   s   g | ]}|  ¡ ‘qS r=   rQ  rS  r=   r=   r>   rv   †  rw   zNTestDataFrameConstructors.test_constructor_with_datetimes2.<locals>.<listcomp>c                 S   s   g | ]}|  ¡ ‘qS r=   )r   rS  r=   r=   r>   rv   ‡  rw   rV  r€   Údatesúdatetime64[ns]r[   rA   )r   r   rÐ   r   rJ   rG   r3   rQ   )r8   rU  rV  rX  r;   r_   r<   r=   r=   r>   Ú test_constructor_with_datetimes2ƒ  s    þz:TestDataFrameConstructors.test_constructor_with_datetimes2c                 C   s�   t  d¡}| tdddƒ¡}td|idgd�}|jd |ks@J ‚t |jt	ddiƒ¡ td|igƒ}|jd |ksvJ ‚t |jt	ddiƒ¡ d S )	Nr˜  éÜ  r/   zEnd Dater   rA   r¬   údatetime64[ns, US/Eastern])
ÚpytzÚtimezoneZlocalizer   r   Úiatr3   rQ   rÐ   r   )r8   r,   r@   r;   r=   r=   r>   Ú test_constructor_with_datetimes3‘  s    
ÿÿz:TestDataFrameConstructors.test_constructor_with_datetimes3c                 C   s”   t ddd�}td|iƒ}|jd jd u s,J ‚t dddd�}td|iƒ}t|jd jƒdks^J ‚t dddd�}td|iƒ}t|jd jƒdks�J ‚d S )	NÚ20130101r-   r?  rC   r¬   ÚUTCr*   r˜  )r   r   r_  r,   rº  )r8   Údrr;   r=   r=   r>   Ú test_constructor_with_datetimes4£  s    z:TestDataFrameConstructors.test_constructor_with_datetimes4c                 C   s^   t ddddd�}td| ¡ jdd�iƒ}tƒ }||d< t ||¡ td|iƒ}t ||¡ d S )	Nú1/1/2011r   Ú10sr˜  ©r+   r’  r,   rš   T©Zdrop©r   r   Z	to_seriesZreset_indexr3   r4   )r8   rî   r<   r;   r=   r=   r>   Ú test_constructor_with_datetimes5°  s    z:TestDataFrameConstructors.test_constructor_with_datetimes5c                 C   sV   t ddddd�}t dddd�}t||dœƒ}t| ¡ jdd	�|dœƒ}t ||¡ d S )
Nre  r   rf  r˜  rg  ©r+   r’  r×   Trh  ri  )r8   rî   Zi_no_tzr;   r<   r=   r=   r>   Ú test_constructor_with_datetimes6½  s
    z:TestDataFrameConstructors.test_constructor_with_datetimes6rR   ra   c                 C   s*   t |ƒj}tt d¡gƒ}t ||¡ d S )NrY  )r   rÐ   r   rJ   rG   r3   rQ   )r8   rR   r_   r<   r=   r=   r>   Ú%test_constructor_datetimes_with_nullsÅ  s    
z?TestDataFrameConstructors.test_constructor_datetimes_with_nullsÚorder)ÚKr¿   rÕ   ÚFrG   )zdatetime64[M]zdatetime64[D]zdatetime64[h]zdatetime64[m]zdatetime64[s]zdatetime64[ms]zdatetime64[us]rY  c                 C   sT   t jg d¢g d¢g||d�}t|ƒ}tg d¢g d¢gƒ}|j|d�}t ||¡ d S )N)z
2015-01-01z
2015-01-02z
2015-01-03)z
2017-01-01z
2017-01-02z
2017-02-03©rG   rn  rF   )rJ   rK   r   rØ   r3   r4   ©r8   rn  rG   Únar;   r<   r=   r=   r>   Ú!test_constructor_datetimes_non_nsØ  s    þúþÿz;TestDataFrameConstructors.test_constructor_datetimes_non_ns)ztimedelta64[D]ztimedelta64[h]ztimedelta64[m]ztimedelta64[s]ztimedelta64[ms]ztimedelta64[us]útimedelta64[ns]c                 C   s†   t jt  dd¡t  dd¡gt  dd¡t  dd¡gg||d�}t|ƒ d¡}ttddƒtddƒgtddƒtddƒggƒ}t ||¡ d S )Nr/   r  r.   rž   r   rq  ru  )rJ   rK   rŒ  r   rØ   r   r3   r4   rr  r=   r=   r>   Ú!test_constructor_timedelta_non_nsù  s    þúþÿz;TestDataFrameConstructors.test_constructor_timedelta_non_nsc                 C   s&  t dd„ tdƒD ƒƒ}|j}tt d¡gd ƒ}t ||¡ t dd„ tdƒD ƒƒ}|j}tt d¡gd ƒ}t ||¡ t ddd	giƒ}|jjd
 t d¡ks¢J ‚t ddgƒ}|jjd
 t d¡ksÈJ ‚t ddgƒ}|jjd
 t d¡ksîJ ‚t dddgiƒ}|jjd
 t d¡k�sJ ‚t dddgiƒ}|jjd
 t d¡k�sFJ ‚t dditdƒd�}|jjd
 t d¡k�svJ ‚t dditdƒd�}|jjd
 t d¡k�s¦J ‚t g d¢g d¢t	dƒdd„ tdƒD ƒg d¢dœƒ}|j}tt d¡t d¡t d¡t d¡t d¡gt	dƒd�}t ||¡ d S )Nc                 S   s   g | ]}t  d ¡‘qS )r   )rJ   rx   rs   r=   r=   r>   rv     rw   zSTestDataFrameConstructors.test_constructor_for_list_with_dtypes.<locals>.<listcomp>r   rÂ   c                 S   s    g | ]}t jt  d ¡dd�‘qS )r   r$   rF   )rJ   rK   rx   rs   r=   r=   r>   rv     rw   r$   rš   l        l       r   r%   r/   r.   r¢   r£   r!   r-   rA   )r/   r.   rž   rr  )g333333ó?gffffff@gffffff@g333333@rÝ  c                 S   s   g | ]}t d ddƒ‘qS )éÐ  r/   )r   rí   r=   r=   r>   rv   B  rw   rž   )r¢   r.   rT  rr  r<  r[   rY  Zabcde)
r   r‚   rÐ   r   rJ   rG   r3   rQ   rP   rà   )r8   r;   r_   r<   r=   r=   r>   Ú%test_constructor_for_list_with_dtypes  sR    ûÿ	ûø
z?TestDataFrameConstructors.test_constructor_for_list_with_dtypesc                 C   s@   t |dd�}d|d< |d dk ¡ s(J ‚|d dk ¡ r<J ‚d S )NT©r¨   r   r¿   )r   r  )r8   rä   Úcopr=   r=   r>   Útest_constructor_frame_copyS  s    z5TestDataFrameConstructors.test_constructor_frame_copyc                 C   sÜ   |s^t |jƒ}d|jd< |jd dk ¡ s.J ‚t |jdd�}d|jd< |jd dk ¡ rØJ ‚nz|j ¡ }t |ƒ}|jjd jjs„J ‚d|d< |jd dksžJ ‚t |dd�}|jjd jjr¾J ‚d	|d< |jd d	ksØJ ‚d S )
Nr   Try  r(   r   r÷   r¬   Fiè  )	r   rO   r  r¨   r6   rz   r°   r±   rP   )r8   rä   r9   r;   rR   r=   r=   r>   Útest_constructor_ndarray_copyY  s     



z7TestDataFrameConstructors.test_constructor_ndarray_copyc                 C   sB   |j }td|d idd�}d|d d d …< |d dk ¡ r>J ‚d S )Nr¿   Try  r   )r  r   r  )r8   rä   r  r;   r=   r=   r>   Útest_constructor_series_copyr  s    z6TestDataFrameConstructors.test_constructor_series_copyr;   rA   gš™™™™™ñ?gš™™™™™@r€   r‡  rÞ  )rI  r/   r.   r¤   c                 C   sú   t t|jƒƒD ]}|jd d …|f  qt t|jƒ¡t|jƒ }t|ƒdkr�tjt	dd��$ |j
d d …tjf  W d   ƒ qö1 s„0    Y  nft|ƒdkrÌt |jd d …|d f |j
d d …tjf ¡ n*t |jd d …|f |j
d d …tjf ¡ d S )Nr   z^nan$rd   r/   )r‚   r5   r�   rP   rJ   rx   r   ri   rj   ÚKeyErrorr¼   rL   r3   rQ   r4   )r8   r;   rî   Zindexerr=   r=   r>   Útest_constructor_with_nas{  s    40z3TestDataFrameConstructors.test_constructor_with_nasc                 C   s:   t dtjdgiƒ}|d jtjks&J ‚|d d r6J ‚d S )Nrš   Fr/   )r   rJ   rL   rG   r—   )r8   r¸   r=   r=   r>   Ú&test_constructor_lists_to_object_dtypeœ  s    z@TestDataFrameConstructors.test_constructor_lists_to_object_dtypec                 C   sZ   t g d¢ƒ}t |¡ dd¡}t |d¡}t||jd�}t||||dœƒ}t ||¡ d S )NrÔ   rß   r/   r  rF   r‡  )	r   rJ   rK   r2   Zbroadcast_tor   rG   r3   r4   )r8   ÚcatrR   r_   r<   r=   r=   r>   Ú*test_constructor_ndarray_categorical_dtype¢  s    zDTestDataFrameConstructors.test_constructor_ndarray_categorical_dtypec                 C   sÔ   t dtdƒidd�}ttdƒddd�}t |d |¡ ttdƒdd�}| ¡ }ttdƒddd�}t |d |¡ |jdd�}ttdƒddd�}t |d |¡ t tdƒdd�}ttdƒddd�}t |d |¡ d S )	Nr¿   r   rª  rF   rH   r   r–   rZ   )r   rà   r   r3   rQ   r3  )r8   r;   r<   r  r_   r=   r=   r>   Útest_constructor_categorical¬  s    z6TestDataFrameConstructors.test_constructor_categoricalc                 C   sl   d}t jt|d��" tttdƒƒgƒ}W d   ƒ n1 s:0    Y  tdttdƒdd�iƒ}t  ||¡ d S )Nú%will be changed to match the behaviorrd   r   r   rª  rF   ©r3   rM   rN   r   r   rà   r   r4   rB  r=   r=   r>   Ú-test_construct_from_1item_list_of_categoricalÃ  s
    0zGTestDataFrameConstructors.test_construct_from_1item_list_of_categoricalc                 C   sŒ   d}t jt|d��, tttdƒƒttdƒƒgƒ}W d   ƒ n1 sD0    Y  tttdƒdd�ttdƒdd�dœdd	gd
�}t  ||¡ d S )Nr„  rd   r   Zabdrª  rF   r0   r   r/   r€   r…  rB  r=   r=   r>   Ú(test_construct_from_list_of_categoricalsË  s    :þûzBTestDataFrameConstructors.test_construct_from_list_of_categoricalsc                 C   s€   d}t jt|d��( tttdƒƒtdƒgƒ}W d   ƒ n1 s@0    Y  tttdƒdd�tdƒdœdd	gd
�}t  ||¡ d S )Nr„  rd   r   r»  rª  rF   r0   r   r/   r€   r…  rB  r=   r=   r>   Ú%test_from_nested_listlike_mixed_typesØ  s    6ÿz?TestDataFrameConstructors.test_from_nested_listlike_mixed_typesc              	   C   sŒ   d  dg¡}d}tjt|d��Z tjt|d��, ttt	dƒƒtt	dƒƒgƒ W d   ƒ n1 s`0    Y  W d   ƒ n1 s~0    Y  d S )Nrc   z;Length of values \(6\) does not match length of index \(3\)r„  rd   r   Zabdefg)
rh   ri   rj   rk   r3   rM   rN   r   r   rà   )r8   rm   Zmsg2r=   r=   r>   Ú0test_construct_from_listlikes_mismatched_lengthsâ  s    ÿÿzJTestDataFrameConstructors.test_construct_from_listlikes_mismatched_lengthsc                 C   sÆ   g d¢}t |ƒ d¡}t |dd�}t ||¡ g d¢}t |ƒ d¡}t |dd�}t ||¡ tddd�}t ttjtjtjgg d¢d	�ƒ}||_t	d
|iƒ}t	d
t g d¢dd�i|d�}t 
||¡ d S )N)r/   r.   r-   r/   rª  rF   )rš   rœ   r�   rš   Z20000101r-   r?  r›   )rO   Ú
categoriesru   rA   )r   rØ   r3   rQ   r   r   rJ   rL   rB   r   r4   )r8   rI  r  ÚresrB   r<   r;   r=   r=   r>   Ú#test_constructor_categorical_seriesî  s     ÿz=TestDataFrameConstructors.test_constructor_categorical_seriesc                 C   s,   t dddgidg|d�}|jj|ks(J ‚d S )Nrš   r/   r.   rœ   rG  )r   rœ   rG   )r8   rG   r‘   r=   r=   r>   Ú%test_check_dtype_empty_numeric_column	  s    z?TestDataFrameConstructors.test_check_dtype_empty_numeric_columnc                 C   sF   t dddgidg|d�}|r0|tjv r0t |¡ |jjjdksBJ ‚d S )Nrš   r/   r.   rœ   rG  r[   )r   r3   ÚBYTES_DTYPESr�  Ú&mark_array_manager_not_yet_implementedrœ   rG   rI   )r8   ÚrequestrG   r9   r‘   r=   r=   r>   Ú$test_check_dtype_empty_string_column	  s    
z>TestDataFrameConstructors.test_check_dtype_empty_string_columnc                 C   sL   t dtd� ¡ j}t dtiƒ}t ||¡ tt dtd�ƒj}t ||¡ d S )Nr   r/  )r   r[   r3  rÐ   r3   rQ   r   r/  r=   r=   r>   Útest_to_frame_with_falsey_names%	  s
    z9TestDataFrameConstructors.test_to_frame_with_falsey_names)Nr"   rª  c                 C   s\   t dg d¢i|pdd�}t tdƒdg|d�}t ||¡ t dtdƒi|d�}t ||¡ d S )Nr¿   )r   r/   r.   r-   rž   r%   rF   r   rG  )r   r‚   r3   r4   )r8   rG   r<   r_   r=   r=   r>   Útest_constructor_range_dtype.	  s
    z6TestDataFrameConstructors.test_constructor_range_dtypec                 C   sT   G dd„ dt ƒ}tg d¢g d¢gƒ}t||g d¢ƒ|g d¢ƒgƒƒ}t ||¡ d S )Nc                   @   s   e Zd ZdS )zETestDataFrameConstructors.test_frame_from_list_subclass.<locals>.ListNr	  r=   r=   r=   r>   ÚList=	  s   r”  rb  r@  )rà   r   r3   r4   )r8   r”  r<   r_   r=   r=   r>   Útest_frame_from_list_subclass;	  s     z7TestDataFrameConstructors.test_frame_from_list_subclassÚextension_arrZaabbcz1/1/2017z1/1/2018)rP  Úendr’  c                 C   s$   t t|ƒƒ}t |ƒ}t ||¡ d S r†   r  )r8   r–  r<   r_   r=   r=   r>   Ú%test_constructor_with_extension_arrayD	  s    z?TestDataFrameConstructors.test_constructor_with_extension_arrayc                 C   s\   t  ¡ }||f}t|ttdƒtdƒd�i|gd�}tg d¢tt|gƒƒd�}t ||¡ d S )Nr-   rA   r€   r  )r   Útodayr   r   r‚   r   r3   r4   )r8   rQ  Útupr_   r<   r=   r=   r>   Ú*test_datetime_date_tuple_columns_from_dictS	  s
    "zDTestDataFrameConstructors.test_datetime_date_tuple_columns_from_dictc                 C   sx   t g d¢tg d¢ƒd�}t g d¢tg d¢ƒd�}t||gƒ}tt dddtjtjgg d	¢g¡g d
¢d�}t ||¡ d S )N)é'   r(   rž   )ÚfemaleÚmaleÚunknownrA   )r.   é˜   r.   éò   é–   )Úfr�  rp   rž  rŸ  rœ  r(   rž   )g      c@g     @n@g     Àb@r£   r£   )r�  rž  rŸ  r£  rp   r€   )r   r   r   rJ   rK   rL   r3   r4   )r8   r1  r6  r_   r<   r=   r=   r>   Ú/test_construct_with_two_categoricalindex_series[	  s    
þþzITestDataFrameConstructors.test_construct_with_two_categoricalindex_seriesc                 C   s  t tddƒƒ}t|dƒ ¡  d¡}t|dƒ ¡  d¡}t||dœƒ}ttdddd	�tdd
dd	�td
ddd	�tdddd	�tdddd	�tdddd	�tdddd	�tdddd	�tdddd	�tdddd	�g
dd�}tdgd t	j
gd  t	j
gd dgd  dœ|d�}t ||¡ d S )Nr   r÷   rÃ   r   r
  gòÒMbX¹¿gÍÌÌÌÌÌ#@r—  )ÚclosedgÍÌÌÌÌÌ3@g33333³=@gÍÌÌÌÌÌC@g     ÀH@g33333³M@g33333SQ@gÍÌÌÌÌÌS@gfffffFV@r«   T)ZorderedrA   )r   r‚   r   Zvalue_countsÚheadÚtailr   r   r   rJ   rL   r3   r4   )r8   rS   Úser1Úser2r_   rB   r<   r=   r=   r>   Ú1test_constructor_series_nonexact_categoricalindexi	  s,    öó.ÿzKTestDataFrameConstructors.test_constructor_series_nonexact_categoricalindexc                 C   s®   t dddddƒt dddddƒfg}tj|ddgd	�}t|ƒ}|d
 d |d d ksXJ ‚|d d |d d kstJ ‚t|d
 ƒ}t|d tƒs’J ‚|d |d d ksªJ ‚d S )Nr[  rt  r   rs  r[  rÃ   )ÚDateúM8[us])ÚForecastingr¬  rF   r«  r­  r/   )r   rJ   rK   r   r   r{   r   )r8   rX  rR   r;   r  r=   r=   r>   Útest_from_M8_structuredƒ	  s    "z1TestDataFrameConstructors.test_from_M8_structuredc                 C   s>   G dd„ dt ƒ}td|dddddƒgiƒ}|j jdks:J ‚d S )Nc                   @   s   e Zd ZdS )zOTestDataFrameConstructors.test_from_datetime_subclass.<locals>.DatetimeSubclassNr	  r=   r=   r=   r>   ÚDatetimeSubclass‘	  s   r¯  r   iä  r/   rY  )r   r   rG   )r8   r¯  r‘   r=   r=   r>   Útest_from_datetime_subclass�	  s    z5TestDataFrameConstructors.test_from_datetime_subclassc                 C   sT   t dddd�}d}tjt|d��  t|tdƒd� W d   ƒ n1 sF0    Y  d S )	Nr'   r-   r)   r*   z@Shape of passed values|Passed arrays should have the same lengthrd   rž   rA   )r   ri   rj   rk   r   r‚   )r8   r:   rm   r=   r=   r>   Ú(test_with_mismatched_index_length_raises—	  s    zBTestDataFrameConstructors.test_with_mismatched_index_length_raisesc                 C   sR   t dddd�}t |¡}ttj t|ƒ¡|dœƒ}t |d jt d¡¡sNJ ‚d S )Nz1/1/2000 00:00:00z1/1/2000 1:59:50rf  r‘  r  rY   rU   )	r   rJ   r§  r   rÄ   r\  r5   Z
issubdtyperG   )r8   rå   rX  r;   r=   r=   r>   Ú!test_frame_ctor_datetime64_columnž	  s    
z;TestDataFrameConstructors.test_frame_ctor_datetime64_columnc                 C   sz   g d¢g d¢g}t tj dd¡dd„ |D ƒd�}t|jtƒs@J ‚t|jtƒrPJ ‚t tj dd¡|d�}t|jtƒsvJ ‚d S )N)rš   rš   rœ   rœ   )ru   rƒ   ru   rƒ   rž   c                 S   s   g | ]}t  |¡‘qS r=   rÚ  rs   r=   r=   r>   rv   ª	  rw   zYTestDataFrameConstructors.test_dataframe_constructor_infer_multiindex.<locals>.<listcomp>rA   r€   )r   rJ   rÄ   r\  r{   rB   r   r�   )r8   Zindex_listsZmultir=   r=   r>   Ú+test_dataframe_constructor_infer_multiindex¥	  s    þzETestDataFrameConstructors.test_dataframe_constructor_infer_multiindexÚ
input_valsr  rº   re  ÚHrk  rg  c                 C   s6   t d|i|d�}t d|iƒ d|i¡}t ||¡ d S )Nr¿   rF   )r   rØ   r3   r4   )r8   r´  rÝ   r_   r<   r=   r=   r>   Útest_constructor_list_str²	  s    z3TestDataFrameConstructors.test_constructor_list_strc                 C   s8   t dg d¢i|d�}t dg d¢itd�}t ||¡ d S )Nr¿   rÉ  rF   )z1.0z2.0N)r   r[   r3   r4   )r8   rÝ   r_   r<   r=   r=   r>   Útest_constructor_list_str_naÅ	  s    z6TestDataFrameConstructors.test_constructor_list_str_nar¨   FTc                    sª  |r8|t jt j v s8|t jt j t j v r.|s8t |¡ tj	ddg|d�‰ tj	ddg|d�‰ˆj
jdv rld S tj	ddg|d�‰tˆ ˆˆdœ|d�‰d	d
„ ‰‡ ‡‡‡‡fdd„}|s¸|ƒ  dˆjd< dˆjd< |sòt‡fdd„ˆjjD ƒƒdksòJ ‚dˆd< |�r’ˆ j
jdk�rHˆ d ˆ j
 dd¡k�s*J ‚ˆd ˆj
 dd¡k�s|J ‚n4ˆ d ˆ j
 d¡k�sbJ ‚ˆd ˆj
 d¡k�s|J ‚ˆjd dk�s¦J ‚nˆjd dk�s¦J ‚d S )Nr/   r.   rF   r-   rž   )ÚSÚUr›   ry  c                 S   s0   t | tjƒr| jS t | jtjƒr(| jjS t‚d S r†   )r{   rJ   ZndarrayÚbaserG   Z_ndarrayr#  ©r}   r=   r=   r>   Úget_baseã	  s
    z<TestDataFrameConstructors.test_dict_nocopy.<locals>.get_basec                      sn   t ‡fdd„ˆjjD ƒƒdks"J ‚t ‡ ‡fdd„ˆjjD ƒƒdksFJ ‚t ‡‡fdd„ˆjjD ƒƒdksjJ ‚d S )Nc                 3   s   | ]}|ˆ u V  qd S r†   r=   rs   ©r�   r=   r>   r‹   î	  rw   zRTestDataFrameConstructors.test_dict_nocopy.<locals>.check_views.<locals>.<genexpr>r/   c                 3   s(   | ] }t |jtjƒrˆ|ƒˆ u V  qd S r†   ©r{   rG   rJ   rs   )rš   r¼  r=   r>   r‹   ð	  s   þc                 3   s(   | ] }t |jtjƒrˆ|ƒˆ u V  qd S r†   r¾  rs   )rœ   r¼  r=   r>   r‹   ø	  s   þ)Úsumr6   rz   r=   ©rš   rœ   r�   r;   r¼  r=   r>   Úcheck_viewsì	  s    "þûÿ	þûÿz?TestDataFrameConstructors.test_dict_nocopy.<locals>.check_viewsr   r¬   r0   c                 3   s   | ]}|ˆ u V  qd S r†   r=   rs   r½  r=   r>   r‹   
  rw   z=TestDataFrameConstructors.test_dict_nocopy.<locals>.<genexpr>rq   rb   rÓ  )r3   ÚSTRING_DTYPESrŽ  ÚDATETIME64_DTYPESÚTIMEDELTA64_DTYPESÚBOOL_DTYPESr�  r�  rJ   rK   rG   ro   r“  r   rP   r¿  r6   rz   Útype)r8   r�  r¨   Zany_numeric_ea_dtypeZany_numpy_dtyper9   rÁ  r=   rÀ  r>   Útest_dict_nocopyË	  sB    ÿÿýû	
	

"	z*TestDataFrameConstructors.test_dict_nocopyc                 C   s2   t tddd�dgd�}t dgd�}t ||¡ d S )Nr/   r–   rZ   rÓ   r€   r  r/  r=   r=   r>   Ú'test_from_series_with_name_with_columns'
  s    zATestDataFrameConstructors.test_from_series_with_name_with_columnsc                 C   sV   t g d¢g d¢gg d¢g d¢gd�}t g d¢g d¢gt g d¢¡d�}t ||¡ d S )Nrb  r@  )r¿   r¿   r¿   r›   r€   ))r¿   rš   )r¿   rœ   )r¿   r�   )r   r   r3  r3   r4   r/  r=   r=   r>   Útest_nested_list_columns-
  s    ÿþz2TestDataFrameConstructors.test_nested_list_columnsc           
      C   s   t jddd�}|j t¡ dd¡}t|ƒ}|jdks8J ‚|j|j	k 
¡ sLJ ‚||k 
¡  
¡ s`J ‚t j g d¢¡}|j t¡ dd¡}t|ƒ}|jdksšJ ‚|j|j	k 
¡ s®J ‚||k 
¡  
¡ sÂJ ‚tj||||f j}t|ƒ}t||||dœƒ}	t ||	¡ d S )	Nz
2016-04-05r-   r?  r/   rß   ©r/   r-   )r-   rž   r   r(   r‡  )r“  r›  r1   rØ   r[   r2   r   rÅ  rÐ   rG   r  ZIntervalIndexZfrom_breaksrJ   Zr_rz  r3   r4   )
r8   Úpir‘   r;   ÚiiZdata2r²   Zdata3ræ   r<   r=   r=   r>   Ú1test_from_2d_object_array_of_periods_or_intervals8
  s     zKTestDataFrameConstructors.test_from_2d_object_array_of_periods_or_intervalszcol_a, col_bc                 C   sD   d}t jt|d�� t||dœƒ W d   ƒ n1 s60    Y  d S )Nz,Per-column arrays must each be 1-dimensionalrd   r×   r  )r8   Zcol_aZcol_brm   r=   r=   r>   Útest_error_from_2darrayN
  s    	z1TestDataFrameConstructors.test_error_from_2darrayc                 C   sˆ   t g d¢g d¢dd�}t |d j|d j¡r2J ‚d|jd< t dtjtjgtjtjtjgtjtjtjgdœg d¢td	�}t ||¡ d S )
Nrb  r›   F)rB   r�   r¨   rš   rœ   r   r¬   ©rB   rG   )	r   rJ   rµ   Z_valuesrP   rL   r[   r3   r4   r9  r=   r=   r>   Ú&test_from_dict_with_missing_copy_false[
  s    
ýù	z@TestDataFrameConstructors.test_from_dict_with_missing_copy_false)Þrî  rï  rð  r?   rD   rT   rX   r`   rn   ri   ÚmarkÚparametrizer~   r„   r’   r   r•   r˜   r¡   rª   r®   r³   r�  Zskip_array_manager_invalid_testr·   r¹   r½   Zskipifr   rÁ   rÖ   rÛ   rÞ   rç   rë   rô   rJ   rK   r[   rö   rú   r	  r  r  r  r  r  r  rL   r  r©   r%  r*  r.  r0  r6  r:  rG  rL  rS  rW  rZ  r]  r_  ra  rf  rh  rl  rm  r|  rˆ  r�  r”  r•  r   r   r   r
   r   r	   rš  rž  r¢  r£  r¨  r°  r±  r¸  ZslowrÄ  rÆ  rà   r‚   r—   rG   rÂ   rÇ  r“  ZBooleanDtypeZFloat64DtypeZ
Int64DtypeZStringDtyperË  rÍ  rÎ  rÐ  rÒ  rÖ  rØ  rÛ  rÜ  rß  rã  rä  ræ  ró  rô  r÷  rø  rû  rý  rþ  r   r  rH  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r&  r.  r2  r5  r8  r>  r?  rA  rC  rD  rE  rH  rJ  rN  rW  rZ  r`  rd  rj  rl  r   rV   rg   ra   rm  rt  rv  rx  r{  r|  Z&skip_array_manager_not_yet_implementedr}  r   r  r€  r‚  rƒ  r†  r‡  rˆ  r‰  rŒ  r3   ZALL_INT_NUMPY_DTYPESZALL_INT_EA_DTYPESZFLOAT_NUMPY_DTYPESZCOMPLEX_DTYPESrÃ  rÄ  rÅ  r�  rÂ  rŽ  ZOBJECT_DTYPESr‘  r’  Zarm_slowr“  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&   H   s   
!óþ
ýþ
	


&	
úþ

&	



4	
þýþ
=J
/"ûþ

üþ	

'
	

üþ	



&ùþ&þ
 Gøþþþ;"(,$ÿ&ùþ

ÿþýüûúþ
ÿ		üþ	
ûþ
	["ýþr&   c                   @   s   e Zd Zdd„ Zdd„ ZdS )Ú&TestDataFrameConstructorIndexInferencec                 C   s|   t jdddd�}ttj t|ƒ¡|ƒ}t jdddd�}ttj t|ƒ¡|ƒ}t||dœƒ}t jdddd�}t 	|j
|¡ d S )Nz1/1/1999ú1/1/2012rq   r‘  z1/1/1980z	12/1/2001)r1  r6  )r“  r›  r   rJ   rÄ   r\  r5   r   r3   râ   rB   )r8   Zrng1r1  Zrng2r6  r;   r  r=   r=   r>   ÚAtest_frame_from_dict_of_series_overlapping_monthly_period_indexesn
  s    zhTestDataFrameConstructorIndexInference.test_frame_from_dict_of_series_overlapping_monthly_period_indexesc                 C   s.  t ddd�}ttdƒ|d�}ttdƒ| d¡d�}ttdƒ| d¡d�}ttdƒƒ}t|||dœƒ}tt|jƒt|jƒ t|jƒ td�}t	 
|j|¡ t|||d	œƒ}tt|jƒt|jƒ t|jƒ td�}	t	 
|j|	¡ t|||d
œƒ}
tt|jƒt|jƒ t|jƒ td�}	t	 
|
j|	¡ t|||dœƒ}tt|jƒt|jƒ t|jƒ td�}t	 
|j|¡ d}tjt|d��" t||||dœƒ W d   ƒ n1 �s 0    Y  tjt|d��  t|||dœƒ W d   ƒ n1 �sà0    Y  tjt|d��  t|||dœƒ W d   ƒ n1 �s 0    Y  d S )Nr'   r-   r?  rA   rb  z
US/CentralrÔ   rF   )r¿   rÕ   rY   )rY   r¿   rÕ   )rÕ   rY   r¿   z0Cannot join tz-naive with tz-aware DatetimeIndexrd   )r¿   rY   rÕ   r  )r¿   rY   r  )r  r¿   rY   )r   r   r‚   r\   r   r   rà   rB   r[   r3   râ   ri   rj   r#  )r8   r:   r¨  r©  Zser3Zser4r7  Z	exp_indexr²   Z
exp_index3ræ   Zdf4Z
exp_index4rm   r=   r=   r>   Ú/test_frame_from_dict_with_mixed_tzaware_indexesy
  s@    ÿÿÿÿ20zVTestDataFrameConstructorIndexInference.test_frame_from_dict_with_mixed_tzaware_indexesN)rî  rï  rð  rÕ  rÖ  r=   r=   r=   r>   rÓ  m
  s   rÓ  c                   @   s   e Zd Zdd„ ZdS )Ú)TestDataFrameConstructorWithDtypeCoercionc                 C   s–  t j dd¡}d}tjt|d�� t|dd� W d   ƒ n1 sB0    Y  t d ¡�  t| ¡ dd� W d   ƒ n1 s|0    Y  t j|d< d}tjt|d�� t|dd� W d   ƒ n1 sÄ0    Y  tjt|d��  t	|d	 dd� W d   ƒ n1 �s0    Y  d
}t
jt|d�� t|ƒ d¡ W d   ƒ n1 �sF0    Y  t
jt|d��" t	|d	 ƒ d¡ W d   ƒ n1 �sˆ0    Y  d S )NrÃ   r   z!if they cannot be cast losslesslyrd   rE   rF   r¬   z)passing float-dtype values containing NaNr   z9Cannot convert non-finite values \(NA or inf\) to integer)rJ   rÄ   r\  r3   rM   rN   r   ÚroundrL   r   ri   rj   rk   rØ   )r8   rR   rm   r=   r=   r>   Ú"test_floating_values_integer_dtype§
  s"    *.
*0.zLTestDataFrameConstructorWithDtypeCoercion.test_floating_values_integer_dtypeN)rî  rï  rð  rÙ  r=   r=   r=   r>   r×  ¦
  s   r×  c                   @   s²   e Zd Zej dddg¡dd„ ƒZej dddg¡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„ Zej deeg¡dd„ ƒZd d!„ Zd"d#„ Zd$S )%Ú&TestDataFrameConstructorWithDatetimeTZr,   r˜  zdateutil/US/Easternc           
      C   sÎ   t dddd�}| |¡}td|dœ|d�}td|jƒ}|d	 j|ksHJ ‚d
d„ |D ƒ}dd„ |D ƒ}td|iƒ}||d< ||d< ||d< |j}tt d¡t|d�t d¡t|d�gg d¢d�}	t	 
||	¡ d S )Nú2011/1/1ú2012/1/1úW-FRIr‘  r–   r  rA   rb   rY   c                 S   s   g | ]}|  ¡ ‘qS r=   rQ  rS  r=   r=   r>   rv   Ð
  rw   zeTestDataFrameConstructorWithDatetimeTZ.test_construction_preserves_tzaware_dtypes.<locals>.<listcomp>c                 S   s   g | ]}|  ¡ ‘qS r=   rQ  rS  r=   r=   r>   rv   Ñ
  rw   rc  Údr_tzÚdatetimes_naiveÚdatetimes_with_tzrY  r™  )rc  rÞ  rß  rà  )r   r\   r   r	   ÚtzinforG   rÐ   r   rJ   r3   rQ   )
r8   r,   rc  rÞ  r;   Ztz_expectedrß  rà  r_   r<   r=   r=   r>   Ú*test_construction_preserves_tzaware_dtypesÅ
  s*    
üù	zQTestDataFrameConstructorWithDatetimeTZ.test_construction_preserves_tzaware_dtypesÚpydtTFc           	      C   s@  |}t d|d�}|r| ¡ }t dƒ}t t¡�" td|gidd�}W d   ƒ n1 sV0    Y  td|giƒ}t ||¡ t t¡�$ td|idgdd�}W d   ƒ n1 s®0    Y  t ||¡ t t¡� t|gdd�}W d   ƒ n1 sò0    Y  t ||¡ t t¡�( ttj|gt	d�dd�}W d   ƒ n1 �sB0    Y  t ||¡ t t¡�$ t|dgdgdd�}W d   ƒ n1 �sŽ0    Y  t ||¡ t t¡�$ tt
|gƒgdd�}W d   ƒ n1 �sÚ0    Y  t ||¡ t t¡�$ t|ggdgdd�}W d   ƒ n1 �s&0    Y  t ||¡ d S )	NÚ2019r™  r   rY  rF   rÏ  rÔ  rG  )r   rR  r3   rM   rN   r   r4   rJ   rK   r[   r   Zassert_equal)	r8   Ztz_aware_fixturerã  r,   rT  Úts_naiver_   r<   r;   r=   r=   r>   Ú'test_constructor_data_aware_dtype_naiveâ
  s6    02,8444zNTestDataFrameConstructorWithDatetimeTZ.test_constructor_data_aware_dtype_naivec                 C   sˆ   t tdddd�dd�}tddd�}t||d	œƒ}|d
 jsBJ dƒ‚|d
 jd
ksTJ ‚t |d
 t|d
d�¡ t |d t|dd�¡ d S )Nra  r-   r˜  r*   r–   rZ   Z20130110r?  r  r¿   zM8[ns, US/EasternrY   )r   r   r   rG   rI   r3   rQ   r   )r8   r^   rc  r;   r=   r=   r>   Útest_from_dict	  s    z5TestDataFrameConstructorWithDatetimeTZ.test_from_dictc                 C   sª   t ddddd�}t|ƒ}t |d t|dd�¡ tt|ƒƒ}t |d t|dd�¡ t dddd�}t|ƒ}t |d t|dd�¡ tt|ƒƒ}t |d t|dd�¡ d S )	Nra  r-   r˜  r–   )r+   r,   rI   rZ   r*   r   )r   r   r3   rQ   r   )r8   r:  r²   r=   r=   r>   Útest_from_index  s    z6TestDataFrameConstructorWithDatetimeTZ.test_from_indexc                 C   sB   t ddd�}t||d�}td|dœ|d� td|jdœ|d� d S )NrÔ  rÃ   r?  rA   r–   r×   )r   r   r   rO   )r8   rc  r  r=   r=   r>   Ú+test_frame_dict_constructor_datetime64_1680'  s    zRTestDataFrameConstructorWithDatetimeTZ.test_frame_dict_constructor_datetime64_1680c                 C   s@   t dddd�}t|ƒ}td|dœ|d�}|d  ¡  ¡ s<J ‚d S )	NrÛ  rÜ  rÝ  r‘  r–   r  rA   rY   )r   r   r   r   r  )r8   rc  rT  r¸   r=   r=   r>   Ú+test_frame_datetime64_mixed_index_ctor_1681/  s    zRTestDataFrameConstructorWithDatetimeTZ.test_frame_datetime64_mixed_index_ctor_1681c                 C   sX   t ddddd�}t|dgd�}tdtddd�td	dd�td
dd�giƒ}t ||¡ d S )Nz20130101T10:00:00r-   rz  r˜  )rP  r+   r’  r,   Z
timestampsr€   r™  z20130101T10:01:00z20130101T10:02:00)r   r   r   r3   r4   )r8   rc  r_   r<   r=   r=   r>   Útest_frame_timeseries_column7  s    


ýÿÿ	zCTestDataFrameConstructorWithDatetimeTZ.test_frame_timeseries_columnc                 C   sf   ddg}dddœdddd	œd
œ}t |g d¢|d�}t ddtjtjfg|tg d¢ƒd�}t ||¡ d S )NÚNevadaÚOhioç333333@ç333333@)rK  éÒ  r¹  ç333333û?çÍÌÌÌÌÌ@)rw  rK  rð  )rì  rí  )rK  rð  iÓ  r“   )rî  rñ  )rï  rò  r7  )r   rJ   rL   r   r3   r4   )r8   r�   Úpopr_   r<   r=   r=   r>   Útest_nested_dict_constructionF  s    
þ
ýzDTestDataFrameConstructorWithDatetimeTZ.test_nested_dict_constructionc                 C   sd   t dddd�}|j t¡ dd¡}t|ƒ}|jdks8J ‚|j|jk 	¡ sLJ ‚||k 	¡  	¡ s`J ‚d S )Nz2016-04-05 04:30r-   rb  r*   r/   rß   rÊ  )
r   r1   rØ   r[   r2   r   rÅ  rÐ   rG   r  )r8   r:   r‘   r;   r=   r=   r>   Útest_from_tzaware_object_arrayU  s    zETestDataFrameConstructorWithDatetimeTZ.test_from_tzaware_object_arrayc              	   C   s†   t jtdƒtdƒtdƒgtddd�tjtddd�gtdd	d�tjtd
d	d�ggtd�j}t|g d¢d�}g d¢}|j|k 	¡ s‚J ‚d S )Nz2013-01-01 00:00:00z2013-01-02 00:00:00z2013-01-03 00:00:00z2013-01-01 00:00:00-0500r˜  r™  z2013-01-03 00:00:00-0500z2013-01-01 00:00:00+0100ZCETz2013-01-03 00:00:00+0100rF   rÔ   r€   )rY  r\  zdatetime64[ns, CET])
rJ   rK   r   r“  ra   r[   rz  r   rÐ   r  )r8   rR   r‹  Zexpected_dtypesr=   r=   r>   Ú$test_from_tzaware_mixed_object_array^  s&    ý

ý

ýõîzKTestDataFrameConstructorWithDatetimeTZ.test_from_tzaware_mixed_object_arrayc                 C   s:   t  d¡ d¡}t|dd�}t|ƒ d¡}t ||¡ d S )NrÃ   r¶  zdatetime64[ns, UTC]rF   )rJ   rx   r2   r   rØ   r3   r4   )r8   Z
array_dim2r;   r<   r=   r=   r>   Útest_from_2d_ndarray_with_dtype}  s    zFTestDataFrameConstructorWithDatetimeTZ.test_from_2d_ndarray_with_dtyperÎ   c                 C   sŽ   |h d£ƒ}d|j › d�}tjt|d�� td|iƒ W d   ƒ n1 sJ0    Y  tjt|d�� t|ƒ W d   ƒ n1 s€0    Y  d S )N>   r/   r.   r-   ú'z' type is unorderedrd   rš   )rî  ri   rj   r#  r   r   )r8   rÎ   rO   rm   r=   r=   r>   Ú!test_construction_from_set_raises…  s    *zHTestDataFrameConstructorWithDatetimeTZ.test_construction_from_set_raisesc                 C   s>   t jdddd� dd¡}t|ƒ}tdd„ |jjD ƒƒs:J ‚d S )	Nr   r;  rY  rF   rž   r-   c                 s   s   | ]}t |tƒV  qd S r†   )r{   r   )rt   rR   r=   r=   r>   r‹   •  rw   zeTestDataFrameConstructorWithDatetimeTZ.test_construction_from_ndarray_datetimelike.<locals>.<genexpr>)rJ   rx   r2   r   r  r6   rz   r¶   r=   r=   r>   Ú+test_construction_from_ndarray_datetimelike�  s    zRTestDataFrameConstructorWithDatetimeTZ.test_construction_from_ndarray_datetimelikec                 C   s®   t j dd¡}t dg¡j}d}tjt|d��  t	|dg|d� W d   ƒ n1 sT0    Y  t g d¢¡}tjt|d��  t	|dd	gd
� W d   ƒ n1 s 0    Y  d S )NrÃ   r.   r£   z'len\(arrays\) must match len\(columns\)rd   r–   rG  )r£   r¤   rT  rÓ   r€   )
rJ   rÄ   r\  r“  rK   rG   ri   rj   rk   r   )r8   rR   rG   rm   Zarr2r=   r=   r>   Ú>test_construction_from_ndarray_with_eadtype_mismatched_columns—  s    .zeTestDataFrameConstructorWithDatetimeTZ.test_construction_from_ndarray_with_eadtype_mismatched_columnsN)rî  rï  rð  ri   rÑ  rÒ  râ  ræ  rç  rè  ré  rê  rë  rô  rõ  rö  r÷  ÚsetÚ	frozensetrù  rú  rû  r=   r=   r=   r>   rÚ  Ä
  s"   

&	

rÚ  c                 C   s"   t | tƒr| jd S | jd S d S )Nr   r¬   )r{   r   rP   r»  r=   r=   r>   Úget1£  s    

rþ  c                   @   s¶   e Zd Zejeedgd�dd„ ƒZej 	dddg¡dd	„ ƒZ
d
d„ Zdd„ Zdd„ Zej 	dejejg¡dd„ ƒZej 	deejg¡dd„ ƒZej 	deejg¡dd„ ƒZdd„ ZdS )ÚTestFromScalarN)Úparamsc                    s”   |j }dtdƒi‰ ˆtu r$dgˆ d< |d u r>tjˆfi ˆ ¤ŽS |tu rlˆtu r\‡ ‡fdd„S ‡ ‡fdd„S n$ˆtu r‚‡ ‡fdd„S ‡ ‡fd	d„S d S )
NrB   r.   r¿   r�   c                    s   ˆ| | dœfi ˆ ¤|¤ŽS )Nr0   r=   ©ru   Úkwargs©Úextrarl   r=   r>   rˆ   ¸  s   ÿÿÿz,TestFromScalar.constructor.<locals>.<lambda>c                    s   ˆd| ifi ˆ ¤|¤ŽS ©Nr¿   r=   r  r  r=   r>   rˆ   ¼  rw   c                    s   ˆ| | gfi ˆ ¤|¤ŽS r†   r=   r  r  r=   r>   rˆ   ¿  rw   c                    s   ˆd| | gifi ˆ ¤|¤ŽS r  r=   r  r  r=   r>   rˆ   Á  s   
ÿÿÿ)Úparamr‚   r   r¾  r¿  rH  r   )r8   r�  rl   Úboxr=   r  r>   r…   «  s    
zTestFromScalar.constructorrG   rU   rf   c                 C   s8   |t j|d�}t |j|k¡s"J ‚t | ¡ ¡s4J ‚d S rÏ  )r“  ra   rJ   r  rÐ   r   )r8   rG   r…   r}   r=   r=   r>   Útest_from_nat_scalarÅ  s    z#TestFromScalar.test_from_nat_scalarc                 C   s(   t dƒ}||dd�}t|ƒ|ks$J ‚d S )Nr/   rf   rF   ©r   rþ  )r8   r…   r�  r}   r=   r=   r>   Ú*test_from_timedelta_scalar_preserves_nanosË  s    z9TestFromScalar.test_from_timedelta_scalar_preserves_nanosc                 C   s,   |t dƒ }||dd�}t|ƒ|ks(J ‚d S )Nr/   rU   rF   r	  )r8   r…   Zfixed_now_tsrT  r}   r=   r=   r>   Ú*test_from_timestamp_scalar_preserves_nanosÑ  s    z9TestFromScalar.test_from_timestamp_scalar_preserves_nanosc                 C   s4   t dƒ}| ¡ }||td�}tt|ƒtjƒs0J ‚d S )Nr/   rF   )r   Zto_timedelta64r[   r{   rþ  rJ   rŒ  )r8   r…   r�  Ztd64r}   r=   r=   r>   Ú#test_from_timedelta64_scalar_object×  s    z2TestFromScalar.test_from_timedelta64_scalar_objectÚclsc                 C   s¼   |ddƒ}t jdt jdi| }d}|t ju r:d ddg¡}tjt|d�� |||d	� W d   ƒ n1 sj0    Y  |d
dƒ}tjt|d�� |||d	� W d   ƒ n1 s®0    Y  d S )Nra   rb   rf   rU   zCannot castrc   z?dtype datetime64\[ns\] cannot be converted to timedelta64\[ns\]rd   rF   rž   )rJ   rg   rŒ  rh   ri   rj   r#  )r8   r…   r  r  rG   rm   r=   r=   r>   Ú(test_from_scalar_datetimelike_mismatchedß  s    

þÿ*
z7TestFromScalar.test_from_scalar_datetimelike_mismatchedc                 C   sB   t dddƒ}|tju r"t |d¡}||ƒ}tt|ƒƒ|u s>J ‚d S )Né'  r/   r  )r   rJ   rg   rÆ  rþ  ©r8   r…   r  r  r_   r=   r=   r>   Ú test_from_out_of_bounds_datetimeô  s
    
z/TestFromScalar.test_from_out_of_bounds_datetimec                 C   sN   t dddƒt dddƒ }|tju r.t |d¡}||ƒ}tt|ƒƒ|u sJJ ‚d S )Nr  r/   i²  r  )r   rJ   rŒ  rÆ  rþ  r  r=   r=   r>   Ú!test_from_out_of_bounds_timedeltaý  s
    
z0TestFromScalar.test_from_out_of_bounds_timedeltac                 C   s|   d}t d|d�}t dƒ}tjtdd�� ||dd�}W d   ƒ n1 sH0    Y  t |jdk¡sfJ ‚t ||k¡sxJ ‚d S )Nr˜  rä  r™  zData is timezone-awarerd   rU   rF   )r   r3   rM   rN   rJ   r  rÐ   )r8   r…   r,   rT  rå  r_   r=   r=   r>   Útest_tzaware_data_tznaive_dtype  s    *z.TestFromScalar.test_tzaware_data_tznaive_dtype)rî  rï  rð  ri   Zfixturerà   rH  r…   rÑ  rÒ  r  r
  r  r  rJ   rg   rŒ  r  r   r  r   r  r  r=   r=   r=   r>   rÿ  ª  s   




rÿ  )BrN  r   r   r   r   r   r¾  rÁ  r$  r¬  ÚnumpyrJ   Znumpy.mar¥  Znumpy.ma.mrecordsr·  ri   r]  Zpandas.compatr   Zpandas.util._test_decoratorsÚutilZ_test_decoratorsr�  Zpandas.core.dtypes.commonr   Zpandas.core.dtypes.dtypesr	   r
   r   r   Zpandasr“  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zpandas._testingZ_testingr3   Zpandas.arraysr   r   r   r   Zpandas.core.apir    rË   rÊ   r&   rÓ  r×  rÚ  rþ  rÿ  r=   r=   r=   r>   Ú<module>   s`   D                    99 `