The home page for ipy_table is at epmoyer.github.com/ipy_table/
ipy_table is maintained at github.com/epmoyer/ipy_table
To create a table call make_table on an array (a list of equal sized lists) or a numpy.ndarray.
make_table() creates a table in interactive mode. Subsequent calls to modify styles (e.g. apply_theme(), set_cell_style(), etc.) will re-render the table with the new style modifications.
from ipy_table import *
example_table = [[i for i in range(j,j+4)] for j in range(0,30,10)]
make_table(example_table)
ipy_table implements three pre-defined table styles (basic, basic_left, and basic_both) which provide bold gray headers and alternating colored rows for three different header configurations.
make_table(example_table)
apply_theme('basic')
make_table(example_table)
apply_theme('basic_left')
import copy
example_table2 = copy.deepcopy(example_table) # Copy the example table
example_table2[0][0] = '' # Clear the contents of the upper left corner cell
make_table(example_table2)
apply_theme('basic_both')
Sets the style of a single cell. For a list of the available style options, see Syle Options below.
make_table(example_table)
set_cell_style(1, 2, color='red')
Sets the style for a row of cells. For a list of the available style options, see Syle Options below.
make_table(example_table)
set_row_style(0, color='lightGreen')
Sets the style for a column of cells. For a list of the available style options, see Syle Options below.
make_table(example_table)
set_column_style(1, color='lightBlue')
Sets the style for all cells. For a list of the available style options, see Syle Options below.
make_table(example_table)
set_global_style(color='Pink')
make_table(example_table)
set_row_style(1, bold=True)
make_table(example_table)
set_row_style(1, italic=True)
Sets background cell color by name. The color name can be any any standard web/X11 color name. For a list see http://en.wikipedia.org/wiki/Web_colors
make_table(example_table)
set_row_style(1, color='Orange')
Accepts a comma delimited list of cell edges, which may be any of: left, top, right, bottom. You can also speify 'all' to include all edges.
make_table(example_table)
set_cell_style(0,0, thick_border='left,top')
set_cell_style(2,3, thick_border='right,bottom')
make_table(example_table)
set_row_style(1, thick_border='all')
Accepts a comma delimited list of cell edges, which may be any of: left, top, right, bottom. You can also speify 'all' to include all edges.
make_table(example_table)
set_cell_style(0,0, no_border='left,top')
set_cell_style(2,3, no_border='right,bottom')
make_table(example_table)
set_row_style(1, no_border='all')
make_table(example_table)
set_cell_style(0, 0, row_span=3)
make_table(example_table)
set_cell_style(1,1, column_span=3)
Sets the cell width in pixels.
make_table(example_table)
set_cell_style(0,0, width=100)
Sets the cell alignment. Accpets any of: left, right, center.
make_table(example_table)
set_cell_style(0, 0, width='100')
set_cell_style(0, 0, align='right')
set_cell_style(1, 0, align='center')
Turns text wrapping on or off. By default wraping is off.
example_table2 = copy.deepcopy(example_table)
example_table2[0][0] = 'This cell has wrap set'
example_table2[0][1] = 'This cell does not have wrap set'
make_table(example_table2)
set_cell_style(0, 0, width=50,wrap=True)
set_cell_style(0, 1, width=50)
Sets the display format for floating point values.
The float format string is a standard Python "%" format string (and should contain one and only one %f reference). See http://docs.python.org/2/library/stdtypes.html#string-formatting-operations
The float format only affects cells that contain float or numpy.float64 data types, so you can use set_global_style to set a global floating point format and only those cells containing floating point data will be affected.
The default float format is '%0.4f'.
from ipy_table import *
example_table2 = [[i + float(i)/100.0 + i/10000.0 for i in range(j,j+4)] for j in range(0,30,10)]
make_table(example_table2)
set_cell_style(0, 0, float_format='%0.1f')
set_cell_style(1, 0, float_format='%0.6f')
set_cell_style(2, 0, float_format='$%0.2f')
t = IpyTable(example_table)
t.set_cell_style(1, 1, color='DarkCyan')
t
make_table(example_table, interactive=False)
set_row_style(1,color='yellow')
render()
The HTML text representation of the current table can be obtained by calling render()._repr_html_()
render()._repr_html_()
Use tabulate(list, n) to display a list (not an array) of data in a table with n columns.
tabulate(range(20), 6)
tabulate() creates a table object just like make_table(), so the same style operations can be applied.
set_cell_style(1, 2, color='yellow')
import ipy_table as ipt
ipt.__version__