ipyaggrid icon indicating copy to clipboard operation
ipyaggrid copied to clipboard

TypeError: Unserializable object for ipyaggrid table cell renderer

Open AlesyaSeliazniova30032012 opened this issue 11 months ago • 7 comments

Hi. I use "ipyaggrid" lib. I want to convert all price values to float format with 2 decimal places and add a prefix £. Please tell me what I'm doing wrong and how to fix it, that I'm getting an error TypeError: Unserializable object <function currency_renderer at 0x0000026B9F46AB60> of type <class 'function'>. Thanks for any help

def currency_renderer(params): formatted_value = "£{:.2f}".format(float(params.value)) return formatted_value ` def create_aggrid(df): currency_columns = ['size', 'pnl', 'commission'] column_defs = [ { 'headerName': column, 'field': column, 'cellRenderer': currency_renderer if column in currency_columns else None } for column in df.columns ] grid_options = { 'columnDefs' : column_defs, 'defaultColDef': {'sortable': 'true', 'filter': 'true', 'resizable': 'true'}, }

ag_grid = grid.Grid(grid_data=df,
        export_mode="buttons",
        columns_fit='auto',
        grid_options=grid_options,
        theme='ag-theme-balham',
        keep_multiindex=False,
        center=True)

return ag_grid

`