Skip to content

Commit 94aaa20

Browse files
committed
Work around pandas formatting bug.
With index=False the column labels are not correctly aligned with the data, as leading spaces are stripped. Remove the index from the formatted table ourself. See pandas-dev/pandas#13032
1 parent 2db8b6d commit 94aaa20

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/dmqmc/analyse_canonical.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ def main(args):
8585
# python 2.6..
8686
float_fmt = '{0:-.8e}'.format
8787

88-
print(results.to_string(index=False, float_format=float_fmt))
89-
88+
# Work around bug in to_string alignment with index=False
89+
lines = results.to_string(float_format=float_fmt).split('\n')
90+
index_wdith = max([len(str(s)) for s in results.index]) + 1
91+
print('\n'.join(l[index_wdith:] for l in lines))
9092

9193
if __name__ == '__main__':
9294

0 commit comments

Comments
 (0)