Is there a way to write custom aggregation function in Python when using AG Grid?
I’m aware that we can write javascript functions for custom aggregation but I would like to do it on the server side with Python function. Is it possible? Thanks for your attention.
To give more context to my problem, I already have a dataframe with precalculated aggregate values and the aggregates are not straight forward (requires a lot of computational power). I just want to show the corresponding aggregates for each group using simple look up using group keys.
Thanks for the reply! I’m using the rowGroup attribute in the colDef so the rows are collapsed if value is the same.
columnDefs = [
{
"headerName": "Portfolio Code",
"field": "portfolio_code",
"rowGroup": True,
"hide": True,
},
{"headerName": "Risk Type", "field": "risk_type", "rowGroup": True, "hide": True},
{"headerName": "Category", "field": "category", "rowGroup": True, "hide": True},
*[
{
"headerName": format_header(col),
"headerTooltip": format_header(col),
"field": col,
"aggFunc": <AGGFUNC>
"valueFormatter": {
"function": "params.value && d3.format('(.2f')(params.value)"
},
}
for col in df.columns.tolist()
if "bps" in col
],
]
I don’t have the function (AGGFUNC) to aggregate the values because the aggregation was done in another system but I have the aggregated values. But I can’t find a way to put those values into the cells.