为什么在 python 中绘制图形时会出现 HTTP400 错误? [英] Why do i get HTTP400 error when i am plotting graphs in python?
问题描述
我正在研究数据集以可视化python中的基本图.我使用 seaborn 和 matplotlib
.直到昨天,这些软件包都可以正常工作,直到出现此错误为止:
I am working on a dataset to visualize basic plots in python. I use seaborn and matplotlib
. Up until yesterday, the packages worked perfectly fine until this error showed up:
stars = sns.load_dataset(vcsfeatures)
sns.boxplot(stars)
plt.xlim(-100, 8000, 500)
plt.show()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/seaborn/utils.py", line 424, in load_dataset
urlretrieve(full_path, cache_path)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 248, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
我在这个平台上搜索过,所有的答案都是出于使用 url 或访问 web api 的意图.
I searched on this platform and all answers came from-out the intention to utilize a url or to get access to a web api.
当我使用简单的绘图代码时,会发生此错误:
This error occurs when i use simple plot code:
pd.DataFrame.boxplot(vcsfeatures)
pd.DataFrame.boxplot(userfeatures)
plt.ylim(-100, 1800)
plt.show()
也使用假数据作为 data = [1、2、3]
每当我尝试调用绘图库时,我都会收到此错误.
also with fake data as data = [1, 2, 3]
I get this error whenever i try to call for a plotting library.
这曾经在昨天有效.对于 seaborn、pandas 和 numpy 也会出现错误.
寻找解决方案时,我在这里遗漏了什么?
What am I missing here in finding the solution?
如果已经有这样的问题,请重定向我,因为我找不到它.
If there is a question like this already, please redirect me as I am not able to find it.
推荐答案
sns.load_dataset
需要一个字符串作为参数,该字符串的值等于
sns.load_dataset
requires a string as argument which evaluates to one of the available datasets at https://github.com/mwaskom/seaborn-data
.
例如 sns.load_dataset("tips")
将加载 tips.csv 文件.
另请参见 Seaborn load_dataset
提供一些其他数据或没有相应文件的字符串当然不起作用.
Supplying some other data or a string which does not have its corresponding file will of course not work.
这篇关于为什么在 python 中绘制图形时会出现 HTTP400 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!