Group Data for Scatter Plot in Dash

Hello,

I have a graph as seen below and i am trying to group the data because the df contains more values for other charts. I can’t seem to figure out the syntax. I would like to group the data for the trace by DescReporting, Subcategory, and Indicator. Any help would be greatly appreciated. Thanks!

def update_graph(xaxis_column_name, yaxis_column_name,
xaxis_type, yaxis_type,
year_value):
dff = df[df[‘Year’] == year_value]
traces = []
for i in dff.DescReporting.unique():
dfdc = dff[dff[‘DescReporting’] == i]
traces.append(go.Scatter(
x=dfdc[dfdc[‘Indicator’] == xaxis_column_name][‘Values’],
y=dfdc[dfdc[‘Indicator’] == yaxis_column_name][‘Values’],
text=dfdc[dfdc[‘Indicator’] == yaxis_column_name][‘SubCategory’],
customdata=dfdc[dfdc[‘Indicator’] == yaxis_column_name][‘SubCategory’],
mode=‘markers’,
marker={
‘size’: 15,
‘opacity’: 0.5,
‘line’: {‘width’: 0.5, ‘color’: ‘white’}
},
name=i
))
return{
‘data’:traces,
‘layout’: go.Layout(
xaxis={
‘title’: xaxis_column_name,
‘type’: ‘linear’ if xaxis_type == ‘Linear’ else ‘log’
},
yaxis={
‘title’: yaxis_column_name,
‘type’: ‘linear’ if yaxis_type == ‘Linear’ else ‘log’
},
margin={‘l’: 60, ‘b’: 30, ‘t’: 10, ‘r’: 0},
height=450,
hovermode=‘closest’
)
}