Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python/Plotly/Geopandas_Python_Plotly_Geopandas - Fatal编程技术网

Python/Plotly/Geopandas

Python/Plotly/Geopandas,python,plotly,geopandas,Python,Plotly,Geopandas,我不断地发现这个错误,并且在网上看到了其他人的信息 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==

我不断地发现这个错误,并且在网上看到了其他人的信息

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、geopanda时,它不会抛出错误。实际上,当我分解下面的代码时,这一行就是引发错误的原因:
ff.create\u 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')

请不要将绘图工厂导入为ff,然后再导入ff。请尝试以下操作:

# import necessary libraries
import geopandas
import shapely
import shapefile
import plotly
from plotly.figure_factory._county_choropleth import create_choropleth
import xlrd
# Check your version
print(plotly.__version__, geopandas.__version__,shapely.__version__,shapefile.__version__)
# Data
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 = 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'
)
# Plot in offline mode and save plot in your Python script folder
plotly.offline.plot(fig, filename='diseasechange.html')

另外,如果您在
导入shapely
导入shapefile
时遇到问题,则需要安装它

,您会遇到什么错误?(您能显示完整的回溯吗?)导入错误。在我的邮件的最顶端,当我下班回来时,我会把跟踪信息发回去