Pass proxy to Seaborn

前端 未结 2 1699
礼貌的吻别
礼貌的吻别 2021-01-21 13:55

I am using seaborn for data visualization. But it fails over the sample data it has in documentation

import seaborn as sns
sns.set()
tips = sns.load         


        
2条回答
  •  忘掉有多难
    2021-01-21 14:51

    I understand, question is bit old. But I was looking for the similar kind of solution, that I didn't get working for me (somehow) mentioned above. So, I created similar/duplicate question at below link:

    Not able to resolve issue(HTTP error 404) with seaborn.load_dataset function

    And then I found my solution through debugging. Details is below:

    load_dataset() is available in 'utils.py' library file, where path has below hard coded string:

    path = ("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/{}.csv")
    

    So, whatever file name we provide in load_dataset() function, python searches it online to above path. There is no option, where we can give our own online link for the dataset other than the above path. The second parameter of load_dataset() is 'cache' that has default boolean value as 'True'. So, if dataset not found online then the function will look into the physical path as below:

    :\Users\\seaborn-data 
        e.g. C:\Users\user1\seaborn-data    
    

    This path should have our dataset if not found online. i.e. below code will work if we have dataset physically present:

    df = sns.load_dataset('FiveYearData')
    

    (Note: But if dataset is found online then, due to cache=True, it will be copied to above path as well.)

    We can also provide different physical path for dataset through third parameter (data_home) as below:

    df = sns.load_dataset('FiveYearData',data_home=os.path.dirname(os.path.abspath("FiveYearData")))
    

    Here, I am taking my current project working directory to have my dataset.

提交回复
热议问题