U
    f/e8                     @   sb  d dl Z d dl mZ d dlmZ d dl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mZmZmZ d dlm  mZ d dlZd dlmZmZmZmZmZmZ d dlmZ e  Z!ee!Z"e"# Z$dgd d	gd  d
gd  dge%e$d   Z&ej'e&dde$_(e)e*e&e$d< e
j+e%e$dde$d< dd Z,ej-.dej-.dG dd dZ/dS )    N)	timedelta)Decimal)StringIO)IS64PY38PY310is_platform_windows)	DataFrameDatetimeIndexSeries	Timestampcompat	read_jsonZbah   barbazfoo   Enameint64dtypesortc                 C   sD   |dks|dkr|j dd}|dkr4tt|j|_t| | d S )NrecordsvaluesTdrop)reset_indexrangelencolumnstmassert_frame_equal)resultexpectedorient r(   D/tmp/pip-unpacked-wheel-tiezk1ph/pandas/tests/io/json/test_pandas.pyassert_json_roundtrip_equal*   s
    r*   zBignore:an integer is required (got type float)*:DeprecationWarningz6ignore:the 'numpy' keyword is deprecated:FutureWarningc                   @   s  e Zd Zejdddd Zejdd Zejdd Zd	d
 Zej	
ddddgdd Zej	
dddgdd Zej	
dddgej	
dddgddggddgddggddgddgged dged!dgggd"d# Zej	
ddddgd$d% Zd&d' Zej	
d(d)egej	
d*dd)gej	
d+dd)gd,d- Zej	
d(d)ejgej	
d*dd)gej	
d+dd)gd.d/ Zej	
d(d0ejed1gej	
d*dd)gej	
d+dd)gd2d3 Zej	
d*dd)gej	
d+dd)gd4d5 Zej	
d*dd)gej	
d+dd)gd6d7 Zej	
d*dd)gej	
d+dd)gd8d9 Zej	
d*dd)gej	
d+dd)gd:d; Zej	
d<d=d>d?d@dAgdfdBdCgdDdE Zej	
d(dd)gej	
d*dd)gej	
d+dd)gdFdG Zej	
d(dd)gdHdI Z ej	
dJej!ej"gej	
d(dd)gdKdL Z#ej	j$e% dMdNej	
dOdPdQdRdSdTdUgdVdW Z&dXdY Z'dZd[ Z(d\d] Z)d^d_ Z*d`da Z+dbdc Z,ddde Z-dfdg Z.dhdi Z/djdk Z0ej	
d+dd)gdldm Z1ej	
d(d)d0gej	
d+dd)gdndo Z2ej	
d+dd)gdpdq Z3ej	
d+dd)gdrds Z4ej	
d(ejegej	
d+dd)gdtdu Z5dvdw Z6dxdy Z7dzd{ Z8ej	
d|de9d}gd~dfd)e9dgfgdd Z:dd Z;dd Z<dd Z=dd Z>dd Z?dd Z@ej	
dddgej	
ddd)gej	
deAjBeAjAegdd ZCej	
ddddddddgdd ZDej	
ddddddgdd ZEdd ZFej	
ddddddgdd ZGdd ZHej	
dddddgdd ZIdd ZJdd ZKdd ZLeMjNej	jOdd ZPeMjNej	jOej	
ddeQjRddgdd~gdeQjRddggddĄ ZSddƄ ZTddȄ ZUej	
ddd)gej	
dddgej	
deQjVeWgdd˄ ZXdd̈́ ZYddτ ZZddф Z[ddӄ Z\ddՄ Z]ddׄ Z^ddل Z_ej	j$e`ddNej	
ded܃eddded߃gdd Zaej	j$e`ddNej	
deQjbdddeQjbddddeQjbdddgdd Zcdd Zdeejfdd Zgdd Zhdd Ziej	
dejjkd ejjkd  gdd Zlej	
dejjkd ejjkd  gej	j$emj% ddNdd Zndd Zodd Zpdd Zqdd  Zrej	
dd0ddgddgddgddgddggej	
dddgddgddggdd Zsd	d
 Ztej	
d(deedgdd Zudd Zvej	
dewddgddggddgdddgddgddggdfewddgddggddgdxdddgddgddggdfewddgddggddgddgddggdddgddgddggdfe9dddgddddddgdfe9dddgddxdddddgdfe9ddgdddgddggddddgdfgdd Zyej	
dewddgddggddgdewddgddggddgdxdewddgddggddgddgddggde9dddgdde9dddgddxde9ddgdddgddggdgdd Zzej	
dddddgdd  Z{ej	
ddd!gej	
ddd)gd"d# Z|d$d% Z}ej	
d&d'd(gd)d* Z~ej	
d+d,d-ejdd.ej	jd/ejd!d.ej	jd/gd0d1 Zej	
d2dddgd3d4 Zej	
d+d5d6d7d8d9d:gd;d< Zd=d> Zd?d@ ZdAdB ZdCdD Zej	
dEewdddgdddgdFdGfgdHdI Zej	je oedJd)dKdLdM ZdNdO ZdPdQ ZdRdS Zd0S (T  TestPandasContainerT)Zautousec                 c   s   t  | _d V  d S N)
_cat_framecopycategoricalselfr(   r(   r)   setup7   s    
zTestPandasContainer.setupc                 C   s    t  }d|_|jd |_|S )Nts)r#   ZmakeTimeSeriesr   index
_with_freq)r1   serr(   r(   r)   datetime_series=   s    z#TestPandasContainer.datetime_seriesc                 C   s   t t }|jd |_|S r,   )r	   r#   ZgetTimeSeriesDatar4   r5   r1   dfr(   r(   r)   datetime_frameF   s    z"TestPandasContainer.datetime_framec                 C   sN   t ddgddggddgddgd	}t|j|d
|d
}| }t||| d S )Nabcdz	index " 1z	index / 2za \ bzy / zr4   r"   r'   r	   r   to_jsonr.   r*   r1   r'   r9   r%   r&   r(   r(   r)    test_frame_double_encoded_labelsN   s    z4TestPandasContainer.test_frame_double_encoded_labelsr'   splitr   r   c                 C   sN   t ddgddggddgddgd}t|j|d	|d	}| }t||| d S )
Nr;   r<   r=   r>      xyr?   r@   rA   rC   r(   r(   r)   test_frame_non_unique_indexZ   s    "z/TestPandasContainer.test_frame_non_unique_indexr4   r"   c              	   C   sX   t ddgddggddgddgd}d	| d
}tjt|d |j|d W 5 Q R X d S )Nr;   r<   r=   r>   rF   rG   rH   r?   z+DataFrame index must be unique for orient=''matchr@   r	   pytestraises
ValueErrorrB   r1   r'   r9   msgr(   r(   r)   "test_frame_non_unique_index_raisesb   s    "z6TestPandasContainer.test_frame_non_unique_index_raisesdatar;   r<   r=   r>   g      ?g      @g      @g      @rF      20130101Z20130102c                 C   s   t |ddgddgd}t|j|d|dgd}|dkrt |}|jd d df jd	kr|jd d df tjd
 |jd d df< n|dkr|}t	|| d S )NrF      rG   r?   r@   )r'   convert_datesr   r   datetime64[ns]@B rE   )
r	   r   rB   ilocr   viewnpr   r#   r$   )r1   r'   rT   r9   r%   r&   r(   r(   r)   test_frame_non_unique_columnsi   s    
  .z1TestPandasContainer.test_frame_non_unique_columnsc              	   C   sX   t ddgddggddgddgd}d	| d
}tjt|d |j|d W 5 Q R X d S )Nr;   r<   r=   r>   rF   rW   rG   r?   z-DataFrame columns must be unique for orient='rJ   rK   r@   rM   rQ   r(   r(   r)   $test_frame_non_unique_columns_raises   s    "z8TestPandasContainer.test_frame_non_unique_columns_raisesc                 C   s   |  |j ddkstd S )Nr"   r@   rB   AssertionError)r1   float_framer(   r(   r)   test_frame_default_orient   s    z-TestPandasContainer.test_frame_default_orientr   Fconvert_axesnumpyc           	      C   s2   |j |d}t|||||d}|}t||| d S )Nr@   r'   rd   re   r   )rB   r   r*   )	r1   r'   rd   re   r   rb   rT   r%   r&   r(   r(   r)   test_roundtrip_simple   s        z)TestPandasContainer.test_roundtrip_simplec           	      C   sX   |j |d}t|||||d}|}|rHtr0t rH|sH|dkrH|tj}t||| d S )Nr@   rf   rE   )rB   r   r   r   astyper]   Zint32r*   )	r1   r'   rd   re   r   	int_framerT   r%   r&   r(   r(   r)   test_roundtrip_intframe   s*        z+TestPandasContainer.test_roundtrip_intframeNU3c           
      C   s
  t tddd tdD dd tdD |d}|r\|dkr\|d	kr\|jtjjd
d |j	|d}t
|||||d}| }	|s|	tj}	|r|dkr|	jtj|	_|	jtj|	_n:|dkr|r|	jtj|	_n|r|d	kr|	jtj|	_t||	| d S )N)      c                 S   s   g | ]}t |qS r(   str.0ir(   r(   r)   
<listcomp>   s     z?TestPandasContainer.test_roundtrip_str_axes.<locals>.<listcomp>rm   c                 S   s   g | ]}t |qS r(   rn   rp   r(   r(   r)   rs      s     rl   )r"   r4   r   rk   rE   Can't decode directly to arrayreasonr@   rf   r?   r   )r	   r]   zerosr    node
add_markerrN   markxfailrB   r   r.   rh   r   r"   r4   r*   )
r1   requestr'   rd   re   r   r9   rT   r%   r&   r(   r(   r)   test_roundtrip_str_axes   s:        z+TestPandasContainer.test_roundtrip_str_axesc                 C   s   |dkr&|j tjjd| dd | jj|d}|r^|dkr^|j tjjd| dd t||||d	}| j }|j	
t|_	d |j	_|s|d
kr| }t||| d S )Nr?   z.Can't have duplicate index values for orient 'z')ru   r@   )r   r   zOrient z is broken with numpy=Truer'   rd   re   r4   )rx   ry   rN   rz   r{   r/   rB   r   r.   r4   rh   ro   r   
sort_indexr*   )r1   r|   r'   rd   re   rT   r%   r&   r(   r(   r)   test_roundtrip_categorical   s$    

z.TestPandasContainer.test_roundtrip_categoricalc                 C   sx   |j |d}t||||d}| }|rD|jt|_|jt|_|rh|dkrh|jdgddjdd}t	
|| d S )	Nr@   r~   r   r   rF   ZaxisTr   )rB   r   r.   r4   rh   floatr"   reindexr   r#   r$   )r1   r'   rd   re   Zempty_framerT   r%   r&   r(   r(   r)   test_roundtrip_empty   s    z(TestPandasContainer.test_roundtrip_emptyc           	      C   sb   |j |d}t||||d}| }|sR|jtjd }|dkrL|t}||_t	||| d S )Nr@   r~   rZ   rE   )
rB   r   r.   r4   r\   r]   r   rh   ro   r*   )	r1   r'   rd   re   r:   rT   r%   r&   idxr(   r(   r)   test_roundtrip_timestamp  s    
z,TestPandasContainer.test_roundtrip_timestampc                 C   s   |r"|dkr"|j tjjdd tdddddg}d	d
dddgd	d
d	d
d	gdddddgdddddgd}t||d}|j|d}t	||||d}	|
 }
|
jf |
dtj}
|s|dkr|
 }
t|	|
| d S )NrE   rt   ru   r;   r<   r=   r>   eg              ?       @      @      @Zfoo1Zfoo2Zfoo3Zfoo4Zfoo5TF)ABCD)rT   r4   r@   r~   numberr4   )rx   ry   rN   rz   r{   pdIndexr	   rB   r   r.   ZassignZselect_dtypesrh   r]   r   r   r*   )r1   r|   r'   rd   re   r4   r   r9   rT   r%   r&   r(   r(   r)   test_roundtrip_mixed  s$    z(TestPandasContainer.test_roundtrip_mixedzdata,msg,orient)z{"key":b:a:d}zExpected object or valuer"   zO{"columns":["A","B"],"index":["2","3"],"data":[[1.0,"1"],[2.0,"2"],[null,"3"]]}|z:Shape of passed values is \(3, 2\), indices imply \(2, 2\)zHPassed arrays should have the same length as the rows Index: 3 vs 2 rows)zW{"columns":["A","B","C"],"index":["1","2","3"],"data":[[1.0,"1"],[2.0,"2"],[null,"3"]]}z+3 columns passed, passed data had 2 columnsrE   )zN{"badkey":["A","B"],"index":["2","3"],"data":[[1.0,"1"],[2.0,"2"],[null,"3"]]}zunexpected key\(s\): badkeyrE   c              	   C   s.   t jt|d tt||d W 5 Q R X d S )NrK   r@   )rN   rO   rP   r   r   )r1   rT   rR   r'   r(   r(   r)   $test_frame_from_json_bad_data_raises6  s    %z8TestPandasContainer.test_frame_from_json_bad_data_raisesc                 C   s   t ddgdddgg}t|j|d|||d}t|jd sBtt d	d
gdddgg}t|j|d|||d}t|jd std S )NrF   rW   rm   r      r@   )r'   rd   r   r   rW   12456)r	   r   rB   r]   isnanr[   ra   )r1   r'   rd   re   r   Znum_dfr%   Zobj_dfr(   r(   r)   !test_frame_from_json_missing_data^  s     

z5TestPandasContainer.test_frame_from_json_missing_datac                 C   s(   t d|d}ttjg}t|| d S )Nz[null]r   )r   r	   r]   nanr#   r$   )r1   r'   r   r%   r&   r(   r(   r)   (test_frame_read_json_dtype_missing_valuet  s    z<TestPandasContainer.test_frame_read_json_dtype_missing_valueinfc                 C   sH   t ddgdddgg}||jd< t| |d}t|jd sDtd S )NrF   rW   rm   r   r   r   r   )r	   locr   rB   r]   r   r[   ra   )r1   r'   r   r   r9   r%   r(   r(   r)   test_frame_infinity}  s    
z'TestPandasContainer.test_frame_infinityz$not compliant on 32-bit, xref #15865ru   zvalue,precision,expected_val)gffffff?rF   r   )g333333?rF   r   )g333333rF   g       )gףp=
?rW   r   )gCl?rU   r   )g?r   r   c                 C   s2   t d|ig}|j|d}|d| dks.td S )NZa_float)Zdouble_precisionz{"a_float":{"0":}}r	   rB   ra   )r1   valueZ	precisionZexpected_valr9   encodedr(   r(   r)   "test_frame_to_json_float_precision  s    z6TestPandasContainer.test_frame_to_json_float_precisionc              	   C   s<   t dddg}d}tjt|d |jdd W 5 Q R X d S NrF   rW   rU   z+Invalid value 'garbage' for option 'orient'rK   garbager@   rM   )r1   r9   rR   r(   r(   r)   test_frame_to_json_except  s    z-TestPandasContainer.test_frame_to_json_exceptc                 C   sf   t ddgd}|jrttjt| t|jd|dd t dg ig djd	d
}d}||ksbtd S )Njimjoer"   r   Fcheck_index_typetestr4   r"   r@   z{"test":{}})	r	   _is_mixed_typera   r#   r$   r   rB   dictdtypesr1   r9   r%   r&   r(   r(   r)   test_frame_empty  s    
  z$TestPandasContainer.test_frame_emptyc                 C   sP   t ddgd}|d d|d< |js*ttjt| t|j	d|dd d S )Nr   r   r   i8r   Fr   )
