1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
U
­ý°d•'ã @sddlmZddlmZddlmZddlZddlZddlm    m
Z ddl m Z mZmZmZdd„Zdd    „Zd
d „Zej d d ddgdfddgdfdddgdfdddgdfddgdfddgdfg    ¡d d!„ƒZej d d"dgid#fddgd$d%gd&œd'fddgd(dgd&œd)fg¡d*d+„ƒZej d,d-d.d/d0d1g¡d2d3„ƒZd4d5„Zd6d7„Zd8d9„Zd:d;„Zd<d=„Zd>d?„Zd@dA„ZdBdC„Z dDdE„Z!dFdG„Z"dHdI„Z#ej dJdKdLg¡dMdN„ƒZ$ej dOddPgdQdRgdSœdTfdUdVgej%dWgdSœdXfej%dgdYdZgdUd[gd\œd]fg¡d^d_„ƒZ&e  'd`¡dadb„ƒZ(dS)cé)Údatetime)ÚStringIO)ÚdedentN)Ú    DataFrameÚSeriesÚoption_contextÚ to_datetimecCsbtjddtfgd}tt|ƒƒD]}tj |¡|d|<q t|ƒ}t|dƒt|ƒ|     ¡dS)Né
Úerr©Údtype)
ÚnpÚemptyÚobjectÚrangeÚlenÚrandomZrandnrÚreprÚ    to_string)ZarrÚiÚdf©rú]d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/io/formats/test_to_string.pyÚtest_repr_embedded_ndarrays rcCs>tƒ}tdtttdƒtdƒƒƒiƒ}t|ƒ|jd|ddS)NZtupsr    )Z    col_spaceÚbuf)rrÚlistÚziprrr)rrrrrÚtest_repr_tuplessrc    Cs~tdddddœdddddœgƒ}| ddd    g¡| ¡d
ks@t‚td d ƒ| ¡d
ks\t‚W5QRX|jd d dkszt‚dS)NÚfooÚbarzXlet's make this a very VERY long line that is longer than the default 50 character limité)ÚaÚbÚcÚdÚstuffr!r"r#a:     a    b                                                                                         c  d
0  foo  bar  let's make this a very VERY long line that is longer than the default 50 character limit  1
1  foo  bar                                                                                     stuff  1Ú max_colwidthé)r&zk     a    b                    c  d
0  foo  bar  let's make this ...  1
1  foo  bar                stuff  1)rZ    set_indexrÚAssertionErrorr)rrrrÚtest_to_string_truncate%s(û øÿ ÿ ÿ
ÿr)zinput_array, expected)r!r!r!r"za
br z1
a)r Ú1éÿÿÿÿz 0
-1)çð?z1.0z az bz a
 bz.1r*z.1
 1Ú10z-10z 10
-10cCs t|ƒjdd}||kst‚dS©NF)Úindex)rrr()Ú input_arrayÚexpectedÚsrrrÚ'test_format_remove_leading_space_seriesMsr3ÚAzA
ar#Údd)r4ÚBzA  B
a  c
b ddZaazA  B
a aa
1  1cCs t|ƒjdd}||kst‚dSr.©rrr()r0r1rrrrÚ*test_format_remove_leading_space_dataframeas
r8zmax_cols, max_rows, expected)r    Nzà 0   1   2   3   4   ...  6   7   8   9   10
  0   0   0   0   0  ...   0   0   0   0   0
  0   0   0   0   0  ...   0   0   0   0   0
  0   0   0   0   0  ...   0   0   0   0   0
  0   0   0   0   0  ...   0   0   0   0   0)Néz¯ 0   1   2   3   4   5   6   7   8   9   10
  0   0   0   0   0   0   0   0   0   0   0
 ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..
  0   0   0   0   0   0   0   0   0   0   0)r    r9z³ 0   1   2   3   4   ...  6   7   8   9   10
  0   0   0   0   0  ...   0   0   0   0   0
 ..  ..  ..  ..  ..  ...  ..  ..  ..  ..  ..
  0   0   0   0   0  ...   0   0   0   0   0)é    r9z“ 0   1   2   3   ...  7   8   9   10
  0   0   0   0  ...   0   0   0   0
 ..  ..  ..  ..  ...  ..  ..  ..  ..
  0   0   0   0  ...   0   0   0   0)r r z 0  ...
 0  ...
