#Import requests to get data from the web.
import requests
#Use StringIO for CSV data.
from io import StringIO
#The URL of the data.
url = "http://elections.huffingtonpost.com/pollster/2012-general-election-romney-vs-obama.csv"
#Use requests to get the data as text.
source = requests.get(url).text
#Use StringIO to prevent pandas errors.
poll_data = StringIO(source)
poll_df = pd.read_csv(poll_data)
Recommended Posts