r	   rh   r   ra   r#   r$   r   rB   r   r   r8   r(   r(   r)   test_frame_empty_mixedtype  s    
  z.TestPandasContainer.test_frame_empty_mixedtypec                 C   s  dddddgdddd	d
gdddddgdddddgg}t |tddddddgd}|jsZt| }dD ]*}|j|d}t||dd}t|| qft	
t||_|jd d}t|d dd}t|| t	
|jd |_|jd!d}t|d!dd}t|| d S )"N
   rF   r   皙?g{Gz?   rW   r   g?g{Gz?   rU   r   g333333?gQ?(   rm   quxg?g{Gz?ZabcdZ1stZ2ndZ3rdZ4thZ5thr?   )rE   r4   r"   r@   Fr'   rd   r   r   )r	   listr   ra   r.   rB   r   r#   r$   r]   aranger!   r4   shaper"   )r1   valsr9   rightr'   inpleftr(   r(   r)   test_frame_mixedtype_orient  s0      
z/TestPandasContainer.test_frame_mixedtype_orientc           
   	   C   s  t dd}tt|d d}tddddgdd	d
dgddddgddddgddddggddddg|d}td|d< td|jd |j	df< |d |d!< t j
|jd"|j	d!f< |d#d$d%}tj|d&}t|}t|| |jd!gd"d'}tj|d(}t|}	t||	 d S ))Nz
2000-01-03z
2000-01-07freqgÉ?gz~Kc?gX7?gH/ƿg|RпgXgsBfg(ƿg<1=?g9?gg??gLł
gJQg[r?T?gj<DH>?g-ѿgIEx?gW!i`ygP04?g+]5?r   r   r   r   r"   r4   z19920106 18:21:32.12daterV   rU   modifiedrF   iojsonrT   ztsframe_v012.jsonr   ztsframe_iso_v012.json)r   
date_ranger
   r]   Zasarrayr	   r   r[   r"   get_locNaTospathjoinr   r#   r$   r   )
r1   datapathdtir9   dirpathZv12_jsonZdf_unserZdf_isoZv12_iso_jsonZdf_unser_isor(   r(   r)   test_v12_compat  s0    





z#TestPandasContainer.test_v12_compatc                 C   s   t jdddd}tt|d d}tdddd	d
dddddg
ddddddddddg
ddddddd d!d"d#g
d$d%d&d'd(d)d*d+d,d-g
d.d/d0d1d2d3d4d5d6d7g
d8d9d:d;d<d=d>d?d@dAg
dB|dC}|jdD|_t|jdEdFdEdF}t	j
||dGdGdGdGdH d S )INZ20000101r   H)periodsr   r   g}S? wgbm?gz(~J	?g1?gk*MgvTj?g7j	" Y?gp+KS(g񒬁?gZtSyiL,i_}i4ziKeiL&i%giDiY)L i;eiD Z78c608f1Z64a99743Z13d2ff52Zca7f4af2Z97236474Zbde7e214Z1a6bde47Zb1190be5Z7a669144Z8d64d068gD!gIxJ g%
@gP\<g޿gPl?gFzn?g5mH/?gpH%gI?Z14f04af9Zd085da90Z4bcfac83Z81504cafZ2ffef4a9Z08e2f5c4Z07e1af03Zaddbd4a7Z1f6a09baZ4bfc4d87i/iiYi6iI i;>i	i( i0q{iѪ)Zfloat_1Zint_1Zstr_1Zfloat_2Zstr_2Zint_2r   unicoderE   r@   T)r   Zcheck_column_typeZ	by_blocksZcheck_exact)r   r   r
   r   r	   r"   rh   r   rB   r#   r$   )r1   r4   df_mixedZdf_roundtripr(   r(   r)   test_blocks_compat_GH9037  s    JOz-TestPandasContainer.test_blocks_compat_GH9037c           
   	   C   s   G dd d}d}||}t d|jgi}| d| dksBtt d|gi}d}tjt|d |  W 5 Q R X t |gd	gd
ddgd}tjt|d |  W 5 Q R X |jtd}d| d}	||	kst|jtdd| dkstd S )Nc                   @   s"   e Zd Zdd ZedddZdS )zFTestPandasContainer.test_frame_nonprintable_bytes.<locals>.BinaryThingc                 S   s   || _ t|| _d S r,   )hexedbytesfromhexbinary)r1   r   r(   r(   r)   __init__R  s    zOTestPandasContainer.test_frame_nonprintable_bytes.<locals>.BinaryThing.__init__)returnc                 S   s   | j S r,   )r   r0   r(   r(   r)   __str__V  s    zNTestPandasContainer.test_frame_nonprintable_bytes.<locals>.BinaryThing.__str__N)__name__
__module____qualname__r   ro   r   r(   r(   r(   r)   BinaryThingQ  s   r   Z574b4454ba8c5eb4f98a8f45r   z{"A":{"0":"z"}}z6Unsupported UTF-8 sequence length when encoding stringrK   rF   r   r   r   r   default_handlerz"},"B":{"0":1}})r	   r   rB   ra   rN   rO   OverflowErrorro   )
r1   r   r   ZbinthingZdf_printableZdf_nonprintablerR   r   r%   r&   r(   r(   r)   test_frame_nonprintable_bytesN  s&    

z1TestPandasContainer.test_frame_nonprintable_bytesc                 C   s<   t dd dgddgi }ddd  d}||ks8td S )Nr   i rF   r   i9  {"z":{"0":1},"foo":{"0":1337}}r   r1   r%   r&   r(   r(   r)   test_label_overflowt  s    z'TestPandasContainer.test_label_overflowc              	   C   s   t ddgddgd}d}tjt|d |jdd W 5 Q R X t|t|jd	dd	d
d t|jdddd
d}t|j	|j	 d S )Nr;   r<   rF   r   z.Series index must be unique for orient='index'rK   r4   r@   rE   series)r'   typr   )
r   rN   rO   rP   rB   r#   assert_series_equalr   Zassert_numpy_array_equalr   )r1   srR   Zunserializedr(   r(   r)   test_series_non_unique_indexz  s     
  z0TestPandasContainer.test_series_non_unique_indexc                 C   s   |  |j ddkstd S Nr4   r@   r`   )r1   string_seriesr(   r(   r)   test_series_default_orient  s    z.TestPandasContainer.test_series_default_orientc                 C   sR   |j |d}t|d||d}|}|dkr4|jdd}|dkrBd |_t|| d S Nr@   r   r   r'   re   r   r   Tr   rE   rB   r   r   r   r#   r   )r1   r'   re   r   rT   r%   r&   r(   r(   r)   test_series_roundtrip_simple  s    z0TestPandasContainer.test_series_roundtrip_simplec                 C   sT   |j |d}t|d|||d}|}|dkr6|jdd}|dkrDd |_t|| d S )Nr@   r   )r   r'   re   r   r   Tr   rE   r   )r1   r'   re   r   Zobject_seriesrT   r%   r&   r(   r(   r)   test_series_roundtrip_object  s    z0TestPandasContainer.test_series_roundtrip_objectc                 C   sT   |j |d}t|d||d}|}|dkr6|jdd}n|jt|_t|| d S )Nr@   r   r   r   Tr   )rB   r   r   r4   rh   r   r#   r   )r1   r'   re   Zempty_seriesrT   r%   r&   r(   r(   r)   test_series_roundtrip_empty  s    z/TestPandasContainer.test_series_roundtrip_emptyc                 C   sR   |j |d}t|d||d}|}|dkr4|jdd}|dkrBd |_t|| d S r   r   )r1   r'   re   r7   rT   r%   r&   r(   r(   r)    test_series_roundtrip_timeseries  s    z4TestPandasContainer.test_series_roundtrip_timeseriesc                 C   sd   t tdddddddgd}|j|d	}t|d
