Skip to content
Snippets Groups Projects
Commit faffd8c8 authored by Bert Palm's avatar Bert Palm 🎇
Browse files

minor improves

parent 13614dbc
No related branches found
No related tags found
No related merge requests found
......@@ -354,7 +354,7 @@ class DictOfSeries:
locations, just like `series.loc[:]=val` or `df[:]=val` do.
Eg.
di1[::2] = di[::3] -> di[::2]
di[::2] = di[::3] -> di[::2]
x | x | x |
===== | ==== | ====== |
......@@ -767,7 +767,7 @@ def pprint_dios(dios,
# now data only contains series that we want to print.
# if any series exceed max_rows we trim all series to min_rows
series_lengths = data.apply(len)
series_lengths = data.apply(len).to_list()
series_maxlen = max(series_lengths)
trunc_rows = series_maxlen > max_rows
max_rows = min_rows if trunc_rows else series_maxlen
......@@ -812,7 +812,7 @@ def pprint_dios(dios,
# columns.
valstr_len = [len(c[0]) for c in outer]
rows = max_rows + 1 # colname
rows = max_rows + 1 # colnames aka. header
rows += 1 if trunc_rows else 0 # `...` in rows
rows += 1 if header_delim else 0 # underline header
......@@ -821,10 +821,11 @@ def pprint_dios(dios,
colheader = (header_delim * valstr_len[i])[:valstr_len[i]]
c.insert(1, colheader)
delim = ' ... '
dots = ' ... '
if trunc_cols:
outer.insert(max_cols // 2, [delim] * rows)
valstr_len.insert(max_cols // 2, len(delim))
outer.insert(max_cols // 2, [dots] * rows)
valstr_len.insert(max_cols // 2, len(dots))
series_lengths.insert(max_cols//2, rows)
txt = ""
for r in range(rows):
......@@ -838,17 +839,12 @@ def pprint_dios(dios,
# add footer
if show_dimensions:
# correction because the collections `series_lengths`
# and `valstr_len` differ by 1 in length. very hacky!
# todo: use a dict/df or dios(?!) to store the str-data
corr = 0
for i, c in enumerate(outer):
# ignore the dot-column
if trunc_cols and i == max_cols//2:
txt += delim + ' ' * len(col_delim)
corr = 1
txt += dots + ' ' * len(col_delim)
else:
txt += f"[{series_lengths.iat[i-corr]}]".ljust(valstr_len[i] + len(col_delim))
txt += f"[{series_lengths[i]}]".ljust(valstr_len[i] + len(col_delim))
txt += f'\n\nmax: [{maxlen} rows x {len(dios.columns)} columns]'
txt += '\n'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment