MCPcopy Create free account
hub / github.com/dask/dask / test_to_string

Function test_to_string

dask/dataframe/dask_expr/tests/test_format.py:17–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15
16
17def test_to_string():
18 pytest.importorskip("jinja2")
19 dtype = "string" if pyarrow_strings_enabled() else "object"
20 df = pd.DataFrame(
21 {
22 "A": [1, 2, 3, 4, 5, 6, 7, 8],
23 "B": list("ABCDEFGH"),
24 "C": pd.Categorical(list("AAABBBCC")),
25 }
26 )
27 ddf = from_pandas(df, 3)
28
29 exp = dedent(
30 f"""\
31 A B C
32 npartitions=3
33 0 int64 {dtype} category[known]
34 3 ... ... ...
35 6 ... ... ...
36 7 ... ... ..."""
37 )
38 assert ddf.to_string() == exp
39
40 exp_table = f"""<table border="1" class="dataframe">
41 <thead>
42 <tr style="text-align: right;">
43 <th></th>
44 <th>A</th>
45 <th>B</th>
46 <th>C</th>
47 </tr>
48 <tr>
49 <th>npartitions=3</th>
50 <th></th>
51 <th></th>
52 <th></th>
53 </tr>
54 </thead>
55 <tbody>
56 <tr>
57 <th>0</th>
58 <td>int64</td>
59 <td>{dtype}</td>
60 <td>category[known]</td>
61 </tr>
62 <tr>
63 <th>3</th>
64 <td>...</td>
65 <td>...</td>
66 <td>...</td>
67 </tr>
68 <tr>
69 <th>6</th>
70 <td>...</td>
71 <td>...</td>
72 <td>...</td>
73 </tr>
74 <tr>

Callers

nothing calls this directly

Calls 5

pyarrow_strings_enabledFunction · 0.90
from_pandasFunction · 0.90
maybe_pluralizeFunction · 0.90
to_htmlMethod · 0.80
to_stringMethod · 0.45

Tested by

no test coverage detected