
    o[we8                         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c mc mZ  G d d          ZdS )    )datetime	timedelta)StringION)NACategorical	DataFrame
MultiIndexNaTPeriodIndexSeries	Timestamp
date_rangeoption_contextperiod_rangec                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zej        j        d             Zd Zd Zej        j        d             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zej                            dej         ej!        g          ej                            de"dge#dgg          d                         Z$d Z%d Z&d  Z'd! Z(d" Z)d# Z*d$ Z+d% Z,d& Z-d' Z.d( Z/d)S )*TestDataFrameReprInfoEtcc                    t          d          dd}f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                 F    g | ]}fd t                    D             S )c                 t    g | ]4}t           j                            d                                         5S )   )nprandomdefault_rngchoice).0xletss     Alib/python3.11/site-packages/pandas/tests/frame/test_repr_info.py
<listcomp>zPTestDataFrameReprInfoEtc.test_repr_bytes_61_lines.<locals>.<listcomp>.<listcomp>#   s7    HHHqRY""1%%,,T22HHH    )range)r   _r    slens     r!   r"   zETestDataFrameReprInfoEtc.test_repr_bytes_61_lines.<locals>.<listcomp>"   sD     
 
 
 IHHHE$KKHHH
 
 
r#   U1<   =   )	listr$   r   astypedtypesobjectallrepriloc)selfnseqswordsdfr    r&   s       @@r!   test_repr_bytes_61_linesz1TestDataFrameReprInfoEtc.test_repr_bytes_61_lines   s    %&&
 
 
 
 
5\\
 
 
 u$$T**	V#((***** 	RRWSbS!!!V_RWSbS!!!V_r#   c                    t          j        ddgddg          }t          t          j                            d                              d          |          }t          j        ||          }t          |           d S )	N)r   r   )   r7   u   Δi1namesr   )r      index)
r	   from_tuplesr   r   r   r   standard_normaltmget_objr/   )r1   frame_or_seriesr=   objs       r!   test_repr_unicode_level_namesz6TestDataFrameReprInfoEtc.test_repr_unicode_level_names.   sr    &'7$?OPPP	--a00@@HHPUVVVjo..S					r#   c                     t          g dg dg dd                              ddg          }t          |j                  }d|d<   ||_        t	          |           d	d
g|d<   ||_        t	          |           d S )Nr7   r      r;               	   abcrP   rQ   )fazboor   rS   rT   )r   	set_indexr*   r=   r/   )r1   r4   r=   s      r!   test_assign_index_sequencesz4TestDataFrameReprInfoEtc.test_assign_index_sequences5   s    YYYYYYYYYGGHHRR#J
 
 RX!aR 5>aRr#   c                     t          dddgit          t          d          gddgg          }t          |          }d}||k    sJ d S )	NXr7   r   20130101rP   rQ   r<   z/              X
NaT        a  1
2013-01-01 b  2)r   r
   r   r/   r1   r4   resultexpecteds       r!   test_repr_with_mi_natz.TestDataFrameReprInfoEtc.test_repr_with_mi_natD   sZ    aV}c9Z3H3H-ICQT:,VWWWbF!!!!!!r#   c                     t          g ddd t          j        t          g          }t	          |          }d}||k    sJ d S )N)r7   r   rG   r;   Tz'      0
True  1
None  2
NaN   3
NaT   4)r   r   nanr
   r/   rZ   s       r!   test_repr_with_different_nullsz7TestDataFrameReprInfoEtc.test_repr_with_different_nullsJ   sK    |||dD"&#%>??b
 !!!!!!r#   c           	          t           j        ddgd ddgt          ddgddd	gi}t          |
          }t	          |          }d}||k    sJ d S )Nr7   r   rG   r;   rJ   rL   TrM   rN   )datazG   NaN  None  NaT  True
0    1     3    6     8
1    2     4    7     9)r   r_   r
   r   r/   )r1   dr4   r[   r\   s        r!   #test_repr_with_different_nulls_colsz<TestDataFrameReprInfoEtc.test_repr_with_different_nulls_colsU   se    VaVTAq63Aq!fEAb !!!!!!r#   c           	          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nuitrg   rf   )AAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFri   rk   )r   r   r_   rU   r/   )r1   df3idfs      r!   test_multiindex_na_reprz0TestDataFrameReprInfoEtc.test_multiindex_na_repr_   sz    4jA4bf=4bf=4bf=4c:4bf= 	
 	
 mmXx011S					r#   c                     t          j        ddgg d          }t          dddgi|          }t          |                              d	          }|d
                             d          sJ d S )N)rP   r   foo)rQ   r7   barrO   r9   valuer   r7   r<   
r   za 0 foo)r	   r>   r   r/   split
startswith)r1   r=   r4   liness       r!   test_repr_name_coincidez0TestDataFrameReprInfoEtc.test_repr_name_coincideo   s    &o.ooo
 
 
 !Q(666Rt$$Qx""9-------r#   c                 z   |}|}t          |           t          |           t          |j                   t          |j                   t                      }|                    |           |                    |           |j                            |           |j                            |           d S )Nbuf)r/   Tr   	to_string)r1   /multiindex_year_month_day_dataframe_random_data multiindex_dataframe_random_dataymdframer}   s         r!   test_repr_to_stringz,TestDataFrameReprInfoEtc.test_repr_to_stringy   s    
 >0US			UWSUjjC   #c"""C     r#   c                     t          t                                 t          t          j        d                    }t          |           d S )Nr   r<   )r/   r   r   arange)r1   r   s     r!   test_repr_emptyz(TestDataFrameReprInfoEtc.test_repr_empty   s=    Y[[ 	$000Ur#   c                 n    t                      }t          |           |                    d|           d S )NFverboser}   )r   r/   info)r1   float_string_framer}   s      r!   test_repr_mixedz(TestDataFrameReprInfoEtc.test_repr_mixed   s;    jj 	   377777r#   c                 J   t          t          j                            d                              d          t          j        d          dt          d                    }t          j        |j	        d ddf<   t          j        |j	        d ddf<   t          |           d S )Nr      )rf   Br<      rf   r   )r   r   r   r   r?   r@   makeStringIndexr$   r_   locr/   r1   biggies     r!   test_repr_mixed_bigz,TestDataFrameReprInfoEtc.test_repr_mixed_big   s     Y**1--==cBB',,  **
 
 
  "v
3B38!v
3B38Vr#   c                 B   t                      }t          |           |                    d|           |                    dg                              d|           |                    ddg                              d|           t	          g d          }t          |           t	                                          |           t	          dgd	gd
g          }dt          |          vsJ dt          |          vsJ dt          |          vsJ d S )NFr   rf   columnsr   )r   r7   rG   r|   za
	bza
	dza
	fr   r=   	za
)r   r/   r   reindexr   )r1   float_framer}   no_indexr4   s        r!   	test_reprz"TestDataFrameReprInfoEtc.test_repr   s3   jj 	[C000 	SE**//3/GGGS#J//44U4LLL
 YYY///X 	S!!!
|j\*NNN488####488####DHH$$$$$$r#   c                    t          ddgddgg          }t          dd          5  dt          |          v sJ 	 d d d            n# 1 swxY w Y   t          dd          5  dt          |          vsJ 	 d d d            n# 1 swxY w Y   t          dd	          5  dt          |          vsJ 	 d d d            d S # 1 swxY w Y   d S )
Nr7   r   rG   r;   zdisplay.show_dimensionsTz2 rows x 2 columnsFtruncater   r   r/   r1   r4   s     r!   test_repr_dimensionsz-TestDataFrameReprInfoEtc.test_repr_dimensions   s   AA'((5t<< 	4 	4'48833333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 5u== 	8 	8'tBxx77777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 5zBB 	8 	8'tBxx77777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s5   AAA"BB
BC  CCc                     t          t          j        d          t          d          t          d                    }t	          |           d S )N)r   r;   r;   r   r   )r   r   zerosr$   r/   r   s     r!   test_repr_bigz&TestDataFrameReprInfoEtc.test_repr_big   s=     28H--uQxxuSzzRRRVr#   c                    t          ddgdz  t          j                    dgdz  ddgdz  t          j                    t          d          z   dgdz  it	          j        d                    }t          |           t          j        dd           t          |           t          j        dd	d
d           t          |           t          j        ddd
d           t          |           t          j
                     d S )Nrs   r7   r   rt   r<   zdisplay.precisionrG   zdisplay.max_rows
   display.max_columnsr   r   )r   r   todayr   r   r   r/   fmt
