Create colour gradient for lines in Scattermapbox (Python)

Iโ€™m mapping lines in plotly.graph_objects.Scattermapbox with fig.add_trace. Ideally, I would like to change the colour of the lines, such that it corresponds to an attribute in another column. For example:

Line Attribute
LINE01 45
LINE02 60
LINE03 270

I canโ€™t figure out how to do this. When I create my plot, each line appears as a legend entry (LINE01 appears as trace 0, etc.) This is my code:

import plotly.graph_objects as go
fig = go.Figure()


for i in range(len(df)):
    fig.add_trace(go.Scattermapbox(
        mode = "lines",
        lon = [df['lon.start'][i], df['lon.end'][i]],
        lat = [df['lat.start'][i], df['lat.end'][i]],
        line = dict(width = 3)
        )
    )

How can I change it such that my legend is grouped by the Attribute column to create a discrete colour scale?

Iโ€™ve tried tweaking my code to add the following, but it doesnโ€™t work

u_attribute = np.unique(df['Attribute'].values)
d = dict(zip(u_attribute, np.arange(len(u_attribute))))

line_color = [d[s] for s in df['Attribute']