Black Lives Matter. Please consider donating to Black Girls Code today.

Invalid value of type 'pandas.core.series.Series' received for the 'size' property of scattermapbox.marker

Hi, I’m new on Plotly.

I got a following error message running the code below.

Invalid value of type ‘pandas.core.series.Series’ received for the ‘size’ property of scattermapbox.marker

cols = ['zone', 'date', 'time', 'person_count_mean', 'lat', 'lon']
df = pd.DataFrame(index=[], columns=cols)

for i in range(5):
    tmp_person_count_mean = random.randint(1, 50)
    tmp_lat = 35.6822193 + random.uniform(0.0001,0.0005)
    tmp_lon = 139.7646148 + random.uniform(0.0001,0.0005)
    tmp_se = pd.Series(['Tokyo', '2020-10-01', '08:00:00', int(tmp_person_count_mean), tmp_lat, tmp_lon], index=df.columns)
    df = df.append(tmp_se, ignore_index=True)

print(df)

px.set_mapbox_access_token("DELETED")

fig = px.scatter_mapbox(df, lat="lat", lon="lon", zoom=17, color_continuous_scale=px.colors.cyclical.IceFire,
                        size="person_count_mean")


app = dash.Dash(__name__, external_stylesheets=["https://codepen.io/chriddyp/pen/bWLwgP.css"])

app.layout = html.Div(
    [
        html.H1("Tokyo"),
        dcc.Graph(id='graph', figure=fig)
    ]

)

if __name__ == '__main__':
    app.run_server(debug=True)

detailed error message is below.

Invalid value of type ‘pandas.core.series.Series’ received for the ‘size’ property of scattermapbox.marker
Received value: 0 46
1 22
2 42
3 44
4 44
Name: person_count_mean, dtype: object

The 'size' property is a number and may be specified as:
  - An int or float in the interval [0, inf]
  - A tuple, list, or one-dimensional numpy array of the above

I thought ‘person_count_mean’ is not set as ‘int’.
So, I applied Int() method to ‘tmp_person_count_mean’, but it did not work.

Thanks in advance.