-
-
Save prithwi/d029b239b7f1de7a895e to your computer and use it in GitHub Desktop.
Example Choropleth map using folium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id | Country | Score | |
---|---|---|---|
PER | Peru | 2.81030047565 | |
HND | Honduras | 2.73452059052 | |
GUF | French Guiana | 2.73088624339 | |
SLV | El Salvador | 2.47313396091 | |
CRI | Costa Rica | 2.45496258877 | |
PRY | Paraguay | 2.27359432526 | |
CHL | Chile | 2.22459594857 | |
ECU | Ecuador | 2.1062717474 | |
ARG | Argentina | 2.07731052863 | |
BOL | Bolivia | 2.04044795703 | |
NIC | Nicaragua | 2.02057902574 | |
COL | Colombia | 1.97875064122 | |
MEX | Mexico | 1.86885576881 | |
GTM | Guatemala | 1.57594468934 | |
PAN | Panama | 1.23348283352 |
@ammarsabircheema I suspect the world-countries.json
file you are using doesn't have the requisite columns.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried to compile your code but I am having following error,
`
Traceback (most recent call last):
File "/home/ammar/.local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2897, in get_loc
return self._engine.get_loc(key)
File "pandas/_libs/index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'geometry'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ch.py", line 28, in
geo_str = spatial_gdf.to_json()
File "/home/ammar/.local/lib/python3.7/site-packages/geopandas/geodataframe.py", line 381, in to_json
return json.dumps(self._to_geo(na=na, show_bbox=show_bbox), **kwargs)
File "/home/ammar/.local/lib/python3.7/site-packages/geopandas/geodataframe.py", line 468, in _to_geo
"features": list(self.iterfeatures(**kwargs)),
File "/home/ammar/.local/lib/python3.7/site-packages/geopandas/geodataframe.py", line 417, in iterfeatures
geometries = np.array(self[self._geometry_column_name], copy=False)
File "/home/ammar/.local/lib/python3.7/site-packages/geopandas/geodataframe.py", line 546, in getitem
result = super(GeoDataFrame, self).getitem(key)
File "/home/ammar/.local/lib/python3.7/site-packages/pandas/core/frame.py", line 2980, in getitem
indexer = self.columns.get_loc(key)
File "/home/ammar/.local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 2899, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas/_libs/index.pyx", line 107, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 131, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 1607, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1614, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'geometry
`