Skip to content Skip to sidebar Skip to footer

Flask Pandas To Tabulator Tables Are All Messed Up

I'm a new Dev , trying to pass Pandas DataFrame to Tabulator , it works but the table is so messed up original file : original file in excel without tabulator : to_html() render r

Solution 1:

Looking at the code you posted, the issue is that it is using th tags for the first cell of each row in the table instead of td tags. th tags should only be used in the thead not the tbody

Solution 2:

Working with .to_json(orient = "records") is always the best for Tabulator

Try this:

1) If there's no Id yet, just:

df.insert(0,'id',range(1,len(df)+1))
df= df.to_json(orient='records')

JsonResponse({'myDF':df})

2) Once back in Javascript, when you try to load your data from Ajax response, you must use

 data: eval(json.myDF) 

in order to Tabulator read it correctly

Post a Comment for "Flask Pandas To Tabulator Tables Are All Messed Up"