Trace name from series

I have a graph that is being built with a loop that appends several go.Bar()'s to a ‘traces’ array.
I’m then returning this ‘traces’ array as the value to the ‘data’ key required by ‘figure’.
I’d like to use a pandas series in order to create the name for each trace, the elements in the series look something like this:
0 Indirect costs, 1 Direct costs, 2 Capital expenditures

how can i make each trace name be one of the unique elements in the series?

thank you

@blksheephw, can you share the source code you are using for that loop?

let me know if u need any clarification on anything

statewide_dict = budget_object_codes_by_region['statewide']
    traces = []
    for region_name in statewide_dict['institutions.region'].unique():
                x = statewide_dict['institutions.region'].unique(), 
                y = statewide_dict.loc[statewide_dict['institutions.region'] == region_name]['budget_items.budget'],
                name = "These will all be the same",
                marker = dict(
                    line=dict(color='#000000', width=2)
    return { 'data': traces,
            'layout': go.Layout(
            title = "Codes by Region", 
            margin = dict(

basically there is a key in my statewide_dict called object_codes that i’d like each trace to have as a name… lmk if something doesnt make sense… Also, statewide_dict is a dataframe sorry for the confusion w the name of the variable


I’m not to sure how your region_name series looks, but you should be able to take whatever index and set it to name within your go.Bar function.

Currently your name is set to name="These will all be the same"

but it should instead be something like:


You can find this in the plotly reference