||d}| }|dkrT|jdd}t|| d S )Nr   r;   r<   r=   r>   r   fr   r@   r   r   r   Tr   )r   r    rB   r   r.   r   r#   r   )r1   r'   re   r   r   rT   r%   r&   r(   r(   r)   test_series_roundtrip_numeric  s    z1TestPandasContainer.test_series_roundtrip_numericc              	   C   s<   t dddg}d}tjt|d |jdd W 5 Q R X d S r   )r   rN   rO   rP   rB   )r1   r   rR   r(   r(   r)   test_series_to_json_except  s    z.TestPandasContainer.test_series_to_json_exceptc                 C   s4   t dddg}t| ddd}tj||dd d S )N=
ףp=@r   T)r   precise_floatFr   )r   r   rB   r#   r   r1   r   r%   r(   r(   r)   #test_series_from_json_precise_float  s    z7TestPandasContainer.test_series_from_json_precise_floatc                 C   s@   t dddg}t| dtjd}t dgd }t|| d S )Nr  r   r   r   rm   rU   )r   r   rB   r]   r   r#   r   )r1   r   r%   r&   r(   r(   r)   test_series_with_dtype  s    z*TestPandasContainer.test_series_with_dtypezdtype,expected
2000-01-01rY   r   l    ,Uqc                 C   s4   t dgdd}| }t|d|d}t|| d S )Nr  rY   r   r   r	  )r   rB   r   r#   r   )r1   r   r&   r   rT   r%   r(   r(   r)   test_series_with_dtype_datetime  s    z3TestPandasContainer.test_series_with_dtype_datetimec                 C   s8   t dddgdddgg}t| dd}t|| d S )Nr  T)r  r	   r   rB   r#   r$   r1   r9   r%   r(   r(   r)   "test_frame_from_json_precise_float  s    z6TestPandasContainer.test_frame_from_json_precise_floatc                 C   s>   t tdddddddgdd	}t| d d
}t|| d S )Nr   r;   r<   r=   r>   r   r  r   )r4   r   r   )r   r    r   rB   r#   r   r  r(   r(   r)   test_typ  s    zTestPandasContainer.test_typc                 C   sp   t dddgdddgg}t| }t|| t dddgdddgddd	d
gd}t| }t|| d S )NrF   rW   rU   rm   r   r   r;   r<   r   r   r   r   r  r  r(   r(   r)   test_reconstruction_index  s    $z-TestPandasContainer.test_reconstruction_indexc              	   C   s<   t d(}|||fD ]}|| t| qW 5 Q R X d S )N	test.json)r#   ensure_cleanrB   r   )r1   rb   ri   r:   r   r9   r(   r(   r)   	test_path  s    
zTestPandasContainer.test_pathc                 C   sR   |  }t|}t|| |  }t|dd}tj||dd |jd ksNtd S )Nr   r  F)Zcheck_names)rB   r   r#   r$   r   r   ra   )r1   r7   r:   r   r%   r(   r(   r)   test_axis_dates	  s    z#TestPandasContainer.test_axis_datesc                 C   s   |}t d|d< | }t|}t|| d|d< |jdd}t|dd}| }|d jd	|d< |d d
|d< t|| t	t d|j
d}| }t|dd}t|| d S )NrV   r   r   r   ns	date_unitFrX   r   r   r   r   r  )r   rB   r   r#   r$   r.   r   r\   rh   r   r4   r   )r1   r7   r:   r9   r   r%   r&   r3   r(   r(   r)   test_convert_dates  s     z&TestPandasContainer.test_convert_datesdate_formatepochiso	as_objectdate_typc                 C   sl   |ddddt jg}|r"|d t||d}|j|d}|dkrHd}nd	}|r\|d
d}||kshtd S )Ni  rF   )yearmonthdayr;   r   r  r  z+{"1577836800000":1577836800000,"null":null}zC{"2020-01-01T00:00:00.000Z":"2020-01-01T00:00:00.000Z","null":null}}	,"a":"a"})r   r   appendr   rB   replacera   )r1   r  r   r!  rT   r6   r%   r&   r(   r(   r)   test_date_index_and_values/  s    
z.TestPandasContainer.test_date_index_and_values
infer_wordZ
trade_timer   datetimeZsold_atr   	timestampZ
timestampsc                 C   sf   ddl m} dd|diddig}tdtdgdtjggd|gd}t||d|g }t|| d S )	Nr   dumpsidrF   l    $ArW   z
2002-11-08r   )	pandas.io.jsonr/  r	   r   r   r   r   r#   r$   )r1   r+  r/  rT   r&   r%   r(   r(   r)   test_convert_dates_inferF  s     z,TestPandasContainer.test_convert_dates_inferzdate,date_unit)20130101 20:43:42.123N)20130101 20:43:42r   )r3  ms)z20130101 20:43:42.123456us)z20130101 20:43:42.123456789r  c                 C   s   |}t ||d< tj|jd|jdf< tj|jd|jdf< |rT|jd|d}n|jdd}t|}| }|j	
d|_	|d j
d|d< t|| d S )Nr   rF   r   r  r  r  r%  UTC)r   r   r   r[   r"   r   rB   r   r.   r4   tz_localizedtr#   r$   )r1   r   r  r:   r9   r   r%   r&   r(   r(   r)   test_date_format_frame]  s    z*TestPandasContainer.test_date_format_framec              	   C   s4   |}d}t jt|d |jddd W 5 Q R X d S )N*Invalid value 'foo' for option 'date_unit'rK   r  r   r7  )rN   rO   rP   rB   )r1   r:   r9   rR   r(   r(   r)   test_date_format_frame_raisesw  s    z1TestPandasContainer.test_date_format_frame_raisesc                 C   s   t t||jd}tj|jd< tj|jd< |r>|jd|d}n|jdd}t|dd}| }|j	d	|_|j
	d	}t|| d S )
