I'm lookin at the use map from the link below.
https://plotly.com/python/mapbox-county-choropleth/
Here is their code.
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv",
dtype={"fips": str})
import plotly.express as px
fig = px.choropleth_mapbox(df, geojson=counties, locations='fips', color='unemp',
color_continuous_scale="Viridis",
range_color=(0, 12),
mapbox_style="carto-positron",
zoom=3, center = {"lat": 37.0902, "lon": -95.7129},
opacity=0.5,
labels={'unemp':'unemployment rate'}
)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
Here is their results.
Here is my own code.
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
import pandas as pd
import plotly.express as px
fig = px.choropleth_mapbox(df_lat_lon, geojson=counties, locations='local_market', color='days_between_start_and_complete',
color_continuous_scale="Viridis",
range_color=(0, 12),
mapbox_style="carto-positron",
zoom=3, center = {"lat": 37.0902, "lon": -95.7129},
opacity=0.5,
labels={'markets'}
)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
Here is my DF:
Here is the data from my DF:
index local_market latitude longitude days
4753 Las Vegas 35.936682 -115.086450 134
1628 El Paso 31.755722 -106.273967 2
1625 Denver 39.925373 -105.115118 11
6896 Phoenix 33.609486 -112.181292 11
6897 Tucson 32.228861 -110.947664 9
6898 Tucson 32.228861 -110.947664 9
6899 Tucson 32.228861 -110.947664 9
6900 Tucson 32.228861 -110.947664 9
My map is completely blank.