..  ...cCs0tdgdgdƒ}|jd||d|ks,t‚dS)Nré éF)r/Úmax_colsÚmax_rowsr7)r=r>r1rrrrÚtest_truncation_no_indexos,r?cCs`tdt d¡iƒ}tƒ}|j|d| ¡tƒ}|j|d| ¡| ¡}t|tƒs\t    ‚dS)Nuσg$@)r)
rr ZarangerrÚgetvalueÚinfoÚ
isinstanceÚstrr()Z float_framerrÚresultrrrÚtest_to_string_unicode_columnsŸs  rEc    Cs<d ¡}tddƒ tddg|gd}t|ƒW5QRXdS)Nuאzdisplay.max_rowsr r9©Úcolumns)Úencoderrr)ÚnrrrrÚtest_to_string_utf8_columns®s rJcCs tdgiƒ}tƒ}| |¡dS)Nõc/σ©rrr©ÚdmrrrrÚtest_to_string_unicode_two¶s rOcCstdgƒ}tƒ}| |¡dS)NõÂrLrMrrrÚtest_to_string_unicode_three¼s
rQcCs’tdddgdddgddd    gd
œd d d gd}d dd„fd dd„fd dd„fg}|jt|ƒd}|jtt|Žƒdd}|dks‚t‚||ksŽt‚dS)Nr r9ér,g@g@)r r9TF)ÚintÚfloatrrSrTrrFcSs d|d›S)NÚ0xÚxr©rVrrrÚ<lambda>Íóz0test_to_string_with_formatters.<locals>.<lambda>cSsd|d›dS)Nú[z 4.1fú]rrWrrrrXÎrYcSs d|›dS)Nú-rrWrrrrXÏrY©Ú
formattersz[  int  float    object
0 0x1 [ 1.0]  -(1, 2)-
1 0x2 [ 2.0]    -True-
2 0x3 [ 3.0]   -False-)rrÚdictrrr()rr^rDZresult2rrrÚtest_to_string_with_formattersÂs"ýú
 
 
 
ýÿr`cCsXtdddƒtdddƒg}td|iƒ}dd„}|jd|id}tdƒ}| ¡|ksTt‚dS)    Niàr r9ÚmonthscSs
| d¡S)Nz%Y-%m©ÚstrftimerWrrrÚ format_funcàszBtest_to_string_with_datetime64_monthformatter.<locals>.format_funcr]z2        months
        0 2016-01
        1 2016-02)rrrrÚstripr()rarVrdrDr1rrrÚ-test_to_string_with_datetime64_monthformatterÜs ÿrfcCsLtdtddgddiƒ}dd„}|jd|id}td    ƒ}| ¡|ksHt‚dS)
NZhodz 10:10:10.100z 12:12:12.120z %H:%M:%S.%f)ÚformatcSs
| d¡S)Nz%H:%MrbrWrrrrdòszAtest_to_string_with_datetime64_hourformatter.<locals>.format_funcr]z+        hod
        0 10:10
        1 12:12)rrrrrer()rVrdrDr1rrrÚ,test_to_string_with_datetime64_hourformatterísÿÿrhcCs:tddddgiƒ}|jdtid}tdƒ}||ks6t‚dS)NrKr r9rRr]u8          c/σ
        0   1
        1   2
        2   3)rrrCrr(©rrDr1rrrÚ&test_to_string_with_formatters_unicodeÿs ÿrjcCs.tdddgƒ}| ¡}tdƒ}||ks*t‚dS)Nyð?ð?yÍÌÌÌÌÌð?ð?zG        0    1.00+1.00j
        1    1.00+1.00j
        2    1.05+1.00j©rrrr()r2rDr1rrrÚ)test_to_string_complex_number_trims_zeros s ÿrlcCs6|}tdddg|d}| ¡}tdƒ}||ks2t‚dS)Ngr,r z5        0     0.0
        1     1.0
        2    <NA>rk)Zfloat_ea_dtyper r2rDr1rrrÚtest_nullable_float_to_stringsÿrmcCs6|}tdddg|d}| ¡}tdƒ}||ks2t‚dS)Nrr r z5        0       0
        1       1
        2    <NA>rk)Zany_int_ea_dtyper r2rDr1rrrÚtest_nullable_int_to_string&sÿrnÚna_repÚNaNZTedcCsJtddgddggddgd}|j|djd}td|›ƒ}||ksFt‚dS)    Nr4gÂõ(\ó?ÚGroupÚDatarFz{:.2f})roZ float_formatzA           Group  Data
         0     A  1.22
         1     A   )rrrgrr()rorrDr1rrrÚ&test_to_string_na_rep_and_float_format4sýÿrsz data,expectedr9rRr<)Úcol1Úcol2z)   col1  col2
0     1     3
1     2     4ZAbcgþÔxé&1è?g•C‹,@z2    col1    col2
0    Abc     NaN
1  0.756  4.5435g;ßO—n‚?gòÒMbX @é)rtruZcol3z8  col1   col2 col3
0  NaN  0.009  Abc
1    a  3.543   23cCs"t|djdd}||kst‚dS)N)Údatar)r>r7)rwr1rDrrrÚtest_to_string_max_rows_zeroBsrxZpyarrowcCsVtdddgdddgddd    gd
œƒ}| d d d d
œ¡}|j ¡}tdƒ}||ksRt‚dS)NrrZbazr!r"r#r r9rR)rVÚyÚzzstring[pyarrow]zstring[python]zint64[pyarrow]zV        x    string[pyarrow]
        y     string[python]
        z     int64[pyarrow])rZastypeZdtypesrrr(rirrrÚtest_to_string_string_dtypeYs"
ÿ
ÿr{))rÚiorÚtextwraprÚnumpyr ZpytestZpandas.util._test_decoratorsÚutilZ_test_decoratorsÚtdZpandasrrrrrrr)ÚmarkZ parametrizer3r8r?rErJrOrQr`rfrhrjrlrmrnrsÚnanrxZ
skip_if_nor{rrrrÚ<module>sŒ    (
 
 
 
 
 
÷þ
 ýþ
    Þþ+
 
þþþ÷þ