gpt4 book ai didi

python - HTTP 错误 404 : Not Found Seaborn FacetGrid

转载 作者:行者123 更新时间:2023-12-01 02:30:52 24 4
gpt4 key购买 nike

我想使用 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 功能在线查找其数据集。

来自文档字符串

Help on function load_dataset in module seaborn.utils:

load_dataset(name, cache=True, data_home=None, **kws) Load a dataset from the online repository (requires internet).

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

由于在定义的在线存储库中没有 new_df 文件,因此它返回 404 错误。

您可以将数据帧传递给seaborn函数(如果它已经在您的代码中定义)。

所以如果你的 df 被称为 new_df

f = sns.FacetGrid(new_df, col="Year", col_wrap=4, size=1.5)

应该使用您的数据框。

关于python - HTTP 错误 404 : Not Found Seaborn FacetGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46831363/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com