Ag-Grid formatting floating point values

Before using I was able to set decimals as shown below

format_dict = {f: "{:,.2f}" for f in fields}
st.dataframe(pdf.style.format(format_dict))

How can I limit number of decimals when I use Ag-Grid.
Thank you.

Hi @kannaiah

You could try the this when configuring the column in AGgrid:

gb = GridOptionsBuilder.from_dataframe(df) # where df = your dataframe ref variable
gb.configure_column(YourColumnNameHeader, type=[“numericColumn”,“numberColumnFilter”,“customNumericFormat”], precision=1)

Cheers

1 Like

This worked for columns with floating point values.

I have a column with a list, and this did not affect that column

image

Hi @kannaiah

Then I think you will need to use list comprehension on each value of the data frame column before passing the data frame to aggrid

Cheers

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.