MCPcopy Index your code
hub / github.com/dask/dask / asciitable

Function asciitable

dask/utils.py:1176–1194  ·  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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…