Nr   rF   r   r  r7  r%  r   r  r8  )r   r   r4   r   r   r[   rB   r   r.   r9  r:  r#   r   )r1   r   r  r7   r3   r   r%   r&   r(   r(   r)   test_date_format_series}  s    z+TestPandasContainer.test_date_format_seriesc              	   C   sB   t td|jd}d}tjt|d |jddd W 5 Q R X d S )Nr3  r   r<  rK   r  r   r7  )r   r   r4   rN   rO   rP   rB   )r1   r7   r3   rR   r(   r(   r)   test_date_format_series_raises  s    z2TestPandasContainer.test_date_format_series_raisesunitr   r5  r6  r  c                 C   s   |}t d|d< |jd}t d|jd|f< t d|jd|f< tj|jd|f< |jd|d	}t||d
}t	|| t|d d
}t	|| d S )Nr4  r   z19710101 20:43:42rF   z21460101 20:43:42rW   rm   r  r7  r  )
r   r"   r   r[   r   r   rB   r   r#   r$   )r1   r@  r:   r9   dlr   r%   r(   r(   r)   test_date_unit  s    z"TestPandasContainer.test_date_unitc                 C   s   d}t | d S )Nad  {
        "status": "success",
        "data": {
        "posts": [
            {
            "id": 1,
            "title": "A blog post",
            "body": "Some useful content"
            },
            {
            "id": 2,
            "title": "Another blog post",
            "body": "More content"
            }
           ]
          }
        })r   )r1   r   r(   r(   r)   test_weird_nested_json  s    z*TestPandasContainer.test_weird_nested_jsonc                 C   sx   t tjddtdd}td|d< td|d< d|d	< tjddd
|_	|
 }t|tjtjdd}t|| d S )Nr   rW   ZABr   rV   r   intsTboolsr   )rD  rE  r   )r	   r]   randomrandnr   r   r    r   r   r4   rB   r   r   Zbool_r#   r$   )r1   Zdfj2r   r%   r(   r(   r)   test_doc_example  s    z$TestPandasContainer.test_doc_examplec              	   C   s   t ddd}tddgddggddgd}d	}tjt|d
 tj||dd W 5 Q R X t d}tddgddggddgd}t|| d S )Nz#[{"a": 1, "b": 2}, {"b":2, "a" :1}]Tre   rF   rW   r;   r<   r   zDataFrame\.index are different

DataFrame\.index values are different \(100\.0 %\)
\[left\]:  Index\(\['a', 'b'\], dtype='object'\)
\[right\]: RangeIndex\(start=0, stop=2, step=1\)rK   Fr   )r   r	   rN   rO   ra   r#   r$   )r1   r%   r&   	error_msgr(   r(   r)   test_misc_example  s    z%TestPandasContainer.test_misc_examplec                 C   s<   d}t |}| }t|}t|j|j|jd| d S )Nz<https://raw.github.com/hayd/lahman2012/master/csvs/Teams.csvr?   )	r   Zread_csvrB   r   r#   r$   r   r4   r"   )r1   csvr9   r   r%   r(   r(   r)   test_round_trip_exception_  s
    
z.TestPandasContainer.test_round_trip_exception_zfield,dtypeZ
created_atr8  tzZ	closed_atZ
updated_atc                 C   s&   d}t |dd}|| j|ks"td S )Nz@https://api.github.com/repos/pandas-dev/pandas/issues?per_page=5Tr  )r   r   ra   )r1   fieldr   urlr%   r(   r(   r)   test_url  s    zTestPandasContainer.test_urlc                 C   sV  dd }t tdtddg}|jdks,tt| dd|}t|| t tdtddgt	
d	d
gd}|jdkstt| dd|}t|| ttdtddg}|d	 jdkstt|t| | ttddtddgd
dgt	jdddd}t|jdd}t	j|jdd|d< t	|j|d< t|| d S )Nc                 S   s   t j| ddS )Nr5  r@  )r   to_timedelta)rG   r(   r(   r)   <lambda>      z4TestPandasContainer.test_timedelta.<locals>.<lambda>   r   )secondsztimedelta64[ns]r   r  r   rF   r   daysrW   rV   )startr   r;   r<   r=   r  r  rT  r;   r=   )r   r   r   ra   r   rB   applyr#   r   r   r   r	   r$   r   rU  r;   Zto_datetimer=   )r1   	converterr   r%   framer(   r(   r)   test_timedelta  s,    $z"TestPandasContainer.test_timedeltac                 C   sr   t dtdtdgitd}t dt|jd jt|jd jgi}t|j	dddd	id}t
j||d
d d S )Nr;   rX  rV   r   r   rF   r  r  r   Fr   )r	   r   r   objectr   	Timedeltar;   r   r   rB   r#   r$   )r1   r`  r&   r%   r(   r(   r)   test_mixed_timedelta_datetime  s    $z1TestPandasContainer.test_mixed_timedelta_datetimetimedelta_typc                 C   sp   |dd|ddt jg}|r&|d t||d}|dkr@d}nd}|rT|d	d
}|j|d}||ksltd S )NrF   rZ  rW   r;   r   r  zA{"P1DT0H0M0S":"P1DT0H0M0S","P2DT0H0M0S":"P2DT0H0M0S","null":null}z7{"86400000":86400000,"172800000":172800000,"null":null}r&  r'  r%  )r   r   r(  r   r)  rB   ra   )r1   r   r  re  rT   r6   r&   r%   r(   r(   r)   test_timedelta_to_json"  s    
z*TestPandasContainer.test_timedelta_to_jsonc                 C   sN   t  }tdd|gi}tddt|gi}t|jtd}tj||dd d S )Nr;      r   Fr   )rb  r	   ro   r   rB   r#   r$   )r1   r   r`  r&   r%   r(   r(   r)   test_default_handler9  s
    z(TestPandasContainer.test_default_handlerc                 C   sb   ddl m} dd }dtddtdd	gtd
