2017-10-19 191 views
0

我有以下數據框,我想使用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 

我的庫是最新的。我是編程新手,所以在編碼時我仍然進行大量的試驗和錯誤以獲得正確的輸出。 任何想法如何解決這個問題?

回答

1

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) 

應該使用你的數據幀。

+0

這解決了這個問題。謝謝! – snakepain