Skip to main content
This page shows you how to create and log W&B Tables with the Python SDK so you can visualize and analyze tabular data alongside your ML experiments. A table is a two-dimensional grid of data where each column has a single type of data. Each row represents one or more data points logged to a run. Tables support primitive and numeric types, as well as nested lists, dictionaries, and rich media types. A W&B Table is a specialized W&B data type. When you log a table, W&B stores it as an artifact. You create and log tables using the W&B Python SDK. When you create a table, you specify its columns, data, and a mode. The mode determines how the table is logged and updated during your ML experiments, which affects performance, what you can change after logging, and how the table appears in W&B.

Create and log a table

Follow these steps to log a table to a run. The resulting table is stored as an artifact in W&B and rendered in your project’s workspace.
  1. Initialize a new run with wandb.init().
  2. Create a table with the wandb.Table Class. Use the columns and data parameters to define the table columns and rows. To control how the table behaves when logged, set the optional log_mode parameter to: IMMUTABLE (the default), MUTABLE, or INCREMENTAL. See Table Logging Modes in the next section for more information.
  3. Log the table to W&B with run.log().
The following example shows how to create and log a table with two columns, a and b, and two rows of data, ["a1", "b1"] and ["a2", "b2"]:

Logging modes

The wandb.Table log_mode parameter controls how a table is logged, updated, and displayed in the W&B App. Choose one of the following values based on your workflow: IMMUTABLE for a single end-of-run snapshot, MUTABLE for a table that you update after logging, or INCREMENTAL for long-running jobs that log table data in batches. The following describes the three logging modes, the high-level differences, and common use cases for each mode: The following sections show example code snippets for each mode along with considerations for when to use each mode.

MUTABLE mode

MUTABLE mode updates an existing table by replacing it with a new one. MUTABLE mode is useful when you want to add new columns and rows to an existing table in a non-iterative process. Within the UI, the table is rendered with all rows and columns, including the new ones added after the initial log.
In MUTABLE mode, the table object is replaced each time you log the table. Overwriting a table with a new one is computationally expensive and can be slow for large tables.
The following example shows how to create a table in MUTABLE mode, log it, and then add new columns to it. The table object is logged three times: once with the initial data, once with the confidence scores, and once with the final predictions.
The following example uses a placeholder function load_eval_data() to load data and a placeholder function model.predict() to make predictions. Replace these with your own data loading and prediction functions.
If you only want to add new batches of rows (no columns) incrementally like in a training loop, consider using INCREMENTAL mode instead.

INCREMENTAL mode

In INCREMENTAL mode, you log batches of rows to a table during the machine learning experiment. This is ideal for monitoring long-running jobs or when working with large tables that would be inefficient to log during the run for updates. Within the UI, the table is updated with new rows as they are logged, so you can view the latest data without waiting for the entire run to finish. You can also step through the increments to view the table at different points in time.
Run workspaces in W&B have a limit of 100 increments. If you log more than 100 increments, only the most recent 100 are shown in the run workspace.
The following example creates a table in INCREMENTAL mode, logs it, and then adds new rows to it. The table is logged once per training step (step). The example uses placeholder functions (get_training_batch(), train_model_on_batch(), and predict_on_batch()). Replace these with your own data loading, training, and prediction functions.
Incremental logging is more computationally efficient than logging a new table each time (log_mode="MUTABLE"). However, W&B may not render all rows in the table if you log a large number of increments. To update and view your table data while your run is ongoing and to have all the data available for analysis, consider using two tables: one with INCREMENTAL log mode and one with IMMUTABLE log mode. The following example shows how to combine INCREMENTAL and IMMUTABLE logging modes to achieve this.
In this example, the incr_table is logged incrementally (with log_mode="INCREMENTAL") during training. This lets you log and view updates to the table as new data is processed. At the end of training, an immutable table (final_table) is created with all data from the incremental table. The immutable table is logged to preserve the complete dataset for further analysis and to let you view all rows in W&B.

Examples

The following examples show end-to-end logging patterns for common workflows: enriching evaluation results, resuming runs that log incremental tables, and incrementally logging batches during training.

Enrich evaluation results with MUTABLE

Resume runs with INCREMENTAL tables

You can continue logging to an incremental table when resuming a run:
Increments are logged to a new table if you turn off summaries on a key used for the incremental table using wandb.Run.define_metric("<table_key>", summary="none") or wandb.Run.define_metric("*", summary="none").

Train in batches with INCREMENTAL