1

Hi I'm a student looking to use jupyter notebook to represent a dataset for a school task.

import seaborn as sns
spotify = sns.load_dataset('top10s.csv')

this is a data set that I found online and when I try to run this code I get and HTTPError

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-2-af1fc80c3c1b> in <module>
      1 import seaborn as sns
----> 2 spotify = sns.load_dataset('top10s.csv')

~\Anaconda3\lib\site-packages\seaborn\utils.py in load_dataset(name, cache, data_home, **kws)
    426                                   os.path.basename(full_path))
    427         if not os.path.exists(cache_path):
--> 428             urlretrieve(full_path, cache_path)
    429         full_path = cache_path
    430 

~\Anaconda3\lib\urllib\request.py in urlretrieve(url, filename, reporthook, data)
    245     url_type, path = splittype(url)
    246 
--> 247     with contextlib.closing(urlopen(url, data)) as fp:
    248         headers = fp.info()
    249 

~\Anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    220     else:
    221         opener = _opener
--> 222     return opener.open(url, data, timeout)
    223 
    224 def install_opener(opener):

~\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout)
    529         for processor in self.process_response.get(protocol, []):
    530             meth = getattr(processor, meth_name)
--> 531             response = meth(req, response)
    532 
    533         return response

~\Anaconda3\lib\urllib\request.py in http_response(self, request, response)
    639         if not (200 <= code < 300):
    640             response = self.parent.error(
--> 641                 'http', request, response, code, msg, hdrs)
    642 
    643         return response

~\Anaconda3\lib\urllib\request.py in error(self, proto, *args)
    567         if http_err:
    568             args = (dict, 'default', 'http_error_default') + orig_args
--> 569             return self._call_chain(*args)
    570 
    571 # XXX probably also want an abstract factory that knows when it makes

~\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
    501         for handler in handlers:
    502             func = getattr(handler, meth_name)
--> 503             result = func(*args)
    504             if result is not None:
    505                 return result

~\Anaconda3\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs)
    647 class HTTPDefaultErrorHandler(BaseHandler):
    648     def http_error_default(self, req, fp, code, msg, hdrs):
--> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    650 
    651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found

I do not know how to fix this or why I am even getting is issue

I hope somebody can help me and thank you for your time

Sahith Kurapati
  • 1,617
  • 10
  • 14

3 Answers3

1

There are 2 errors in the code.

  1. We can load only datasets present in the seaborn website using sns.load_dataset as it for online CSV files on https://github.com/mwaskom/seaborn-data.

  2. While specifying the dataset name no need to specify the extension of the dataset. Below is the sample code to load tips dataset.

    import seaborn as sns
    
    tips = sns.load_dataset("tips")
    tips.head()
    
ZygD
  • 22,092
  • 39
  • 79
  • 102
Krishna
  • 11
  • 2
0

sns.load_dataset() searches for a dataset from online. It does not import the dataset from your working directory.

Here is the documentation for seaborn load_dataset function

Assuming that your dataset top10s.csv is located in the same folder as your python file, you should use pandas for this instead.

import pandas as pd

spotify = pd.read_csv('top10s.csv')

Be aware that you have to install this library before importing via pip like so:

pip install pandas
mwaskom
  • 46,693
  • 16
  • 125
  • 127
Sahith Kurapati
  • 1,617
  • 10
  • 14
0

You'll need to install the latest master branch of zipline. You can do that by:

pip install zipline
fcdt
  • 2,371
  • 5
  • 14
  • 26