Update table.

This commit is contained in:
Mikaël Capelle 2017-07-20 11:15:48 +02:00
parent 8aa3d06b19
commit 82418bd6c3

View File

@ -62,16 +62,14 @@ class tabledf(table):
super().__init__(**kargs) super().__init__(**kargs)
if header is None: if header is None:
multilevels, header = self.create_header(df) multilevels, header = self.create_header(df)
df = df.reset_index()
if multilevels: if multilevels:
ncols = len(header[-1]) ncols = len(header[-1])
df = df.reset_index()
else: else:
ncols = len(header) ncols = len(header)
header = [header]
tab = tabular(columns='r' * ncols) tab = tabular(columns='r' * ncols)
if multilevels: tab.addrows(header)
tab.addrows(header)
else:
tab.addrow(header)
tab.addhline() tab.addhline()
tab.addrows(df.astype(object).values, fmt=fmt) tab.addrows(df.astype(object).values, fmt=fmt)
self.add(tab) self.add(tab)