我是Python新手并尝试从以下网址下载csv文件,但收到如下错误 https://mldata.org/repository/data/download/csv/stockvalues/
脚本下载无效的csv
import pandas as pd
import numpy as np
url = 'https://mldata.org/repository/data/download/csv/stockvalues.csv'
url_data = pd.read_table(url,sep='\t')
url_data.head(3)
收到以下错误
urllib.error.URLError occurred Message=<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)>
StackTrace:
C:\Program Files\Anaconda3\lib\urllib\request.py:1320 in AbstractHTTPHandler.do_open
C:\Program Files\Anaconda3\lib\urllib\request.py:1361 in HTTPSHandler.https_open
C:\Program Files\Anaconda3\lib\urllib\request.py:504 in OpenerDirector._call_chain
C:\Program Files\Anaconda3\lib\urllib\request.py:544 in OpenerDirector._open
C:\Program Files\Anaconda3\lib\urllib\request.py:526 in OpenerDirector.open
C:\Program Files\Anaconda3\lib\urllib\request.py:223 in urlopen
C:\Program Files\Anaconda3\lib\site-packages\pandas\io\common.py:186 in get_filepath_or_buffer
C:\Program Files\Anaconda3\lib\site-packages\pandas\io\parsers.py:392 in _read
C:\Program Files\Anaconda3\lib\site-packages\pandas\io\parsers.py:655 in parser_f in _make_parser_function
答案 0 :(得分:1)
您的网址存在问题。如果您的浏览器不信任该网址的证书,则会发生该错误。这绝对意味着网站出现了问题,或链接出现了问题。
作为参考,我进入了website并找到了正确的链接。
url = 'http://mldata.org/repository/data/download/csv/stockvalues/'
df = pd.read_csv(url, header=None)
df.head()