Skip to main content

Export table data

Like all W&B Artifacts, Tables can be converted into pandas dataframes for easy data exporting.

Convert table to artifactโ€‹

First, you'll need to convert the table to an artifact. The easiest way to do this using artifact.get(table, "table_name"):

# 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 artifact to Dataframeโ€‹

Then, convert the table into a dataframe:

# Following from the last code example:
df = table.get_dataframe()

Export Dataโ€‹

Now you can export using any method dataframe supports:

# Converting the table data to .csv
df.to_csv("example.csv", encoding="utf-8")

Next Steps

Was this page helpful?๐Ÿ‘๐Ÿ‘Ž