For the table widget, can we rename the column labels?
I am going through the documentation of the table element, and I am wondering can the column label be renamed? Or we must do that in a dictionary object first?
Solution:Jump to solution
i would change it from the data you have before passing it into
mo.ui.table
5 Replies
Solution
i would change it from the data you have before passing it into
mo.ui.table
this may be easier when using polars or pandas
https://docs.pola.rs/api/python/dev/reference/dataframe/api/polars.DataFrame.rename.html
That could potentially be something we one day add to
ui.experimental_data_editor
if there is sufficient interest?I think the data editor and table element might be redundant. Can the add row be a method? table.add_row() or table.add_rows(). For the editing, can it be control with
read_only
flag?
Having the need to convert a dataset to a dataframe just so the table labels can be modify seems like an extra step (and overhead) in some use cases. This is just a personal opinion.You don't need to convert it to a dataframe, you can keep it as a dictionary - i just found it easier since the util to rename is already there.