Why choropleth mapbox, using animation, not show all discrete values from a dataframe?

I’m trying to plot a map using this dataframe (df_FR_1)

enter image description here

My problem is when I try to use choropleth_mapbox like this :

px.choropleth_mapbox(df_FR_1, geojson = geo_reg, locations="Code", color="Range de veillisement",
                    #color_discrete_map = col_dis_mp,
                    featureidkey="properties.code", mapbox_style="white-bg",
                    center = {'lat': 46.5, 'lon': -0.1}, zoom = 4.1, animation_frame="Year"
                    )

I cannot understand why the plot gives only 2 discrete values, when in total there are 3 :

enter image description here

So the final plot gives me errors like this :

enter image description here

There are values for all years and all Colum ‘Code’.

Can someone help me please ?

Thanks in advance,
Jorge

  • What is the type of data for the year? Also, what about converting the aging range to a categorical variable? Can you submit reproducible data? Data would increase your chances of getting an answer.

    – 

  • Hello, thanks for your answer. The type of year is “int” and I use categorical because it’s easier to distinguish the differences between territories and continuous values. Total data is 322 rows, i’m not sur if is possible submit that here……

    – 

  • Maybe someone have also issues using categorical values in choropleth_mapbox ? because when I use continuos all is ok…

    – 

Leave a Comment