Ошибка подключения: («Соединение прервано.», Ошибка подключения(10054, «Существующее соединение было принудительно закрыто удаленным хостом», Нет, 10054, Нет))

#python #data-science #latitude-longitude #geocode

Вопрос:

Я пытаюсь сгенерировать данные CensusGeocode и добавить их в качестве нового столбца в фрейм данных, используя уже существующие столбцы данных о долготе и широте. Я продолжаю получать сообщение об ошибке подключения. Не уверен, где я ошибаюсь. Помогите мне преодолеть эту ошибку.

 import censusgeocode as cg 
df123['StartGeocode'] = cg.coordinates(x=df123['StartLongitude'], y=df123['StartLatitude']) 
df123['EndGeocode'] = cg.coordinates(x=df123['EndLongitude'], y=df123['EndLatitude'])
 

Получил приведенную ниже ошибку подключения после выполнения приведенного выше кода.

 ---------------------------------------------------------------------------
ConnectionResetError                      Traceback (most recent call last)
~Anaconda3libsite-packagesurllib3connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    698             # Make the request on the httplib connection object.
--> 699             httplib_response = self._make_request(
    700                 conn,

~Anaconda3libsite-packagesurllib3connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    393             else:
--> 394                 conn.request(method, url, **httplib_request_kw)
    395 

~Anaconda3libsite-packagesurllib3connection.py in request(self, method, url, body, headers)
    233             headers["User-Agent"] = _get_default_user_agent()
--> 234         super(HTTPConnection, self).request(method, url, body=body, headers=headers)
    235 

~Anaconda3libhttpclient.py in request(self, method, url, body, headers, encode_chunked)
   1254         """Send a complete request to the server."""
-> 1255         self._send_request(method, url, body, headers, encode_chunked)
   1256 

~Anaconda3libhttpclient.py in _send_request(self, method, url, body, headers, encode_chunked)
   1300             body = _encode(body, 'body')
-> 1301         self.endheaders(body, encode_chunked=encode_chunked)
   1302 

~Anaconda3libhttpclient.py in endheaders(self, message_body, encode_chunked)
   1249             raise CannotSendHeader()
-> 1250         self._send_output(message_body, encode_chunked=encode_chunked)
   1251 

~Anaconda3libhttpclient.py in _send_output(self, message_body, encode_chunked)
   1009         del self._buffer[:]
-> 1010         self.send(msg)
   1011 

~Anaconda3libhttpclient.py in send(self, data)
    970         try:
--> 971             self.sock.sendall(data)
    972         except TypeError:

~Anaconda3libssl.py in sendall(self, data, flags)
   1203                 while count < amount:
-> 1204                     v = self.send(byte_view[count:])
   1205                     count  = v

~Anaconda3libssl.py in send(self, data, flags)
   1172                     self.__class__)
-> 1173             return self._sslobj.write(data)
   1174         else:

ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

ProtocolError                             Traceback (most recent call last)
~Anaconda3libsite-packagesrequestsadapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    438             if not chunked:
--> 439                 resp = conn.urlopen(
    440                     method=request.method,

~Anaconda3libsite-packagesurllib3connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    754 
--> 755             retries = retries.increment(
    756                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]

~Anaconda3libsite-packagesurllib3utilretry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    531             if read is False or not self._is_method_retryable(method):
--> 532                 raise six.reraise(type(error), error, _stacktrace)
    533             elif read is not None:

~Anaconda3libsite-packagesurllib3packagessix.py in reraise(tp, value, tb)
    733             if value.__traceback__ is not tb:
--> 734                 raise value.with_traceback(tb)
    735             raise value

~Anaconda3libsite-packagesurllib3connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    698             # Make the request on the httplib connection object.
--> 699             httplib_response = self._make_request(
    700                 conn,

~Anaconda3libsite-packagesurllib3connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    393             else:
--> 394                 conn.request(method, url, **httplib_request_kw)
    395 

~Anaconda3libsite-packagesurllib3connection.py in request(self, method, url, body, headers)
    233             headers["User-Agent"] = _get_default_user_agent()
--> 234         super(HTTPConnection, self).request(method, url, body=body, headers=headers)
    235 

~Anaconda3libhttpclient.py in request(self, method, url, body, headers, encode_chunked)
   1254         """Send a complete request to the server."""
-> 1255         self._send_request(method, url, body, headers, encode_chunked)
   1256 

~Anaconda3libhttpclient.py in _send_request(self, method, url, body, headers, encode_chunked)
   1300             body = _encode(body, 'body')
-> 1301         self.endheaders(body, encode_chunked=encode_chunked)
   1302 

~Anaconda3libhttpclient.py in endheaders(self, message_body, encode_chunked)
   1249             raise CannotSendHeader()
-> 1250         self._send_output(message_body, encode_chunked=encode_chunked)
   1251 

~Anaconda3libhttpclient.py in _send_output(self, message_body, encode_chunked)
   1009         del self._buffer[:]
-> 1010         self.send(msg)
   1011 

~Anaconda3libhttpclient.py in send(self, data)
    970         try:
--> 971             self.sock.sendall(data)
    972         except TypeError:

~Anaconda3libssl.py in sendall(self, data, flags)
   1203                 while count < amount:
-> 1204                     v = self.send(byte_view[count:])
   1205                     count  = v

~Anaconda3libssl.py in send(self, data, flags)
   1172                     self.__class__)
-> 1173             return self._sslobj.write(data)
   1174         else:

ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
<ipython-input-77-ace0ee7007f7> in <module>
      1 import censusgeocode as cg
----> 2 df123['StartGeocode'] = cg.coordinates(x=df123['StartLongitude'], y=df123['StartLatitude'])
      3 df123['EndGeocode'] = cg.coordinates(x=df123['EndLongitude'], y=df123['EndLatitude'])

~Anaconda3libsite-packagescensusgeocodecensusgeocode.py in coordinates(self, x, y, **kwargs)
    119         fields = {"x": x, "y": y}
    120 
--> 121         return self._fetch("coordinates", fields, **kwargs)
    122 
    123     def address(self, street, city=None, state=None, zipcode=None, **kwargs):

~Anaconda3libsite-packagescensusgeocodecensusgeocode.py in _fetch(self, searchtype, fields, **kwargs)
    112 
    113         except RequestException as err:
--> 114             raise err
    115 
    116     def coordinates(self, x, y, **kwargs):

~Anaconda3libsite-packagescensusgeocodecensusgeocode.py in _fetch(self, searchtype, fields, **kwargs)
     98 
     99         try:
--> 100             with requests.get(url, params=fields, timeout=kwargs.get("timeout")) as r:
    101                 content = r.json()
    102                 if "addressMatches" in content.get("result", {}):

~Anaconda3libsite-packagesrequestsapi.py in get(url, params, **kwargs)
     74 
     75     kwargs.setdefault('allow_redirects', True)
---> 76     return request('get', url, params=params, **kwargs)
     77 
     78 

~Anaconda3libsite-packagesrequestsapi.py in request(method, url, **kwargs)
     59     # cases, and look like a memory leak in others.
     60     with sessions.Session() as session:
---> 61         return session.request(method=method, url=url, **kwargs)
     62 
     63 

~Anaconda3libsite-packagesrequestssessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    540         }
    541         send_kwargs.update(settings)
--> 542         resp = self.send(prep, **send_kwargs)
    543 
    544         return resp

~Anaconda3libsite-packagesrequestssessions.py in send(self, request, **kwargs)
    653 
    654         # Send the request
--> 655         r = adapter.send(request, **kwargs)
    656 
    657         # Total elapsed time of the request (approximately)

~Anaconda3libsite-packagesrequestsadapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    496 
    497         except (ProtocolError, socket.error) as err:
--> 498             raise ConnectionError(err, request=request)
    499 
    500         except MaxRetryError as e:

ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))