现在,我只是把每一列放到一个列表中df['Name'].to_list()
->zip(list1,list2 ,....)
所有列表,遍历它们,然后将它们添加到表中。
我可以想象这远非一个理想的解决方案。在使用pandas时,还有什么更好的方法来填充dearpygui表吗?
我不太了解你们的方法,但这里有一个我使用的一般例子:
dataset = pd.read_csv(filename) # Take your df from wherever
with dpg.table(label='DatasetTable'):
for i in range(dataset.shape[1]): # Generates the correct amount of columns
dpg.add_table_column(label=dataset.columns[i]) # Adds the headers
for i in range(n): # Shows the first n rows
with dpg.table_row():
for j in range(dataset.shape[1]):
dpg.add_text(f"{dataset.iloc[i,j]}") # Displays the value of
# each row/column combination
我希望它能对某人有用。