Get help from the marimo community

Updated 3 months ago

For the table widget, can we rename the column labels?

At a glance

The community member is wondering if the column labels in a table element can be renamed, or if they need to do that in a dictionary object first. The comments suggest that the column labels can be changed before passing the data to the mo.ui.table function, and that this may be easier when using libraries like Polars or Pandas. One community member mentions that the ability to rename column labels could potentially be added to the ui.experimental_data_editor feature if there is sufficient interest. Another community member suggests that the data editor and table element might be redundant, and that adding rows and controlling editability could be handled directly on the table element. Some community members express the opinion that having to convert a dataset to a dataframe just to rename the column labels seems like an unnecessary extra step.

Useful resources
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?
M
A
J
7 comments
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
That could potentially be something we one day add to ui.experimental_data_editor if there is sufficient interest?
Attachment
image.png
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.
Add a reply
Sign up and join the conversation on Discord