Empty dash table

df1 = pd.DataFrame({“Symbol”:[‘alpha’,‘beta’,‘gamma’],“Currency”:[‘USD’,‘USD’,‘USD’],“Price unit”:[‘1’,‘1’,‘1’],
“Trade Unit”:[‘Kg’,‘Kg’,‘Kg’], “Lot Size”:[‘15’,‘1’,‘1’],“Tick Size”:[‘1’,’.01’,’.01’]})

dash_table.DataTable(id =“Con_specs”,columns = [{“name”:x ,“id”: ‘specs_{}’.format(i)} for i,x in enumerate(df1.columns)],
data = df1.to_dict(‘records’))


Not able to find the table content in the cell. Please let me know where I am doing wrong.

Hi @PG55 and welcome to the forum!

“id” needs to be column names in df1. “name” can be whatever you want to show as column headings in the table.

So this should work:

columns = [{"name":'specs_{}'.format(i),"id": x } for i,x in enumerate(df1.columns)],

Or if you just want the column heading like in your image:

`columns = [{"name":i,"id": i } for i in df1.columns]`

Voila!! Thanks a lot!!

1 Like