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

Function test_to_string

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

Source from the content-addressed store, hash-verified

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