How can I log table with index?


I’m logging a table using wandb.log and wandb.Table. What I’m logging via wandb.Table is a pandas data frame and it has index of rows that aren’t simple numbers but a list of category. More specifically, the table is 10 rows (with 10 str names) x 2 columns.

But what I find in the wand db dashboard is a table that’s rendered without the row indices. Is there a good way to log such data frame?


Hey @minkoo-seo, this currently isn’t supported but is an active feature request. I’ll be sure to update you on this thread once progress arises on this.




You can call reset_index on the dataframe to get a new data frame with the index as a column and then log that to W&B.

import pandas as pd
import wandb

# 1. Create the DataFrame with 10 rows containing a string
data = {'Strings': ['string_{}'.format(i) for i in range(10)]}
df = pd.DataFrame(data)

# 2. Reset the DataFrame's index to create a new column
df_reset = df.reset_index()

# 3. Initialize W&B run, log the DataFrame, and end the run
wandb.init(project='my_project', name='df_logging_with_index')

wandb.log({'dataframe_table': wandb.Table(dataframe= df_reset)})


Thank you. I find it a good workaround at the moment.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.