rstutils

ReStructured Text utilities

  • Make ReST table given array of values

rst_table(cell_values[, row_names, ...])

Return string for ReST table with entries cell_values

rst_table

nibabel.rstutils.rst_table(cell_values, row_names=None, col_names=None, title='', val_fmt='{0:5.2f}', format_chars=None)

Return string for ReST table with entries cell_values

Parameters:
cell_values(R, C) array-like

At least 2D. Can be greater than 2D, in which case you should adapt the val_fmt to deal with the multiple entries that will go in each cell

row_namesNone or (R,) length sequence, optional

Row names. If None, use row[0] etc.

col_namesNone or (C,) length sequence, optional

Column names. If None, use col[0] etc.

titlestr, optional

Title for table. Add as heading above table

val_fmtstr, optional

Format string using string format method mini-language. Converts the result of cell_values[r, c] to a string to make the cell contents. Default assumes a floating point value in a 2D cell_values.

format_charsNone or dict, optional

With keys ‘down’, ‘along’, ‘thick_long’, ‘cross’ and ‘title_heading’. Values are characters for: lines going down; lines going along; thick lines along; two lines crossing; and the title overline / underline. All missing values filled with rst defaults.

Returns:
table_strstr

Multiline string with ascii table, suitable for printing