# download modsim.py if necessaryfromos.pathimportbasename,existsdefdownload(url):filename=basename(url)ifnotexists(filename):fromurllib.requestimporturlretrievelocal,_=urlretrieve(url,filename)print('Downloaded '+local)download('https://raw.githubusercontent.com/AllenDowney/'+'ModSimPy/master/data/World_population_estimates.html')
In [13]:
%load_extnb_black
In [12]:
importpandasaspdimportrequests# Fetch the data.df=pd.read_csv("https://ourworldindata.org/grapher/population.csv?v=1&csvType=filtered&useColumnShortNames=true&time=1700..latest&country=~OWID_WRL",storage_options={'User-Agent':'Our World In Data data fetch/1.0'})# Fetch the metadatametadata=requests.get("https://ourworldindata.org/grapher/population.metadata.json?v=1&csvType=filtered&useColumnShortNames=true&time=1700..latest&country=~OWID_WRL").json()