Skip to main content
`Ctrl`+`K`

# cogent3.core.table.Table

class Table(header: list[str] | None = None, data: Sequence[Sequence[Any]] | Mapping[Any, Sequence[Any]] | None = None, index_name: str | None = None, title: str = '', legend: str = '', digits: int = 4, space: int = 4, max_width: int = 10000000000000000159028911097599180468360808563945281389781327557747838772170381060813469985856815104, column_templates: dict[str, str] | dict[str, Callable[[Any], str]] | None = None, format_name: str = 'simple', missing_data: str = '', **kwargs)

  Tabular data. iter operates over rows. Columns are available as an attribute.

  Attributes:
    array
    `format`

      the str display format

    header
    `index_name`

      column name whose values can be used to index table rows

    legend
    shape
    space
    title

  Methods

  `appended`(new_column, *tables, **kwargs) | Concatenates an arbitrary number of tables together
  `count`(callback[, columns]) | Returns number of rows for which the provided callback function returns True when passed row data from columns.
  `count_unique`([columns]) | count occurrences of unique combinations of columns
  `cross_join`(other[, col_prefix]) | cross join, or full outer join, of self with other
  `distinct_values`(columns) | returns the set of distinct values for the named column(s)
  `filtered`(callback[, columns]) | Returns a table with rows satisfying the provided callback function.
  `filtered_by_column`(callback, **kwargs) | Returns a table with columns identified by callback
  `format_column`(column_head, format_template) | Provide a formatting template for a named column.
  `get_columns`(columns[, with_index]) | select columns from self with index_name unless excluded
  `get_row_indices`(callback, columns[, negate]) | returns boolean array of callback values given columns
  `group_by`(columns) | Group table rows by one or more columns.
  `head`([nrows]) | displays top nrows
  `inner_join`(other[, columns_self, ...]) | inner join of self with other
  `joined`(other[, columns_self, columns_other, ...]) | returns a new table containing the join of this table and other.
  `normalized`([by_row, denominator_func]) | returns a table with elements expressed as a fraction according to the results from func
  `set_repr_policy`([head, tail, random, show_shape]) | specify policy for repr(self)
  `sorted`([columns, reverse]) | Returns a new table sorted according to columns order.
  `sum_columns`([columns, strict]) | return sum of indicated columns
  `sum_rows`([indices, strict]) | return sum of indicated rows
  `summed`([indices, col_sum, strict]) | returns the sum of numerical values for column(s)/row(s)
  `tail`([nrows]) | displays bottom nrows
  `to_categorical`([columns, index_name]) | construct object that can be used for statistical tests
  `to_csv`([with_title, with_legend]) | return table formatted as comma separated values
  `to_dict`([flatten]) | returns data as a dict
  `to_html`([column_alignment]) | construct html table
  `to_latex`([concat_title_legend, justify, ...]) | Returns the text a LaTeX table.
  `to_list`([columns]) | Returns raw data as a list
  `to_markdown`([space, justify]) | returns markdown formatted table
  `to_pandas`([categories]) | returns pandas DataFrame instance
  `to_plotly`([width, font_size, layout]) | returns a Plotly Table
  `to_rst`([csv_table]) | returns rst formatted table
  `to_string`([format_name, borders, sep, ...]) | Return the table as a formatted string.
  `to_tsv`([with_title, with_legend]) | return table formatted as tab separated values
  `transposed`(new_column_name[, select_as_header]) | returns the transposed table.
  `with_new_column`(new_column, callback[, ...]) | Returns new table with an additional column, computed using callback.
  `with_new_header`(old, new, **kwargs) | returns a new Table with old header labels replaced by new
  `write`(filename[, mode, writer, format_name, ...]) | Write table to filename in the specified format.

  to_json |
  to_rich_dict |