Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't access seaborn example datasets

I was trying to use 'tips' dataset from seaborn:

import seaborn as sns
tips = sns.load_dataset("tips")

and I got this error:

ValueError                                Traceback (most recent call last)
Cell In[5], line 1
----> 1 a = sns.load_dataset("anagrams")
      2 a.info()

File C:\anaconda3\lib\site-packages\seaborn\utils.py:587, in load_dataset(name, cache, data_home, **kws)
    585 if not os.path.exists(cache_path):
    586     if name not in get_dataset_names():
--> 587         raise ValueError(f"'{name}' is not one of the example datasets.")
    588     urlretrieve(url, cache_path)
    589 full_path = cache_path

ValueError: 'anagrams' is not one of the example datasets.

Then I tried:

sns.get_dataset_names()

the output was an empty list: []

I can use seaborn plots. I also tried to update my seaborn using:

!pip install seaborn --upgrade

but it didn't help.

Could you please help?

like image 353
hooman hedayati Avatar asked Nov 02 '25 19:11

hooman hedayati


1 Answers

It could be that you installed seaborn a long time ago, loaded datasets then, which created a cache, and now are trying to use a new dataset.

Try to use cache=False:

tips = sns.load_dataset("tips", cache=False)

The load_dataset function is explicitly not trying to download the dataset if you have a cache and the dataset name is not found:

if cache:
        cache_path = os.path.join(get_data_home(data_home), os.path.basename(url))
        if not os.path.exists(cache_path):
            if name not in get_dataset_names():
                raise ValueError(f"'{name}' is not one of the example datasets.")
            urlretrieve(url, cache_path)
        full_path = cache_path
    else:
        full_path = url

You can also try to delete the cache directory. Get its path using:

print(sns.utils.get_data_home())
like image 170
mozway Avatar answered Nov 04 '25 08:11

mozway