Export table data

テーブルからデータをエクスポートする方法。

すべての W&B Artifacts と同様に、Tables は pandas のデータフレームに変換して、簡単にデータのエクスポートができます。

tableartifact に変換する

まず、テーブルを artifact に変換する必要があります。これを行うには、artifact.get(table, "table_name") を使用するのが最も簡単です。

# 新しいテーブルを作成してログに記録します。
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)

# 作成した artifact を使用して、作成したテーブルを取得します。
with wandb.init() as r:
    artifact = r.use_artifact("my_dataset:latest")
    table = artifact.get("my_table")

artifact を Dataframe に変換する

次に、テーブルをデータフレームに変換します。

# 前のコード例から続けて:
df = table.get_dataframe()

データのエクスポート

これで、データフレームがサポートする任意の方法を使用してエクスポートできます。

# テーブルデータを .csv に変換する
df.to_csv("example.csv", encoding="utf-8")

次のステップ