HTTP错误404:未找到Seaborn FacetGrid
问题描述:
我有以下数据框,我想使用Seaborn库在FacetGrid中绘图。HTTP错误404:未找到Seaborn FacetGrid
projectId sentDate correspondenceId Year Month
0 10417 2001-09-25 8710 2001 9
1 10417 2001-10-01 9173 2001 10
2 10417 2001-10-05 9676 2001 10
3 10417 2001-10-24 11487 2001 10
4 10417 2001-10-29 11872 2001 10
我使用下面的代码绘制它
data_plot = sns.load_dataset("new_df")
f = sns.FacetGrid(data_plot, col="Year", col_wrap=4, size=1.5)
f = f.map(plt.plot, "Month", "correspondenceId.count()", marker=".")
但我得到一个错误
--> 650 raise HTTPError(req.full_url, code, msg, hdrs, fp)
651
652 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 404: Not Found
我的库是最新的。我是编程新手,所以在编码时我仍然进行大量的试验和错误以获得正确的输出。 任何想法如何解决这个问题?
答
seaborn的load_dataset功能在线查找数据集。
从文档字符串
模块seaborn.utils的功能load_dataset帮助:
load_dataset(姓名,缓存=真,data_home =无,** KWS) 负荷从在线数据集资源库(需要互联网)。
Parameters ---------- name : str Name of the dataset (`name`.csv on https://github.com/mwaskom/seaborn-data). You can obtain list of available datasets using :func:`get_dataset_names` cache : boolean, optional If True, then cache data locally and use the cache on subsequent calls data_home : string, optional The directory in which to cache data. By default, uses ~/seaborn-data/ kws : dict, optional Passed to pandas.read_csv
自定义在线仓库有它返回一个404错误没有new_df文件。
您可以将您的数据框传递给seaborn函数(如果它已经在代码中定义)。
所以,如果你的df被称为new_df
。
f = sns.FacetGrid(new_df, col="Year", col_wrap=4, size=1.5)
应该使用你的数据帧。
这解决了这个问题。谢谢! – snakepain