In [1]:
import urllib2, argparse
In [31]:
from bs4 import BeautifulSoup
In [32]:
import pandas as pd
In [33]:
link = "https://www.globalpolicy.org/component/content/article/109/27519.html"
In [34]:
from week_7_code import *
I used a define function that can be used on any url to load the link into python.
In [35]:
download_link = url_download(link)
After using the request i've prepared a function to parse the site, find the table and return the values, index and title into python as a tuple.
In [36]:
table_data = parse_site(download_link)
In [37]:
talbe_inf = zip(table_data[1], [n[0] for n in table_data[2]], [n[1] for n in table_data[2]])
In order to create a DataFrame i've ziped the cells in the data with the year columns so that it can be further used in the next process of instantiating the DataFrame in the variable table.
In [43]:
table = pd.DataFrame(data = talbe_inf, columns = list(table_data[0]), index = table_data[1])
In [44]:
print table