Closed hupili closed 6 years ago
geopandas
. pyproj
has some problem in python3.7
. pip install numpy
pip install pandas
pip install plotly
pip install pyshp
pip install shapely
pip install cython
pip install git+https://github.com/jswhit/pyproj.git
pip install geopandas
Then operate these codes
import plotly.plotly as py
import plotly.figure_factory as ff
import numpy as np import pandas as pd
df_sample = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/laucnty16.csv') df_sample['State FIPS Code'] = df_sample['State FIPS Code'].apply(lambda x: str(x).zfill(2)) df_sample['County FIPS Code'] = df_sample['County FIPS Code'].apply(lambda x: str(x).zfill(3)) df_sample['FIPS'] = df_sample['State FIPS Code'] + df_sample['County FIPS Code']
colorscale = ["#f7fbff","#ebf3fb","#deebf7","#d2e3f3","#c6dbef","#b3d2e9","#9ecae1", "#85bcdb","#6baed6","#57a0ce","#4292c6","#3082be","#2171b5","#1361a9", "#08519c","#0b4083","#08306b"] endpts = list(np.linspace(1, 12, len(colorscale) - 1)) fips = df_sample['FIPS'].tolist() values = df_sample['Unemployment Rate (%)'].tolist()
fig = ff.create_choropleth( fips=fips, values=values, binning_endpoints=endpts, colorscale=colorscale, show_state_data=False, show_hover=True, centroid_marker={'opacity': 0}, asp=2.9, title='USA by Unemployment %', legend_title='% unemployed' ) py.iplot(fig, filename='choropleth_full_usa')
Get a U.S map
![newplot](https://user-images.githubusercontent.com/42834869/48928930-c8b28480-ef1e-11e8-9700-54f166a95784.png)
- If anyone find any new problem, please tell us and let's solve the problem together.
Good note. Edited into FAQ. @FLYSTEPHEN you may want to have a look. An FAQ structure is slight different. Error messages help people to search into that page.
Also added this case to week 13 mapping.
👍
Got it! We need to extract essential information from the Error messages!
https://python-graph-gallery.com/292-choropleth-map-with-folium/
A project on the same topic but different library. FYR.
https://github.com/hupili/python-for-data-and-media-communication-gitbook/blob/master/module-geopandas.md