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

Function asciitable

dask/utils.py:1179–1197  ·  view source on GitHub ↗

Formats an ascii table for given columns and rows. Parameters ---------- columns : list The column names rows : list of tuples The rows in the table. Each tuple must be the same length as ``columns``.

(columns, rows)

Source from the content-addressed store, hash-verified

1177
1178
1179def asciitable(columns, rows):
1180 """Formats an ascii table for given columns and rows.
1181
1182 Parameters
1183 ----------
1184 columns : list
1185 The column names
1186 rows : list of tuples
1187 The rows in the table. Each tuple must be the same length as
1188 ``columns``.
1189 """
1190 rows = [tuple(str(i) for i in r) for r in rows]
1191 columns = tuple(str(i) for i in columns)
1192 widths = tuple(max(*map(len, x), len(c)) for x, c in zip(zip(*rows), columns))
1193 row_template = ("|" + (" %%-%ds |" * len(columns))) % widths
1194 header = row_template % tuple(columns)
1195 bar = "+%s+" % "+".join("-" * (w + 2) for w in widths)
1196 data = "\n".join(row_template % r for r in rows)
1197 return "\n".join([bar, header, bar, data, bar])
1198
1199
1200def put_lines(buf, lines):

Callers 4

warn_dtype_mismatchFunction · 0.90
check_metaFunction · 0.90
coerce_dtypesFunction · 0.90
test_asciitableFunction · 0.90

Calls 2

maxFunction · 0.85
joinMethod · 0.45

Tested by 1

test_asciitableFunction · 0.72