cogent3.util.table.Table#
- class Table(header=None, data=None, index_name=None, title='', legend='', digits=4, space=4, max_width=1e+100, column_templates=None, format='simple', missing_data='', **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
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_dataframe
(**kwargs)deprecated, use to_pandas()
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, borders, sep, center, ...])Return the table as a formatted string.
to_tsv
([with_title, with_legend])return table formatted as tab separated values
tolist
(**kwargs)deprecated, use to_list
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, sep, ...])Write table to filename in the specified format.
to_json
to_rich_dict