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

Error choropleth() got an unexpected keyword argument 'geojson'

I am trying to use choropleth map vizualisation, but when I copy the example code (or when I customize it) I get the following error : TypeError: choropleth() got an unexpected keyword argument ‘geojson’

I am running this code

from urllib.request import urlopen
import json
with urlopen('') as response:
    counties = json.load(response)

import pandas as pd
df = pd.read_csv("",
                   dtype={"fips": str})

import as px

fig = px.choropleth(df, geojson=counties, locations='fips', color='unemp',
                           range_color=(0, 12),
                           labels={'unemp':'unemployment rate'}

Any ideas why?

Hi @yo.angelina, welcome to the forum! The geojson attribute was introduced in the latest release of (4.5), maybe you have an older version installed? You can check it with

import plotly

You can update your version of plotly by doing pip install -U plotly (or with conda if you’re using conda). More instructions are given in

1 Like

Hi @Emmanuelle, thanks!

Indeed, it was version problem (I had 4.4.1 installed). Everything works now :slight_smile: