datascience.tables.Table.with_column

Table.with_column(label, values)[source]

Return a table with an additional or replaced column.

Args:
label (str): The column label. If an existing label is used,
that column will be replaced in the returned table.
values (single value or sequence): If a single value, every

value in the new column is values.

If a sequence, the new column contains the values in values. values must be the same length as the table.

Raises:
ValueError: If
  • label is not a valid column name
  • values is a list/array and does not have the same length as the number of rows in the table.
>>> tiles = Table().with_columns([
...     'letter', ['c', 'd'],
...     'count',  [2, 4],
... ])
>>> tiles.with_column('points', [3, 2])
letter | count | points
c      | 2     | 3
d      | 4     | 2
>>> tiles.with_column('count', 1)
letter | count
c      | 1
d      | 1