Why do i get HTTP400 error when i am plotting graphs in python?

强颜欢笑 提交于 2019-12-13 08:48:51

问题


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

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()

also with fake data as data = [1, 2, 3] I get this error whenever i try to call for a plotting library.

This used to work yesterday. Also with seaborn, pandas and numpy the error comes up.

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.


回答1:


sns.load_dataset requires a string as argument which evaluates to one of the available datasets at https://github.com/mwaskom/seaborn-data.

E.g. sns.load_dataset("tips") would load the tips.csv file.

Also see Seaborn load_dataset

Supplying some other data or a string which does not have its corresponding file will of course not work.



来源:https://stackoverflow.com/questions/44294541/why-do-i-get-http400-error-when-i-am-plotting-graphs-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!