In [1]:
from ipytables import Table, TableRow, TableCell, TableHeaderRow
In [2]:
# The simple case is easy
Table((4, 1, 8),
      (9, 7, 3),
      (5, 2, 6))
Out[2]:
418
973
526
In [3]:
# With a header
Table(TableHeaderRow('a','b','c'),
      (1,  2,  3),
      (2,  4,  6),
     )
Out[3]:
abc
123
246
In [4]:
# Computing values
t = Table(TableHeaderRow('number', 'square', 'cube'))
for x in range(1, 11):
    t.append_row((x, x**2, x**3))
t
Out[4]:
numbersquarecube
111
248
3927
41664
525125
636216
749343
864512
981729
101001000
In [5]:
# Styling determined by code
t = Table(TableHeaderRow('divisions', 'result'))
num = 55
for x in range(7):
    if num < 1:
        resultcell = TableCell(num, bg_colour='DarkBlue', text_colour='white')
    else:
        resultcell = TableCell(num)
    t.append_row((x, resultcell))
    num /= 3
t
Out[5]:
divisionsresult
055
118.333333333333332
26.111111111111111
32.0370370370370368
40.6790123456790123
50.22633744855967075
60.07544581618655692
In [ ]: