marimo icon indicating copy to clipboard operation
marimo copied to clipboard

Ability to style / format mo.ui.table()

Open Norvie opened this issue 1 year ago • 1 comments

Description

Would be great to be able to format the output of mo.ui.table(). As an example to be able to add decimals, format numbers as percentages, datetime formating etc... image This is the current output.

Suggested solution

A suggested solution would be to add the ability to handle pd options display like pd.options.display.float_format = "{:,.2f}".format.

Alternative

No response

Additional context

No response

Norvie avatar Feb 12 '24 19:02 Norvie

This would be extremely useful!

It would be especially helpful for datetime formatting, as there doesn't seem to be any way to customize the display of dates in the table. At least for numbers, you can make them into strings to customize the number of decimal places, but any method of attempting to convert a datetime to a string leads to the table displaying it the same way.

Having a way to customize the default datetime formatting would be a good solution I believe, or possibly a way to disable automatic datetime identification per column.

Example: image

aopell avatar Feb 17 '24 19:02 aopell

@Norvie, @aopell would appreciate your thoughts:

  1. Do you want to format this programmatically? E.g. passing format options to the table. or do this on the frontend with the dropdown (this wont be persisted across into the application code)? or both?
  2. Do you want to do this per table (.e.g float_format, data_format) or per column?

mscolnick avatar Jul 22 '24 16:07 mscolnick

Hi @mscolnick

In my humble opinion :)

  1. Both
  2. Per column

Norvie avatar Jul 24 '24 08:07 Norvie