In [60]:
import urllib.request
import pandas as pd
import numpy as np
import requests
from urllib.request import Request, urlopen
from pandas.io.json import json_normalize
loc = "London,uk"
weatherurl ='http://api.openweathermap.org/data/2.5/weather?q=' + loc + '?id=524901&APPID=b058d678cdbcdfdadaa17156d4a9a5fd'
data= requests.get(weatherurl)
#data.text
dataj=data.json()
temp=dataj['main']['temp_max']-273.15
objects = (loc, 'Max')
y_pos = np.arange(len(objects))
performance = [temp, 1]
plt.bar(y_pos, performance, align='center', alpha=0.5)
plt.xticks(y_pos, objects)
plt.ylabel('t')
plt.title('Temp in '+loc)
plt.show()
In [ ]:
# For the future more sophisiticated transformations - to DataFrame
#import json
# Finish request http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_json.html
#pd.read_json(data.json(),orient='records', typ="series" )
via google API