'List of lists' attribute error with Data

Hello all,

First post, longtime user.

I am trying to graph bubblechart on scattergeo with a drop down menu that controls the data. It is my understanding that data should be in a list and my code is set up to do that:

city_clean = []
for chptr in alum_dict.keys():
    cities = []
    
    for j in range(len(limits)):
        lim = limits[j]
        df_sub = alum_dict[chptr][lim[0]:lim[1]]
        cities.append(Scattergeo( locationmode = 'USA-states',
            lon = df_sub['Longitude'], 
            lat = df_sub['Latitude'],
            text = df_sub['text'],
            marker = dict(
                size = df_sub['Alumni in City']*10,
                color = colors[j],
                line = dict(width =.5, color = 'rgb(40,40,40)'),
                sizemode = 'area'),
                name = '{0} - {1}'.format(lim[0],lim[1])))
        
    city_clean.append(cities)

However I am also looping through multiple datasets with this line

for chptr in alum_dict.keys():

Essentially, I wan to create a scattergeo for each dataset, then append it all in a list, and have the drop down menu control which map is shown. However, when I get to this point:

fig = dict(data = city_clean, layout = layout)

I get the following attribute error:

Traceback (most recent call last):
  File "C:/Users/Michael/Desktop/Alumni_Scripts_Data/Alum_Geocoding/Bubble_Chart_Final.py", line 92, in <module>
plot_url = py.plot( fig, validate=False, filename='BetaTauAlums' )
  File "C:\Python27\lib\site-packages\plotly\plotly\plotly.py", line 196, in plot
for key, val in list(entry.items()):
AttributeError: 'list' object has no attribute 'items'

`I do not know what I am doing wrong, my city_clean list is set up to be [scattergeo1, scattergeo2,scattergeo3] but plotly does not like that.

Any help or should I be doing this in a completely different manner? I’m getting incredibly frustrated.

Thanks!!!

Hi,
I got this same error, something like: scattergeo’ object has no attribute ‘items’
The reason is bc you are using dict to iterate, simple solution is avoid dictionary.

for chptr in alum_dict.keys():
marker = dict(

Instead use:
a for loop
marker = go.scattergeo.Marker(
line = go.scattergeo.marker.Line(width=0.5, color=‘rgb(40,40,40)’),
fig = go.Figure(data=cases, layout=layout)


Referrer this: