MCPcopy
hub / github.com/dask/dask / test_to_string

Function test_to_string

dask/dataframe/dask_expr/tests/test_format.py:16–83  ·  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(f"""\
29 A B C
30 npartitions=3
31 0 int64 {dtype} category[known]
32 3 ... ... ...
33 6 ... ... ...
34 7 ... ... ...""")
35 assert ddf.to_string() == exp
36
37 exp_table = f"""<table border="1" class="dataframe">
38 <thead>
39 <tr style="text-align: right;">
40 <th></th>
41 <th>A</th>
42 <th>B</th>
43 <th>C</th>
44 </tr>
45 <tr>
46 <th>npartitions=3</th>
47 <th></th>
48 <th></th>
49 <th></th>
50 </tr>
51 </thead>
52 <tbody>
53 <tr>
54 <th>0</th>
55 <td>int64</td>
56 <td>{dtype}</td>
57 <td>category[known]</td>
58 </tr>
59 <tr>
60 <th>3</th>
61 <td>...</td>
62 <td>...</td>
63 <td>...</td>
64 </tr>
65 <tr>
66 <th>6</th>
67 <td>...</td>
68 <td>...</td>
69 <td>...</td>
70 </tr>
71 <tr>
72 <th>7</th>
73 <td>...</td>

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…