> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-new-articles-log.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Table

export const GitHubLink = ({url}) => <a href={url} target="_blank" rel="noopener noreferrer" className="github-source-link">
    <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
      <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
    </svg>
    GitHub source
  </a>;

<GitHubLink url="https://github.com/wandb/wandb/blob/main/wandb/sdk/data_types/table.py#L211" />

## <kbd>class</kbd> wandb.Table

```python theme={null}
columns: 'list[ColumnKey] | None' = None,
data: 'list[InputRow] | np.ndarray | pd.DataFrame | None' = None,
rows: 'list[InputRow] | None' = None,
dataframe: 'pd.DataFrame | None' = None,
dtype: 'Any' = None,
optional: 'bool | list[bool]' = True,
allow_mixed_types: 'bool' = False,
log_mode: 'LogMode | None' = 'IMMUTABLE'
```

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](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

### <kbd>method</kbd> Table.add\_column()

```python theme={null}
self,
name: 'str',
data: 'list[Any] | np.ndarray',
optional: 'bool' = False
```

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.

### <kbd>method</kbd> Table.add\_computed\_columns()

```python theme={null}
self,
fn: 'Callable[[int, dict[ColumnKey, Any]], dict[str, Any]]'
```

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.

```python theme={null}
import wandb

table = wandb.Table(columns=["x", "y"], data=[[3, 1], [4, 6]])
table.add_computed_columns(lambda ndx, row: {"diff": row["x"] - row["y"]})
```

### <kbd>method</kbd> Table.add\_data()

```python theme={null}
self, *data: 'Any'
```

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`:

### <kbd>method</kbd> Table.add\_row()

```python theme={null}
self, *row: 'Any'
```

Deprecated. Use `Table.add_data` method instead.

##### Arguments

* `row`:

### <kbd>method</kbd> Table.cast()

```python theme={null}
self,
col_name: 'ColumnKey',
dtype: 'Any',
optional: 'bool' = False
```

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.

### <kbd>method</kbd> Table.get\_column()

```python theme={null}
self,
name: 'ColumnKey',
convert_to: "Literal['numpy'] | None" = None
```

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.

### <kbd>method</kbd> Table.get\_dataframe()

```python theme={null}
self
```

Returns a `pandas.DataFrame` of the table.

### <kbd>method</kbd> Table.get\_index()

```python theme={null}
(self)
```

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