Skip to main content

class wandb.Table

The Table class used to display and analyze tabular data. Unlike traditional spreadsheets, Tables support numerous types of data: scalar values, strings, numpy arrays, and most subclasses of wandb.data_types.Media. This means you can embed Images, Video, Audio, and other sorts of rich, annotated media directly in Tables, alongside other traditional scalar values. This class is the primary class used to generate W&B Tables https://docs.wandb.ai/models/tables

Args

  • columns: Names of the columns in the table. Defaults to [“Input”, “Output”, “Expected”].
  • data: 2D row-oriented array of values, NumPy array, or pandas DataFrame.
  • rows: 2D row-oriented array of values.
  • dataframe: pandas DataFrame object used to create the table. When set, data and columns arguments are ignored.
  • dtype: The expected type for the column values, used to validate the data. If not set, types are inferred from the data. It can be:
    • a single type
      • a Python built-in type such as int, str, bool, list, dict, or datetime.
      • a W&B Media type like wandb.Image declared under wandb.data_types
      • a const value
    • a list of any of the above to assign a different type to each column (should be the same length as columns)
  • optional: Determines if None values are allowed. Defaults to True.
    • If a singular bool value, then the optionality is enforced for all columns specified at construction time
    • If a list of bool values, then the optionality is applied to each column - should be the same length as columns applies to all columns. A list of bool values applies to each respective column.
  • allow_mixed_types: Determines if columns are allowed to have mixed types (disables type validation). Defaults to False
  • log_mode: Controls how the Table is logged when mutations occur. Options:
    • “IMMUTABLE” (default): Table can only be logged once; subsequent logging attempts after the table has been mutated will be no-ops.
    • “MUTABLE”: Table can be re-logged after mutations, creating a new artifact version each time it’s logged.
    • “INCREMENTAL”: Table data is logged incrementally, with each log creating a new artifact entry containing the new data since the last log.

Methods

method Table.add_column()

Adds a column of data to the table.
Arguments
  • name: The unique name of the column.
  • data: A column of homogeneous data.
  • optional: If null-like values are permitted.

method Table.add_computed_columns()

Adds one or more computed columns based on existing data.
Arguments
  • fn: A function which accepts an index and row dict, and returns a dict representing new columns for that row, keyed by the new column names.
Examples
In the callback:
  • ndx is an integer representing the index of the row.
  • row is a dictionary keyed by existing columns.

method Table.add_data()

Adds a new row of data to the table. The maximum amount ofrows in a table is determined by wandb.Table.MAX_ARTIFACT_ROWS. The length of the data should match the length of the table column.
Arguments
  • data:

method Table.add_row()

Deprecated. Use Table.add_data method instead.
Arguments
  • row:

method Table.cast()

Casts a column to a specific data type. This can be one of the normal python classes, an internal W&B type, or an example object, like an instance of wandb.Image or wandb.Classes.
Arguments
  • col_name: The name of the column to cast.
  • dtype: The target dtype.
  • optional: If the column should allow Nones.

method Table.get_column()

Retrieves a column from the table and optionally converts it to a NumPy object.
Arguments
  • name: The name of the column.
  • convert_to: “numpy” will convert the underlying data to a NumPy object.

method Table.get_dataframe()

Returns a pandas.DataFrame of the table.

method Table.get_index()

Returns an array of row indexes for use in other tables to create links.