gpt4 book ai didi

Python/Plotly/Geopandas

转载 作者:行者123 更新时间:2023-11-28 19:01:04 28 4
gpt4 key购买 nike

我一直收到这个错误,并且已经阅读了其他人的在线访问,

ImportError: geopandas, pyshp and shapely must be installed for this figure factory.

Run the following commands to install the correct versions of the following modules:

```
pip install geopandas==0.3.0
pip install pyshp==1.2.10
pip install shapely==1.6.3
```
If you are using Windows, follow this post to properly install geopandas and dependencies:http://geoffboeing.com/2014/09/using-geopandas-windows/

If you are using Anaconda, do not use PIP to install the packages above. Instead use conda to install them:

```
conda install plotly

conda install geopanda

问题是,我已经通过上述方法安装了 plotly/geopanda,但它仍然不起作用,但是当我单独导入 plotly 时,geopand 不会抛出错误。实际上,当我在下面分解我的代码时,这一行就是引发错误的原因:ff.create_choropleth - 我的完整代码如下:

import plotly, geopandas
import plotly.plotly as py
import plotly.figure_factory as ff
import numpy as np
import pandas as pd
import xlrd
df_sample = pd.read_excel('popdata.xlsx') # Read in your data
values = df_sample['Change'].tolist() # Read in the values contained within your file
fips = df_sample['FIPS'].tolist() # Read in FIPS Codes

colorscale = ["#171c42","#223f78","#1267b2","#4590c4","#8cb5c9","#b6bed5","#dab2be",
"#d79d8b","#c46852","#a63329","#701b20","#3c0911"]

endpts = list(np.linspace(-75, 75, len(colorscale) - 1)) # Identify a suitable range for your data

#fig = ff.create_choropleth(
# fips=fips, values=values, colorscale=colorscale, show_state_data=True, binning_endpoints=endpts, # If your values is a list of numbers, you can bin your values into half-open intervals
# county_outline={'color': 'rgb(255,255,255)', 'width': 0.5},
# legend_title='% change', title='% Change in disease between 1980-2014'
#)
py.plot(fig, filename='diseasechange')

最佳答案

pip install geopandas==0.8.1 

为我解决了这个问题。

关于Python/Plotly/Geopandas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52528889/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com