d dgdddgdg}d}|||dd|ks^td S )Nr   r.  c                 S   s(   t | tr dd| jfd| jfgS t| S )N)ZmathjsComplexreZim)
isinstancecomplexrealimagro   objr(   r(   r)   defaultC  s    
zBTestPandasContainer.test_default_handler_indirect.<locals>.default	   rF   ZSTRrm   r   zN/Ar  r;   r<   r   zR[9,[[1,null],["STR",null],[[["mathjs","Complex"],["re",4.0],["im",-5.0]],"N\/A"]]]r   r   r'   )r1  r/  r	   rl  r   ra   )r1   r/  rq  Zdf_listr&   r(   r(   r)   test_default_handler_indirect@  s    z1TestPandasContainer.test_default_handler_indirectc                 C   sP   t ddtddgtdd tddgdd	d
gd}d}|jtdd|ksLtd S )NrF   gffffff@rm   rs  r   g333333?r   r  r;   r<   r   zE[["(1+0j)","(nan+0j)"],["(2.3+0j)","(nan+0j)"],["(4-5j)","(1.2+0j)"]]r   rt  )r	   rl  r   rB   ro   ra   )r1   r9   r&   r(   r(   r)   ,test_default_handler_numpy_unsupported_dtypeU  s    $z@TestPandasContainer.test_default_handler_numpy_unsupported_dtypec              	      s   d  fdd}t jt d" tdddt gij|d W 5 Q R X t jt d& tdddtd	d
gij|d W 5 Q R X d S )NZraisinc                    s   t  d S r,   )	TypeErrorro  rR   r(   r)   my_handler_raisese  s    zJTestPandasContainer.test_default_handler_raises.<locals>.my_handler_raisesrK   r;   rF   rW   r   rm   rs  )rN   rO   rw  r	   rb  rB   rl  )r1   ry  r(   rx  r)   test_default_handler_raisesb  s    z/TestPandasContainer.test_default_handler_raisesc              	   C   sx   t ddddddddgi}|d |d< | }|d d|d< || ksPt|d }|d }| | ksttd S )Nr   r;   r<   r=   r   category)r	   rB   rh   ra   )r1   r9   r&   r   Zscr(   r(   r)   test_categoricalq  s    z$TestPandasContainer.test_categoricalc                 C   s   t jdddd}|dd }t|t jdddd}| }||d< | }|| ks`tt|}t|}| | kstd S )	NrV   rU   
US/Easternr   rP  utcrF  r   r   )	r   r   Z
tz_convertr9  r	   r.   rB   ra   r   )r1   tz_rangeZtz_naiver9   Zdf_naiver&   ZstzZs_naiver(   r(   r)   test_datetime_tz~  s    z$TestPandasContainer.test_datetime_tzc                 C   s   t tjdd}tj|jd d< |d}| }|| ksDtt	tjd}tj|jd d< |d}| }|| kstd S )Nr   rm      ZSparse)
r	   r]   rG  rH  r   r   rh   rB   ra   r   )r1   r9   Zsdfr&   r   ssr(   r(   r)   test_sparse  s    

zTestPandasContainer.test_sparsezsegfault GH 42130r3   z2013-01-10 05:00:00Zz2013-01-10 00:00:00r}  z2013-01-10 00:00:00-0500c                 C   sD   ddl m} d}||dd|ks$t| }||dd|ks@td S )Nr   r.  z"2013-01-10T05:00:00.000Z"TZ	iso_dates)r1  r/  ra   Zto_pydatetime)r1   r3   r/  expr:  r(   r(   r)   test_tz_is_utc  s
    
z"TestPandasContainer.test_tz_is_utcr  z2013-01-01 05:00:00ZrW   rF  z2013-01-01 00:00:00r~  z2013-01-01 00:00:00-0500c                 C   sl   ddl m} d}d}||dd|ks(tt|}||dd|ksDttd|i}||dd}||kshtd S )Nr   r.  z7["2013-01-01T05:00:00.000Z","2013-01-02T05:00:00.000Z"]zF{"DT":{"0":"2013-01-01T05:00:00.000Z","1":"2013-01-02T05:00:00.000Z"}}Tr  ZDT)r1  r/  ra   r
   r	   )r1   r  r/  r  Zdfexpr   r9   r%   r(   r(   r)   test_tz_range_is_utc  s    
z(TestPandasContainer.test_tz_range_is_utcc                 C   s8   t ddd}tddgddggddgd}t|| d S )	N!{"a": 1, "b": 2}
{"b":2, "a" :1}
TlinesrF   rW   r;   r<   r   r   r	   r#   r$   r   r(   r(   r)   test_read_inline_jsonl  s    z*TestPandasContainer.test_read_inline_jsonlc                 C   s:   t dd|d}tddgddggddgd}t|| d S )	Nzs3n://pandas-test/items.jsonlT)r  storage_optionsrF   rW   r;   r<   r   r  )r1   s3_resources3sor%   r&   r(   r(   r)   test_read_s3_jsonl  s      z&TestPandasContainer.test_read_s3_jsonlc              
   C   sn   t dZ}t|d}|d W 5 Q R X t|dd}tddgddggdd	gd
}t || W 5 Q R X d S )Nztmp_items.jsonwr  Tr  rF   rW   r;   r<   r   )r#   r  openwriter   r	   r$   )r1   r   infiler%   r&   r(   r(   r)   test_read_local_jsonl  s    z)TestPandasContainer.test_read_local_jsonlc                 C   s|   d}t |}t|dd}tddgddggddgd	}t|| d}t|dd}tddgddggddgd	}t|| d S )
Nu5   {"a": "foo”", "b": "bar"}
{"a": "foo", "b": "bar"}
Tr  u   foo”r   r   r;   r<   r   )r   r   r	   r#   r$   r1   r   r%   r&   r(   r(   r)   test_read_jsonl_unicode_chars  s    z1TestPandasContainer.test_read_jsonl_unicode_charsbigNumc                 C   sp   t |tdgd}| }dt| d }||ks4tt|tdgdgd}| }dt| d }||ksltd S )	N	articleId)r   r4   {"articleId":r&  r   )r   r4   r"   {"0":{"articleId":r   )r   rb  rB   ro   ra   r	   )r1   r  r   r   r&   r9   r(   r(   r)   test_to_json_large_numbers  s    z.TestPandasContainer.test_to_json_large_numberszGH-35279c              	   C   st   t dt| d }d}tjt|d t| W 5 Q R X t dt| d }tjt|d t| W 5 Q R X d S )Nr  r&  z#Value is too small|Value is too bigrK   r  r   )r   ro   rN   rO   rP   r   )r1   r  r   rR   r(   r(   r)   test_read_json_large_numbers  s    z0TestPandasContainer.test_read_json_large_numbersc                 C   sh   d}t |}t|dd}tddgd}t|| d}t |}t|}tddgdgd	}t|| d S )
Nz'{"articleId": "1404366058080022500245"}r   r  gg_SDr  r   z.{"0": {"articleId": "1404366058080022500245"}}r   r?   )r   r   r   r#   r   r	   r$   r  r(   r(   r)   test_read_json_large_numbers2  s    z1TestPandasContainer.test_read_json_large_numbers2c                 C   s   t ddgddggddgd}|jddd}d	}||ks:tt d
dgddggddgd}|jddd}d}||kstttt|dd| t ddgddggddgd}|jddd}d}||ksttt|dd| d S )NrF   rW   r;   r<   r   r   T)r'   r  z{"a":1,"b":2}
{"a":1,"b":2}
zfoo}r   zfoo"z/{"a":"foo}","b":"bar"}
{"a":"foo\"","b":"bar"}
r  zfoo\za\z4{"a\\":"foo\\","b":"bar"}
{"a\\":"foo\"","b":"bar"}
)r	   rB   ra   r#   r$   r   r   r(   r(   r)   test_to_jsonl  s    z!TestPandasContainer.test_to_jsonlc                 C   s   t d dddddgddddgdddddgdddddgddddgddddgd	ddddgtjdddgd	tjdddgg	}d
d |D }g }dtfD ] }|D ]}|t||d qqddd}|D ]}|| qd S )Nz3encoding not implemented in .to_json(), xref #13774s   E, 17rW     a   b   cs   EE, 17s   s   Ac                 S   s   g | ]}d d |D qS )c                 S   s$   g | ]}t |tr|d n|qS )latin-1)rk  r   decode)rq   rG   r(   r(   r)   rs   C  s     zFTestPandasContainer.test_latin_encoding.<locals>.<listcomp>.<listcomp>r(   )rq   rH   r(   r(   r)   rs   B  s   z;TestPandasContainer.test_latin_encoding.<locals>.<listcomp>r{  r   r  c              	   S   sD   t d0}| j||d t||d}t j| |dd W 5 Q R X d S )Nr  )encodingF)Zcheck_categorical)r#   r  rB   r   r   )r   r  r   Zretrr(   r(   r)   	roundtripL  s    z:TestPandasContainer.test_latin_encoding.<locals>.roundtrip)r  )rN   skipr]   r   rb  r(  r   )r1   r   Zexamplesr   valr  r   r(   r(   r)   test_latin_encoding2  s*    




z'TestPandasContainer.test_latin_encodingc                 C   sN   t dtdgi}|jddd }|  |jddd }||ksJtd S )Nr;   rF   T)r4   deep)r	   ro   Zmemory_usagesumrB   ra   )r1   r9   Zsize_beforeZ
size_afterr(   r(   r)   "test_data_frame_size_after_to_jsonU  s
    z6TestPandasContainer.test_data_frame_size_after_to_jsonr   r   r   r   1.2.c                 C   sB   t ddgddgg||d}|jdd}t|dd}t|| d S )NrF   rW   rU   rm   r?   tabler@   r	   rB   r   r#   r$   )r1   r4   r"   r&   dfjsonr%   r(   r(   r)   .test_from_json_to_json_table_index_and_columns_  s    zBTestPandasContainer.test_from_json_to_json_table_index_and_columnsc                 C   sD   t ddgddgddgd}|jdd	}t|dd	}t|| d S )
NrF   rW   r   r   r   r   r]  r  r@   r  )r1   r&   r  r%   r(   r(   r)   #test_from_json_to_json_table_dtypesj  s    z7TestPandasContainer.test_from_json_to_json_table_dtypes)r<   r=   c              	   C   sX   t ddgddgddgd}|jdd	}d
}tjt|d t|d|d W 5 Q R X d S )NrF   rW   r   r   r   r   r]  r  r@   z)cannot pass both dtype and orient='table'rK   )r'   r   r	   rB   rN   rO   rP   r   )r1   r   r9   r  rR   r(   r(   r)   !test_read_json_table_dtype_raisesq  s
    z5TestPandasContainer.test_read_json_table_dtype_raisesc              	   C   s^   t ddgddggddgddgd	}|jd
d}d}tjt|d t|d
dd W 5 Q R X d S )NrF   rW   rU   rm   r   r   r  r  r?   r  r@   z0cannot pass both convert_axes and orient='table'rK   Tr   r  )r1   r9   r  rR   r(   r(   r)   (test_read_json_table_convert_axes_raisesz  s
    "z<TestPandasContainer.test_read_json_table_convert_axes_raiseszdata, expectedrm   r   r   )r"   rT   r   r   r   r   )r   rT   )r   r4   c                 C   s(   |j ddd}t|}||ks$td S )NrE   Fr'   r4   )rB   r   loadsra   )r1   rT   r&   r%   r(   r(   r)   test_index_false_to_json_split  s     
z2TestPandasContainer.test_index_false_to_json_splitc                 C   sL   |j ddd}t|}tjjj|ddt|jddd}||ksHtd S )Nr  Fr  r   r   r@   )ZschemarT   )	rB   r   r  r   r   Zbuild_table_schemar	   Zto_dictra   r1   rT   r%   r&   r(   r(   r)   test_index_false_to_json_table  s    
z2TestPandasContainer.test_index_false_to_json_tablec              	   C   sL   t ddgddggddgd}d}tjt|d	 |j|d
d W 5 Q R X d S )NrF   rW   rm   r   r;   r<   r   z?'index=False' is only valid when 'orient' is 'split' or 'table'rK   Fr  rM   rQ   r(   r(   r)   test_index_false_error_to_json  s    z2TestPandasContainer.test_index_false_error_to_jsonr  c                 C   s@   t ddgddgd}|j||d}t||d}t|| d S )NrF   rW   rU   rm   r  r  r@   r  )r1   r'   r4   r&   r  r%   r(   r(   r)   "test_index_false_from_json_to_json  s    z6TestPandasContainer.test_index_false_from_json_to_jsonc                 C   s6   t dddd}tdgtdgddd	}t|| d S )
Nz{"2019-01-01T11:00:00.000Z":88}r   r4   )r   r'   X   z2019-01-01 11:00:00r8  rO  r   )r   r   r
   r#   r   r   r(   r(   r)   test_read_timezone_information  s      z2TestPandasContainer.test_read_timezone_informationzdate_format,key)r  i \&)r  Z
P1DT0H0M0Sc                 C   s@   t dggtdgd}d| d}|j|d}||ks<td S )NrF   Z1Dr   r   z
":{"0":1}}r%  )r	   r   rc  rB   ra   )r1   r  keyr9   r&   r%   r(   r(   r)   test_timedelta_as_label  s    z+TestPandasContainer.test_timedelta_as_labelzorient,expected)r4   z{"('a', 'b')":{"('c', 'd')":1}})r"   z{"('c', 'd')":{"('a', 'b')":1}} )Zmarksc                 C   s2   t dggdgdgd}|j|d}||ks.td S )NrF   r  )r=   r>   r?   r@   r   r1   r'   r&   r9   r%   r(   r(   r)   test_tuple_labels  s    z%TestPandasContainer.test_tuple_labelsindentc                 C   s   t ddgddggddgd}|j|d}d	| }d
| d| | d| | d| d| d| | d| | d| d}||kstd S )Nr   r   r   r   r;   r<   r   r   z{
z"a":{
z"0":"foo",
z
"1":"baz"
z},
z"b":{
z"0":"bar",
z
"1":"qux"
z}
}r   )r1   r  r9   r%   spacesr&   r(   r(   r)   test_to_json_indent  s:    z'TestPandasContainer.test_to_json_indent)rE   z{
    "columns":[
        "a",
        "b"
    ],
    "index":[
        0,
        1
    ],
    "data":[
        [
            "foo",
            "bar"
        ],
        [
            "baz",
            "qux"
        ]
    ]
})r   zf[
    {
        "a":"foo",
        "b":"bar"
    },
    {
        "a":"baz",
        "b":"qux"
    }
])r4   zn{
    "0":{
        "a":"foo",
        "b":"bar"
    },
    "1":{
        "a":"baz",
        "b":"qux"
    }
})r"   zn{
    "a":{
        "0":"foo",
        "1":"baz"
    },
    "b":{
        "0":"bar",
        "1":"qux"
    }
})r   zV[
    [
        "foo",
        "bar"
    ],
    [
        "baz",
        "qux"
    ]
])r  ab  {
    "schema":{
        "fields":[
            {
                "name":"index",
                "type":"integer"
            },
            {
                "name":"a",
                "type":"string"
            },
            {
                "name":"b",
                "type":"string"
            }
        ],
        "primaryKey":[
            "index"
        ],
        "pandas_version":"0.20.0"
    },
    "data":[
        {
            "index":0,
            "a":"foo",
            "b":"bar"
        },
        {
            "index":1,
            "a":"baz",
            "b":"qux"
        }
    ]
}c                 C   s:   t ddgddggddgd}|j|dd	}||ks6td S )
Nr   r   r   r   r;   r<   r   rm   )r'   r  r   r  r(   r(   r)   test_json_indent_all_orients  s    wz0TestPandasContainer.test_json_indent_all_orientsc              	   C   s,   t jtdd t jdd W 5 Q R X d S )Nzmust be a nonnegative integerrK   r  )rN   rO   rP   r	   rB   r0   r(   r(   r)    test_json_negative_indent_raises  s    z4TestPandasContainer.test_json_negative_indent_raisesc                 C   s:   d}t |}tdtjdtjdtj dg}t|| d S )Nz?["a", NaN, "NaN", Infinity, "Infinity", -Infinity, "-Infinity"]r;   NaNInfinityz	-Infinity)r   r	   r]   r   r   r#   r$   r  r(   r(   r)   test_emca_262_nan_inf_support  s    z1TestPandasContainer.test_emca_262_nan_inf_supportc              	   C   sD   t dddg}tt" t| dd}t|| W 5 Q R X d S )NrF   rW   rU   TrJ  )r	   r#   Zassert_produces_warningFutureWarningr   rB   r$   )r1   r&   r%   r(   r(   r)   'test_deprecate_numpy_argument_read_json  s    z;TestPandasContainer.test_deprecate_numpy_argument_read_jsonc                 C   s>   t ddiddig}tdddgi}t|}t|| d S )NcolZ31900441201190696999Text)r   r/  r	   r   r#   r$   )r1   Zencoded_jsonr&   r%   r(   r(   r)   test_frame_int_overflow  s    z+TestPandasContainer.test_frame_int_overflowzdataframe,expectedrG   rH   zU{"(0, 'x')":1,"(0, 'y')":"a","(1, 'x')":2,"(1, 'y')":"b","(2, 'x')":3,"(2, 'y')":"c"}c                 C   s$   |  }|jdd}||ks td S r   )stackrB   ra   )r1   Z	dataframer&   r   r%   r(   r(   r)   test_json_multiindex  s    z(TestPandasContainer.test_json_multiindexzlocalhost connection rejected)rv   strictc                 C   s   dd l }d\}}tdddgdddgd}|jd	| d
| |d d}|dd |dj D krhq|d |d8 }|dksHtdqHd S )Nr   )pandas-testr  rF   rW   rU   rm   r   r  zs3:///)r  r   c                 s   s   | ]}|j V  qd S r,   )r  )rq   rp  r(   r(   r)   	<genexpr>  s    z1TestPandasContainer.test_to_s3.<locals>.<genexpr>r  r   z,Timed out waiting for file to appear on moto)timer	   rB   ZBucketZobjectsallsleepra   )r1   r  r  r  Zmock_bucket_nameZtarget_filer9   timeoutr(   r(   r)   
test_to_s3  s    
zTestPandasContainer.test_to_s3c                 C   sD   t |tr$tjjdd}|j| t|gg }|dks@t	d S )Nznot implementedru   z{"0":{"0":null}})
rk  r   rN   rz   r{   rx   ry   r	   rB   ra   )r1   Znulls_fixturer|   rz   r%   r(   r(   r)   test_json_pandas_nulls  s
    
z*TestPandasContainer.test_json_pandas_nullsc                 C   s*   t ddd}tdddg}t|| d S )Nz[true, true, false]r   r  TF)r   r   r#   r   r   r(   r(   r)   test_readjson_bool_series  s    z-TestPandasContainer.test_readjson_bool_seriesc                 C   s:   t dtddddgd }| }d}||ks6td S )NTz
2017-01-20z
2017-01-23r   r   r?   a  {"(Timestamp('2017-01-20 00:00:00'), 'foo')":true,"(Timestamp('2017-01-20 00:00:00'), 'bar')":true,"(Timestamp('2017-01-21 00:00:00'), 'foo')":true,"(Timestamp('2017-01-21 00:00:00'), 'bar')":true,"(Timestamp('2017-01-22 00:00:00'), 'foo')":true,"(Timestamp('2017-01-22 00:00:00'), 'bar')":true,"(Timestamp('2017-01-23 00:00:00'), 'foo')":true,"(Timestamp('2017-01-23 00:00:00'), 'bar')":true})r	   r   r   r  rB   ra   r   r(   r(   r)   test_to_json_multiindex_escape  s    


z2TestPandasContainer.test_to_json_multiindex_escape)r   r   r   rN   Zfixturer2   r7   r:   rD   rz   ZparametrizerI   rS   r   r^   r_   rc   r   rg   r]   r   rj   Zfloat64intr}   r   r   r   r   r   r   r   r   r   ZNINFr   Zskipifr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r
  r   r  r  r  r  r  r  r  r,  r   r*  r2  r;  r=  r>  r?  rB  rC  rI  rL  r#   networkZsinglerN  r   ZDatetimeTZDtyperS  ra  rd  rc  r   rf  rh  ru  rv  rz  r|  r  r  r   r  r   r  r  tdZskip_if_not_us_localer  r  r  sysmaxsizer  r   r  r  r  r  r  r  r  r  r  r	   Zrename_axisr  r  r  r  r  r  paramr  r  r  r  r  r  r  r  r  r{   r   r   r  r  r  r  r(   r(   r(   r)   r+   2   s  





	

&$

	`&









	
	
		
#

 .& (  ( 	 (   
 
u	

	r+   )0r,  r   decimalr   r   r   r   r   r  re   r]   rN   Zpandas.compatr   r   r   r   Zpandas.util._test_decoratorsutilZ_test_decoratorsr  Zpandasr   r	   r
   r   r   r   r   Zpandas._testingZ_testingr#   ZgetSeriesDataZ_seriesdZ_framer.   r-   r!   catZCategoricalIndexr4   r   reversedr   r*   rz   filterwarningsr+   r(   r(   r(   r)   <module>   s4    0
