Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
titanic from Seaborn
#1
Hello everyone,

I'm beginner in Python, i'd like to use titanic dataset from Seaborn.
The code
import seaborn as sns
titanic = sns.load_dataset('titanic')
I have this error
Error:
--------------------------------------------------------------------------- gaierror Traceback (most recent call last) ~\Anaconda3\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args) 1349 try: -> 1350 h.request(req.get_method(), req.selector, req.data, headers, 1351 encode_chunked=req.has_header('Transfer-encoding')) ~\Anaconda3\lib\http\client.py in request(self, method, url, body, headers, encode_chunked) 1239 """Send a complete request to the server.""" -> 1240 self._send_request(method, url, body, headers, encode_chunked) 1241 ~\Anaconda3\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked) 1285 body = _encode(body, 'body') -> 1286 self.endheaders(body, encode_chunked=encode_chunked) 1287 ~\Anaconda3\lib\http\client.py in endheaders(self, message_body, encode_chunked) 1234 raise CannotSendHeader() -> 1235 self._send_output(message_body, encode_chunked=encode_chunked) 1236 ~\Anaconda3\lib\http\client.py in _send_output(self, message_body, encode_chunked) 1005 del self._buffer[:] -> 1006 self.send(msg) 1007 ~\Anaconda3\lib\http\client.py in send(self, data) 945 if self.auto_open: --> 946 self.connect() 947 else: ~\Anaconda3\lib\http\client.py in connect(self) 1401 -> 1402 super().connect() 1403 ~\Anaconda3\lib\http\client.py in connect(self) 916 """Connect to the host and port specified in __init__.""" --> 917 self.sock = self._create_connection( 918 (self.host,self.port), self.timeout, self.source_address) ~\Anaconda3\lib\socket.py in create_connection(address, timeout, source_address) 786 err = None --> 787 for res in getaddrinfo(host, port, 0, SOCK_STREAM): 788 af, socktype, proto, canonname, sa = res ~\Anaconda3\lib\socket.py in getaddrinfo(host, port, family, type, proto, flags) 917 addrlist = [] --> 918 for res in _socket.getaddrinfo(host, port, family, type, proto, flags): 919 af, socktype, proto, canonname, sa = res gaierror: [Errno 11004] getaddrinfo failed During handling of the above exception, another exception occurred: URLError Traceback (most recent call last) <ipython-input-3-e3b2d17e7451> in <module> 1 import seaborn as sns ----> 2 titanic = sns.load_dataset('titanic') ~\Anaconda3\lib\site-packages\seaborn\utils.py in load_dataset(name, cache, data_home, **kws) 447 os.path.basename(full_path)) 448 if not os.path.exists(cache_path): --> 449 urlretrieve(full_path, cache_path) 450 full_path = cache_path 451 ~\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) 523 524 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) --> 525 response = self._open(req, data) 526 527 # post-process response ~\Anaconda3\lib\urllib\request.py in _open(self, req, data) 540 541 protocol = req.type --> 542 result = self._call_chain(self.handle_open, protocol, protocol + 543 '_open', req) 544 if result: ~\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 500 for handler in handlers: 501 func = getattr(handler, meth_name) --> 502 result = func(*args) 503 if result is not None: 504 return result ~\Anaconda3\lib\urllib\request.py in https_open(self, req) 1391 1392 def https_open(self, req): -> 1393 return self.do_open(http.client.HTTPSConnection, req, 1394 context=self._context, check_hostname=self._check_hostname) 1395 ~\Anaconda3\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args) 1351 encode_chunked=req.has_header('Transfer-encoding')) 1352 except OSError as err: # timeout error -> 1353 raise URLError(err) 1354 r = h.getresponse() 1355 except: URLError: <urlopen error [Errno 11004] getaddrinfo failed>
Can you help me please?
Reply
#2
try
titanic = sns.load_dataset('titanic.csv')


No, that doesn't work.
Your code should work - it does for me. Do you have internet connection, are you behind proxy?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thank you for your reply.

Yes, i have connection but i'm working with my professional pc. Do you think this is the problem?
Reply
#4
it's definitely a problem with your connection, not the code per se.
but it's difficult to identify the cause remotely.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to loop through code to plot seaborn line plots across multiple subplots eyavuz21 0 1,722 Dec-05-2022, 10:46 AM
Last Post: eyavuz21
  How to plot seaborn heatmap on top of a background circle SriRajesh 0 1,455 Jul-09-2022, 04:00 AM
Last Post: SriRajesh
  Installing and Using Seaborn Led_Zeppelin 4 2,624 Jun-07-2022, 09:44 PM
Last Post: snippsat
  seaborn scatterplot npiatti 1 1,915 Mar-03-2020, 01:54 PM
Last Post: scidam
  y-axis on seaborn heatmap not aligned properly amjass12 0 2,858 Oct-01-2019, 10:37 AM
Last Post: amjass12
  How to manually define color bar scale in seaborn heatmap SriRajesh 3 18,426 Sep-08-2019, 11:12 AM
Last Post: RudraMohan
  How to plot multiple scatter plots in seaborn vikola 2 6,543 Jul-14-2019, 10:30 AM
Last Post: vikola
  help for Kaggle Titanic Set fill the missing Age by median age of Pclass and Sex Parthasarathi009 2 6,194 Nov-21-2018, 06:50 PM
Last Post: Parthasarathi009

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020