I’m learning about Dash Ag Grid and I have a question that can we use AG Grid where one part is named, one part is dynamic. For Example:
import pandas as pd
import numpy as np
import dash_ag_grid as dag
from dash import Dash, html, dcc
#create DataFrame
df = pd.DataFrame({'name': ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'g'],
'school': ['A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C'],
'points': [2800, 1700, 1900, 1400, 2300, 2600, 5000, 10000, 15000],
'rebounds': [5000, 6000, 4000, 7000, 14000, 12000, 9000, 3000, 9000],
'assists': [10000, 13000, 7000, 8000, 4000, 5000, 8000, 10000, 7000]})
app = Dash(__name__)
app.layout = html.Div([
dag.AgGrid(
id="format-specifiers-example",
style={"height": "500px", "width": "100%"},
columnDefs=[{'field':'name'}, [{'field':i} for i in df.columns[2:]]],
rowData=df.to_dict("records"),
columnSize="sizeToFit")],
style={"margin": 20},
)
if __name__ == "__main__":
app.run(debug=False)
So I just want to show name and skip schools from data then show points, rebounds and assists. I know that I can define name of each field like {'field':'points'}, {'field':'rebounds'}, {'field':'assists'}
but if one more columns appear in the df, I want to show it but don’t need to hard code. Thank you.