How to get indian numeric system in plotly map..?

import geopandas as gpd
import plotly.express as px
import json
import pandas as pd

Agg_trans=pd.read_excel('Data_Path')
GrouBy_data=pd.DataFrame(Agg_trans.groupby('State')['Transaction_amount'].sum())
data_df=GrouBy_data.reset_index()

# Load GeoJSON 
geo_data = gpd.read_file("Geojson_Path")

# Convert the GeoDataFrame to a GeoJSON 
geo_json = json.loads(geo_data.to_json())

# Merge data with the GeoDataFrame
df = geo_data.merge(data_df, left_on='State', right_on='State', how='left')

# choropleth map 
fig = px.choropleth(
    df,
    geojson=geo_json,
    featureidkey="properties.State",  # Match with the key in GeoJSON properties
    locations="State",
    color="Transaction_amount",
    projection="mercator",
    width=900,  
    height=700  
    )

fig.update_geos(fitbounds="locations", visible=False)

# Show the map
fig.show()

Result:

Please refer to stackoverflow.com for your desired answer.

1 Like

Thank You…!

Is it possible to change color scale numeric system in the map (Now its in trillion) into indian numeric sysytem (Like: Crores, Lakhs and so on…)…?

I think we can handle this by creating our own strings. See second answer.

1 Like

Thank you…!

@Mac
If you want to display colorbar ticks as indian currency, then use locale to set the indian system:

Then set tickvals as the list of ordered numbers as usual colorbar ticks, and ticktext their conversion to
indian currency strings.

I give synthetic values for colorbar ticks:

import locale
locale.setlocale(locale.LC_MONETARY, 'en_IN')
tickvals=np.array([5*k for k in range(1, 8)]+np.random.rand(7))*10**6
ticktext=[locale.currency(tv, grouping=True) for tv in tickvals]
ticktext
['β‚Ή 54,63,466.58',
 'β‚Ή 1,06,04,675.03',
 'β‚Ή 1,55,86,111.03',
 'β‚Ή 2,06,56,579.13',
 'β‚Ή 2,50,12,840.37',
 'β‚Ή 3,00,31,698.94',
 'β‚Ή 3,53,90,703.60']

Now updating colorbar:
fig.update_layout(coloraxis_colorbar=dict(tickvals=tickvals, ticktext=ticktext)

the colorbar ticklabels will be displayed in indian format as above.
1 Like

Thank you.!