set_optionr@   reset_display_options)r1   r   
unsortables      r!   test_repr_unsortablez-TestDataFrameReprInfoEtc.test_repr_unsortable   s    sRx  1#(w|  9Q<</%2	 )B--
 
 

 	Z*A...[)2/DaHHH[)41FMMM[
 """""r#   c                 b   d}t          d||gi          }t          |          }d}|                    d          d                                         |k    sJ t          d||gi          }t          |          }|                    d          d                                         |k    sJ d S )Nu   σσσσrf   z      Arv   r   )r   r/   rw   rstrip)r1   uvalr4   r[   ex_tops        r!   test_repr_unicodez*TestDataFrameReprInfoEtc.test_repr_unicode   s    )dD\*++b||D!!!$++--7777dD\*++b||D!!!$++--777777r#   c                 H    t          ddgi          }t          |           d S )Nrf      א)r   strr   s     r!    test_unicode_string_with_unicodez9TestDataFrameReprInfoEtc.test_unicode_string_with_unicode   s%    hZ())Br#   c                 `    t          g dg dg dd          }t          |j                   d S )NrF   rH   rK   )r   u   בrR   )r   r/   r   r   s     r!   test_repr_unicode_columnsz2TestDataFrameReprInfoEtc.test_repr_unicode_columns   s;    )))yyyyyyQQRRRZr#   c                     t          ddgi          }d}t          j        t          |          5  t	          |           d d d            d S # 1 swxY w Y   d S )Nrf   abcz2^'str' object cannot be interpreted as an integer$match)r   pytestraises	TypeErrorbytes)r1   r4   msgs      r!   test_str_to_bytes_raisesz1TestDataFrameReprInfoEtc.test_str_to_bytes_raises  s    eW~&&B]9C000 	 	"III	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAAc                     t          t          j                            d                              d          t          j        dgdz  t                              }t          |           d S )Nr   )r   r   
aaaaaaaaaar   dtyper   )r   r   r   r   r?   arrayr-   r/   r   s     r!   test_very_wide_info_reprz1TestDataFrameReprInfoEtc.test_very_wide_info_repr	  s`    I!!!$$44X>>HhZ"_F;;;
 
 
 	Rr#   c                     t          dgdd          }t          dd          5  dt          |          v sJ 	 d d d            d S # 1 swxY 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   s     r!   ,test_repr_column_name_unicode_truncation_bugzETestDataFrameReprInfoEtc.test_repr_column_name_unicode_truncation_bug  s    i2 
 
  1266 	+ 	+$r((*****	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s   AA
A
c                    t          j        d           d}t          dd dd          5  t          g dg dg          }|                                }||k    sJ 	 d d d            n# 1 swxY w Y   |                                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$rQ   rR   rF   )r   importorskipr   r   _repr_latex_)r1   r\   r4   r[   s       r!   test_latex_reprz(TestDataFrameReprInfoEtc.test_latex_repr%  s    H%%% "D*>
 
 	& 	& 333YYY?@@B__&&FX%%%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&   (((((s   2A((A,/A,c                 $   t          dddd          }t          ddd          }t          ||d	          }d
}t          |          |k    sJ t          t	          |          t	          |          d	          }t          |          |k    sJ d S )Nz2011-01-01 09:00HrI   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   )r1   r   r   r4   expdf2s         r!   #test_repr_categorical_dates_periodsz<TestDataFrameReprInfoEtc.test_repr_categorical_dates_periods:  s    *aLQQQa888bq))**( Bxx3{2[^^DDEECyyCr#   argzbox, expectedz0    NaT
dtype: objectz     0
0  NaTc                 h    t           | |d          gt                              }||k    sJ d S )Nr
   r   )r/   r-   )r1   r   boxr\   r[   s        r!   test_repr_np_nat_with_objectz5TestDataFrameReprInfoEtc.test_repr_np_nat_with_objectK  sA     cc33u::,f55566!!!!!!r#   c                 f    t          dt          ddd          i          }t          |           d S )Nyearz1/1/1700r   zA-DEC)r   r   )r   r   r/   r   s     r!   "test_frame_datetime64_pre1900_reprz;TestDataFrameReprInfoEtc.test_frame_datetime64_pre1900_reprU  s2    
:r P P PQRRRr#   c                     t          g dd          }t          t          j                            d                              d          |          }|                                 d S )N)z2011-1z2011-2z2011-3r   )r   r   )rG   r;   r<   )r   r   r   r   r   r?   r   )r1   r=   r   s      r!   %test_frame_to_string_with_periodindexz>TestDataFrameReprInfoEtc.test_frame_to_string_with_periodindexZ  sd    :::EEE")//22BB6JJRWXXX 	r#   c           	          t          dddgit          j        t          t          dgd          g                    }|                                }d}||k    sJ d S )NrP   r7   r   Int64r   r<   z      a
<NA>  1
1     2)r   r	   from_arraysr   r   r   rZ   s       r!   "test_to_string_ea_na_in_multiindexz;TestDataFrameReprInfoEtc.test_to_string_ea_na_in_multiindexa  sr    1a&M(&"a*H*H*H)IJJ
 
 

  !!!!!!r#   c                     t          dt          ddd          i          }t          |          }|j        d d d df         }t          |          }||k    sJ d S )Nr   2019r   UTC)r   r   rI   )r   r   r/   r0   r1   r4   r\   r[   s       r!   $test_datetime64tz_slice_non_truncatez=TestDataFrameReprInfoEtc.test_datetime64tz_slice_non_truncaten  sg    ZuEEEFGG88WQQQU^b!!!!!!r#   c                     t          ddgddgddggddg	          }|ddg                                         |d
<   d}t          |          }||k    sJ d S )NrP   rQ   rR   rc   efleftrightr   recordz_  left right     record
0    a     b  [0, a, b]
1    c     d  [1, c, d]
2    e     f  [2, e, f])r   
to_recordsr/   r   s       r!   $test_to_records_no_typeerror_in_reprz=TestDataFrameReprInfoEtc.test_to_records_no_typeerror_in_reprv  sv    c
S#Jc
;fgEVWWW67+,77998 b!!!!!!r#   c                     t          dt          j        gddgddggddg          }|ddg                                         |d	<   d
}t	          |          }||k    sJ d S )NrP   rR   rc   r   r   r   r   r   r   zg  left right       record
0    a   NaN  [0, a, nan]
1    c     d    [1, c, d]
2    e     f    [2, e, f]r   r   r_   r   r/   r   s       r!   $test_to_records_with_na_record_valuez=TestDataFrameReprInfoEtc.test_to_records_with_na_record_value  s    26]S#Jc
3fg=N
 
 
 67+,77998 b!!!!!!r#   c                     t          ddgt          j        t          j        gddggt          j        dg          }|t          j        dg                                         |d<   d}t	          |          }||k    sJ d S )	NrP   rQ   r   r   r   r   r   zo   NaN right         record
0    a     b      [0, a, b]
1  NaN   NaN  [1, nan, nan]
2    e     f      [2, e, f]r   r   s       r!   test_to_records_with_na_recordz7TestDataFrameReprInfoEtc.test_to_records_with_na_record  s    3Z"&"&)C:6@Q
 
 
 267+,77998 b!!!!!!r#   c                    d}d}t          j        t          |          5  t          dd          5  t	          t
          j        dgt
          j        t
          j        gddggt
          j        t
          j        g	          }|t
          j        t
          j        g                                         |d
<   t          |          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   ||k    sJ d S )Nzk   NaN  inf         record
0  NaN    b    [0, inf, b]
1  NaN  NaN  [1, nan, nan]
2    e    f      [2, e, f]"use_inf_as_na option is deprecatedr   use_inf_as_naTrQ   r   r   r   r   
r@   assert_produces_warningFutureWarningr   r   r   infr_   r   r/   r1   r\   r   r4   r[   s        r!   %test_to_records_with_inf_as_na_recordz>TestDataFrameReprInfoEtc.test_to_records_with_inf_as_na_record  sf    3'SAAA 	" 	"66 " "fc]RVRV$4sCjAVRV,    "2626"23>>@@8b" " " " " " " " " " " " " " "	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" !!!!!!5   C%BCC%C	C%C	C%%C),C)c                    d}d}t          j        t          |          5  t          dd          5  t	          t
          j        dgt
          j        t
          j        gddggt
          j        t
          j        g	          }|t
          j        t
          j        g                                         |d
<   t          |          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   ||k    sJ d S )Nzk   NaN  inf         record
0  inf    b    [0, inf, b]
1  NaN  NaN  [1, nan, nan]
2    e    f      [2, e, f]r  r   r  FrQ   r   r   r   r   r  r  s        r!   test_to_records_with_inf_recordz8TestDataFrameReprInfoEtc.test_to_records_with_inf_record  sf    3'SAAA 	" 	"77 " "fc]RVRV$4sCjAVRV,    "2626"23>>@@8b" " " " " " " " " " " " " " "	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" !!!!!!r
  c                     t          t          ddgd          t          ddgd          d          }|                    d	j        d	j        g
          }d}||k    sJ d S )Ng_c97ݚ?g6sӭ?Float64r   r7   r   r   )rP   rQ   z{:.2f})
formattersz)      a     b
0  0.12  1.00
1  1.12  2.00)r   r   r   formatrZ   s       r!   test_masked_ea_with_formatterz6TestDataFrameReprInfoEtc.test_masked_ea_with_formatter  s    [+6iHHHQF'222 
 
 (/8?)KLL !!!!!!r#   c                     t          j        d           t          g dg dd          }|j                            |          |_        d}t          |          |k    sJ d S )NpyarrowrF   rH   )long_column_namecol2zg   long_column_name  col2
0                 1     4
1                 2     5
2                 3     6)r   r   r   r   r+   r/   )r1   any_string_dtyper4   r\   s       r!   test_repr_ea_columnsz-TestDataFrameReprInfoEtc.test_repr_ea_columns  sn    I&&&IIIyyyIIJJZ&&'788
 Bxx8######r#   N)0__name__
__module____qualname__r5   rD   rV   r]   r`   rd   rq   rz   r   r   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  r   r#   r!   r   r      s         "    " " "	" 	" 	"" " "   . . .! ! !&  8 8 8 [  % % %2	8 	8 	8 [  
# # #28 8 8        + + +*) ) )*     " [UR]BN$CDD[
+	,y:J.KL " "	  ED
"
  
  " " "" " "	" 	" 	"" " "" " "" " """ " """ " "	$ 	$ 	$ 	$ 	$r#   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!   <module>r(     sL                                                    & & & & & & & & & & & &x$ x$ x$ x$ x$ x$ x$ x$ x$ x$r#   