o
    d,                     @   s   d dl m Z mZ d dlmZ d dlZd dlZd dlmZm	Z	m
Z
mZmZmZmZmZmZmZmZ d dlmZ d dlm  m  mZ G dd dZdS )    )datetime	timedelta)StringION)NACategorical	DataFrame
MultiIndexNaTPeriodIndexSeries	Timestamp
date_rangeoption_contextperiod_rangec                   @   s<  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zejjdd Zdd Zdd Zejj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/d0 Zejd1ej ej!gejd2e"d3ge#d4ggd5d6 Z$d7d8 Z%d9d: Z&d;d< Z'd=d> Z(d?d@ Z)dAS )BTestDataFrameReprInfoEtcc                    s   t d dd} fddt|D }t|d}|jtk s$J t| t|jd dd d f  t|jd dd d f  d S )	NACDEFGHIJKLMNOP2     c                    s"   g | ]} fd dt D qS )c                    s   g | ]}t j qS  )nprandomchoice).0x)letsr   f/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/pandas/tests/frame/test_repr_info.py
<listcomp>"   s    zPTestDataFrameReprInfoEtc.test_repr_bytes_61_lines.<locals>.<listcomp>.<listcomp>)range)r   _r   slenr   r   r   "   s   " zETestDataFrameReprInfoEtc.test_repr_bytes_61_lines.<locals>.<listcomp>U1<   =   )	listr   r   astypedtypesobjectallrepriloc)selfnseqswordsdfr   r   r   test_repr_bytes_61_lines   s   z1TestDataFrameReprInfoEtc.test_repr_bytes_61_linesc                 C   sD   t jddgddgd}ttjdd|d}t||}t| d S )	N)r   r   )   r0   u   Δi1names      index)	r   from_tuplesr   r   r   randntmget_objr)   )r+   frame_or_seriesr7   objr   r   r   test_repr_unicode_level_names+   s   z6TestDataFrameReprInfoEtc.test_repr_unicode_level_namesc                 C   sd   t g dg dg ddddg}t|j}d|d< ||_t| d	d
g|d< ||_t| d S )Nr0   r4      r5               	   abcrI   rJ   )fazboor   rL   rM   )r   	set_indexr$   r7   r)   )r+   r.   r7   r   r   r   test_assign_index_sequences2   s   
z4TestDataFrameReprInfoEtc.test_assign_index_sequencesc                 C   s@   t dddgittdgddggd}t|}d}||ksJ d S )	NXr0   r4   20130101rI   rJ   r6   z/              X
NaT        a  1
2013-01-01 b  2)r   r	   r   r)   r+   r.   resultexpectedr   r   r   test_repr_with_mi_natA   s   $z.TestDataFrameReprInfoEtc.test_repr_with_mi_natc                 C   s4   t g ddd tjtg}t|}d}||ksJ d S )N)r0   r4   r@   r5   Tz'      0
True  1
None  2
NaN   3
NaT   4)r   r   nanr	   r)   rR   r   r   r   test_repr_with_different_nullsG   s   z7TestDataFrameReprInfoEtc.test_repr_with_different_nullsc              	   C   sL   t jddgd ddgtddgddd	gi}t|d
}t|}d}||ks$J d S )Nr0   r4   r@   r5   rC   rE   TrF   rG   )datazG   NaN  None  NaT  True
0    1     3    6     8
1    2     4    7     9)r   rV   r	   r   r)   )r+   dr.   rS   rT   r   r   r   #test_repr_with_different_nulls_colsR   s
   &
z<TestDataFrameReprInfoEtc.test_repr_with_different_nulls_colsc                 C   sP   t ddidtjidtjidtjiddidtjid}|ddg}t| d S )N)AA0006000nuitr\   r[   )AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFr^   r`   )r   r   rV   rN   r)   )r+   df3idfr   r   r   test_multiindex_na_repr\   s   z0TestDataFrameReprInfoEtc.test_multiindex_na_reprc                 C   sN   t jddgg dd}tdddgi|d}t|d	}|d
 ds%J d S )N)rI   r   foo)rJ   r0   barrH   r2   valuer   r0   r6   
r4   za 0 foo)r   r8   r   r)   split
startswith)r+   r7   r.   linesr   r   r   test_repr_name_coincidel   s   z0TestDataFrameReprInfoEtc.test_repr_name_coincidec                 C   sj   |}|}t | t | t |j t |j t }|j|d |j|d |jj|d |jj|d d S )Nbuf)r)   Tr   	to_string)r+   /multiindex_year_month_day_dataframe_random_data multiindex_dataframe_random_dataymdframerp   r   r   r   test_repr_to_stringv   s   

z,TestDataFrameReprInfoEtc.test_repr_to_stringc                 C   s&   t t  ttdd}t | d S )Nr   r6   )r)   r   r   arange)r+   rv   r   r   r   test_repr_empty   s   
z(TestDataFrameReprInfoEtc.test_repr_emptyc                 C   s    t  }t| |jd|d d S )NFverboserp   )r   r)   info)r+   float_string_framerp   r   r   r   test_repr_mixed   s   z(TestDataFrameReprInfoEtc.test_repr_mixedc                 C   sX   t tjdtddtdd}tj|jd ddf< tj|jd ddf< t	| d S )N   )r[   Br6      r[   r   )
r   r   r   r9   r:   makeStringIndexr   rV   locr)   r+   biggier   r   r   test_repr_mixed_big   s   z,TestDataFrameReprInfoEtc.test_repr_mixed_bigc                 C   s   t  }t| |jd|d |jdgdjd|d |jddgdjd|d tg dd}t| t j|d tdgd	gd
gd}dt|vsKJ dt|vsSJ dt|vs[J d S )NFrz   r[   columnsr   )r   r0   r@   ro   za
	bza
	dza
	fr   r7   	za
)r   r)   r|   reindexr   )r+   float_framerp   no_indexr.   r   r   r   	test_repr   s   z"TestDataFrameReprInfoEtc.test_reprc                 C   s   t ddgddgg}tdd dt|v sJ W d    n1 s"w   Y  tdd dt|vs5J W d    n1 s?w   Y  tdd	 dt|vsRJ W d    d S 1 s]w   Y  d S )
Nr0   r4   r@   r5   zdisplay.show_dimensionsTz2 rows x 2 columnsFtruncater   r   r)   r+   r.   r   r   r   test_repr_dimensions   s   "z-TestDataFrameReprInfoEtc.test_repr_dimensionsc                 C   s(   t tdtdtdd}t| d S )N)r   r5   r5   r   r   )r   r   zerosr   r)   r   r   r   r   test_repr_big   s   z&TestDataFrameReprInfoEtc.test_repr_bigc              
   C   s   t ddgd t dgd ddgd t td dgd itdd}t| tdd t| tdd	d
d t| tddd
d t| t	
  d S )Nrg   r0   r   rh   r6   zdisplay.precisionr@   zdisplay.max_rows
   display.max_columnsr4   r   )r   r   todayr   r   rx   r)   fmt
set_optionr:   reset_display_options)r+   r   
unsortabler   r   r   test_repr_unsortable   s    

	z-TestDataFrameReprInfoEtc.test_repr_unsortablec                 C   sp   d}t d||gi}t|}d}|dd  |ksJ t d||gi}t|}|dd  |ks6J d S )Nu   σσσσr[   z      Arj   r   )r   r)   rk   rstrip)r+   uvalr.   rS   ex_topr   r   r   test_repr_unicode   s   z*TestDataFrameReprInfoEtc.test_repr_unicodec                 C   s   t ddgi}t| d S )Nr[      א)r   strr   r   r   r    test_unicode_string_with_unicode   s   z9TestDataFrameReprInfoEtc.test_unicode_string_with_unicodec                 C   s*   t g dg dg dd}t|j d S )Nr?   rA   rD   )r   u   בrK   )r   r)   r   r   r   r   r   test_repr_unicode_columns   s   z2TestDataFrameReprInfoEtc.test_repr_unicode_columnsc                 C   sN   t ddgi}d}tjt|d t| W d    d S 1 s w   Y  d S )Nr[   abcz2^'str' object cannot be interpreted as an integer$)match)r   pytestraises	TypeErrorbytes)r+   r.   msgr   r   r   test_str_to_bytes_raises   s
   
"z1TestDataFrameReprInfoEtc.test_str_to_bytes_raisesc                 C   s*   t tjddtddd}t| d S )Nr   r   r   )r   r   r   r9   r:   rands_arrayr)   r   r   r   r   test_very_wide_info_repr  s   z1TestDataFrameReprInfoEtc.test_very_wide_info_reprc                 C   sP   t dgdd}tdd dt|v sJ W d    d S 1 s!w   Y  d S )Nizl u  Is it possible to modify drop plot codeso that the output graph is displayed in iphone simulator, Is it possible to modify drop plot code so that the output graph is â¨displayed in iphone simulator.Now we are adding the CSV file externally. I want to Call the File through the code..)Id	StringColr   r   r   r   r   r   r   r   ,test_repr_column_name_unicode_truncation_bug  s   "zETestDataFrameReprInfoEtc.test_repr_column_name_unicode_truncation_bugc                 C   sx   t d d}tdd dd tg dg dg}| }||ks#J W d    n1 s-w   Y  | d u s:J d S )Njinja2z{\begin{tabular}{llll}
\toprule
 & 0 & 1 & 2 \\
\midrule
0 & $\alpha$ & b & c \\
1 & 1 & 2 & 3 \\
\bottomrule
\end{tabular}
zstyler.format.escapezstyler.render.reprlatex)z$\alpha$rJ   rK   r?   )r   importorskipr   r   _repr_latex_)r+   rT   r.   rS   r   r   r   test_latex_repr  s   
	z(TestDataFrameReprInfoEtc.test_latex_reprc                 C   sj   t ddddd}tdddd}t||d	}d
}t||ks J tt|t|d	}t||ks3J d S )Nz2011-01-01 09:00HrB   z
US/Eastern)freqperiodstzz2011-01M)r   r   )dtpz                         dt        p
0 2011-01-01 09:00:00-05:00  2011-01
1 2011-01-01 10:00:00-05:00  2011-02
2 2011-01-01 11:00:00-05:00  2011-03
3 2011-01-01 12:00:00-05:00  2011-04
4 2011-01-01 13:00:00-05:00  2011-05)r   r   r   r)   r   )r+   r   r   r.   expdf2r   r   r   #test_repr_categorical_dates_periods0  s   z<TestDataFrameReprInfoEtc.test_repr_categorical_dates_periodsargzbox, expectedz0    NaT
dtype: objectz     0
0  NaTc                 C   s&   t ||dgtd}||ksJ d S )Nr	   dtype)r)   r'   )r+   r   boxrT   rS   r   r   r   test_repr_np_nat_with_objectA  s   z5TestDataFrameReprInfoEtc.test_repr_np_nat_with_objectc                 C   s"   t dtddddi}t| d S )Nyearz1/1/1700r   zA-DEC)r   r   )r   r   r)   r   r   r   r   "test_frame_datetime64_pre1900_reprK  s   z;TestDataFrameReprInfoEtc.test_frame_datetime64_pre1900_reprc                 C   s2   t g ddd}ttjdd|d}|  d S )N)z2011-1z2011-2z2011-3r   )r   r@   r5   r6   )r
   r   r   r   r9   rr   )r+   r7   rv   r   r   r   %test_frame_to_string_with_periodindexP  s   z>TestDataFrameReprInfoEtc.test_frame_to_string_with_periodindexc                 C   sD   t dddgitttdgddgd}| }d}||ks J d S )NrI   r0   r4   Int64r   r6   z      a
<NA>  1
1     2)r   r   from_arraysr   r   rr   rR   r   r   r   "test_to_string_ea_na_in_multiindexW  s   
z;TestDataFrameReprInfoEtc.test_to_string_ea_na_in_multiindexc                 C   sL   t dtddddi}t|}|jd d d df }t|}||ks$J d S )Nr   2019r   UTC)r   r   rB   )r   r   r)   r*   )r+   r.   rT   rS   r   r   r   $test_datetime64tz_slice_non_truncated  s
   z=TestDataFrameReprInfoEtc.test_datetime64tz_slice_non_truncatec                 C   sN   t tddgddtddgddd}|jd	jd	jgd
}d}||ks%J d S )Ng_c97ݚ?g6sӭ?Float64r   r0   r4   r   )rI   rJ   z{:.2f})
formattersz)      a     b
0  0.12  1.00
1  1.12  2.00)r   r   rr   formatrR   r   r   r   test_masked_ea_with_formatterl  s   z6TestDataFrameReprInfoEtc.test_masked_ea_with_formatterN)*__name__
__module____qualname__r/   r>   rO   rU   rW   rZ   rf   rn   rw   ry   r~   r   markslowr   r   r   r   r   r   r   r   r   r   r   r   r   parametrizer   
datetime64timedelta64r   r   r   r   r   r   r   r   r   r   r   r   r      sL    




r   )r   r   ior   numpyr   r   pandasr   r   r   r   r	   r
   r   r   r   r   r   pandas._testing_testingr:   pandas.io.formats.formatformatsr   r   r   r   r   r   r   <module>   s    4