【问题标题】:How do I fix time out error when reading iris data?读取虹膜数据时如何修复超时错误?
【发布时间】:2019-06-18 21:50:45
【问题描述】:
读取数据时出现超时错误。
我在我的公司,所以我必须写 pip install --proxy=http://ep.threatpulse.net:80pandas 才能安装 pandas。
这是一个prozy问题吗?
import pandas as pd
url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
df = pd.read_csv(url, names=['sepal length','sepal width','petal length','petal width','target'])
结果是这样的:
urlopen error [Errno 10060] 连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应
【问题讨论】:
标签:
python
timeout
read.csv
【解决方案1】:
是的,出现此错误是因为它无法建立与 Internet 网络错误或代理设置问题的连接。您可以检查您的 IE 上的代理设置,如果它默认采用,或者在同一网络中的另一台 PC 上尝试,或者要求您公司的系统管理员允许访问。
【解决方案2】:
你可以试试这样设置代理!
import io
import requests
proxy_dict = {"https":"https://xx.xx.x.xx:80"} #replace proxy setting here
response = requests.get(url, proxies=proxy_dict).text
df = pd.read_csv(io.StringIO(response),header=None)
df.columns = ['sepal length in cm','sepal width in cm',
'petal length in cm','petal width in cm','class']