Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Nov 29, 2020
Embed
What would you like to do?
world["Cases Range"]=pd.cut(world["Cases"],[-150000,50000,200000,800000,1500000,15000000],labels=["U50K","50Kto200K","200Kto800K","800Kto1.5M","1.5M+"])
alpha =[]
for i in world["Country"].str.upper().values:
if i == "BRUNEI":
i="BRUNEI DARUSSALAM"
elif i=="US":
i="UNITED STATES"
if len(continent[continent["name"]==i]["alpha-3"].values)==0:
alpha.append(np.nan)
else:
alpha.append(continent[continent["name"]==i]["alpha-3"].values[0])
world["Alpha3"]=alpha
fig = px.choropleth(world.dropna(),
locations="Alpha3",
color="Cases Range",
projection="mercator",
color_discrete_sequence=["white","khaki","yellow","orange","red"])
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment