I tried different solutions which I got through stack overflow but didn’t succeed.
import pandas as pd
import requests
url=“https://raw.githubusercontent.com/datasets/gdp/master/data/gdp.csv”
s=requests.get(url).content
c=pd.read_csv(s)
I get connection error here.
The error indicates that the IP address for the site is not being found. So something is going wrong with a DNS lookup where you are running the code. Without any further information on the environment where you are running the code, I can’t really help any further.
Country Name Country Code Year Value
0 Arab World ARB 1968 2.576068e+10
1 Arab World ARB 1969 2.843420e+10
2 Arab World ARB 1970 3.138550e+10
3 Arab World ARB 1971 3.642691e+10
4 Arab World ARB 1972 4.331606e+10
... ... ... ... ...
11502 Zimbabwe ZWE 2012 1.424249e+10
11503 Zimbabwe ZWE 2013 1.545177e+10
11504 Zimbabwe ZWE 2014 1.589105e+10
11505 Zimbabwe ZWE 2015 1.630467e+10
11506 Zimbabwe ZWE 2016 1.661996e+10
[11507 rows x 4 columns]
Hi, unfortunately this didn’t work as well, I tried to mention this code in my question also but I am not allowed to post more than 2 links. The error here is same ConnectionError: HTTPSConnectionPool(host=‘raw.githubusercontent.com’, port=443): Max retries exceeded with url: /datasets/gdp/master/data/gdp.csv (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x0000020CF5764088>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed’))
The issue isn’t your code, it is that there is something wrong with the network on the machine that is running the code. That machine is not getting an IP address for the URL to establish the connection. I need details of that machine in order to possibly help you further.
Is it local or is it a cloud service like repl.it? If it is local, what is the Operating System (Windows, Linux, or macOS)? From there I can then figure out how to troubleshoot the network.
If it doesn’t then it means your DNS server is not returning an answer. If that is the case, try changing your DNS server in network settings to Google’s public DNS server which is 8.8.8.8 and see if that works.
If it does return with a list of addresses, and Python is still not working, then something is blocking the python program from connecting and my recommendation then would be to use your browser to download the CSV file from the link, place it in the same place as the Python program and then just use pd.read_csv('gdp.csv')
checked for the command and it returned the below:
Server: UnKnown
Address: my local ip Name: raw.githubusercontent Addresses: ::
0.0.0.0
I have removed .com from the name since I am not allowed to post link here.
I will try changing the DNS server to Google’s public DNS server and try again.
Thanks a lot