使用fredapi从FRED网站获取数据时,我收到以下错误:
Traceback (most recent call last):
File "/xyz/xyz/.local/lib/python3.8/site-packages/fredapi/fred.py", line 64, in __fetch_data
response = urlopen(url)
File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
在处理上述异常的过程中,发生了另一个异常:
Traceback (most recent call last):
File "/xyz/xyz/xyz.py", line 18, in
DataSetBuilder_1()
File "/xyz/xyz/xyz/xyz.py", line 150, in DataSetBuilder_1
x=fred.get_series(x, columns=[y])
File "/xyz/xyz/.local/lib/python3.8/site-packages/fredapi/fred.py", line 131, in get_series
root = self.__fetch_data(url)
File "/xyz/xyz/.local/lib/python3.8/site-packages/fredapi/fred.py", line 68, in __fetch_data
raise ValueError(root.get('message'))
ValueError: Not Found. The series does not exist.
有人知道这是怎么回事吗?提前感谢!
HTTP 404错误表示找不到页面。因此,无论fredapi试图访问什么页面,都找不到。
第二个错误来自Pandas,它说没有数据。Pandas数据以系列或DataFrame的形式出现。此错误是由上面的404错误引起的。
您需要确保您试图访问的url存在,并且正在返回预期的数据。
非常感谢您的投入。我真的很感激。
问题似乎出在FRED API上,一些用户报告某些系列无法访问。我们仍然不知道为什么,但这已经向FRED提出了。
非常感谢
L。