Skip to main content
Like all W&B artifacts, you can convert Tables into pandas DataFrames for data export. This page shows you how to export the data in a W&B Table to a pandas DataFrame and then to a CSV file, so that you can analyze or process the data outside of W&B.

Convert a table to an artifact

First, add the table to an artifact and log it, then retrieve the table as a Table object you can manipulate. Use artifact.add(table, "my_table") to add the table to the artifact and artifact.get("my_table") to retrieve it later:
# Create and log a new table.
with wandb.init() as r:
    artifact = wandb.Artifact("my_dataset", type="dataset")
    table = wandb.Table(
        columns=["a", "b", "c"], data=[(i, i * 2, 2**i) for i in range(10)]
    )
    artifact.add(table, "my_table")
    wandb.log_artifact(artifact)

# Retrieve the created table using the artifact you created.
with wandb.init() as r:
    artifact = r.use_artifact("my_dataset:latest")
    table = artifact.get("my_table")

Convert the artifact to a DataFrame

With the table retrieved from the artifact, convert it into a pandas DataFrame so that you can use DataFrame operations:
# Following from the last code example:
df = table.get_dataframe()

Export data

With your data in a DataFrame, you can export it using any method that pandas supports. For example, the following exports the data to a CSV file:
# Convert the table data to .csv
df.to_csv("example.csv", encoding="utf-8")

Next steps

For more information, see the following resources: