In [5]:
from urllib2 import urlopen
import json
r = urlopen(
'https://www.kimonolabs.com/api/ondemand/bun4ijbo?apikey=xpPjpOXhOop8Emwqk4wttVAD80BCdJp6'
'&kimpath3=2014&kimpath4=1'
).read()
In [6]:
rj = json.loads(r)['results']['collection1']
rj#{k:[d[k] for d in rj) for k in rj[0]}
Out[6]:
[{u'day': u'1',
u'p_day': u'716',
u'p_eve': u'717',
u't_day': u'-6',
u't_eve': u'-6',
u'wind_day': u'\u0421\u0417 2\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 2\u043c/\u0441'},
{u'day': u'2',
u'p_day': u'716',
u'p_eve': u'715',
u't_day': u'-4',
u't_eve': u'-5',
u'wind_day': u'\u0417 2\u043c/\u0441',
u'wind_eve': u'\u0417 2\u043c/\u0441'},
{u'day': u'3',
u'p_day': u'722',
u'p_eve': u'725',
u't_day': u'-18',
u't_eve': u'-22',
u'wind_day': u'\u0417 2\u043c/\u0441',
u'wind_eve': u'\u0417 2\u043c/\u0441'},
{u'day': u'4',
u'p_day': u'728',
u'p_eve': u'728',
u't_day': u'-21',
u't_eve': u'-21',
u'wind_day': u'\u0428',
u'wind_eve': u'\u0428'},
{u'day': u'5',
u'p_day': u'727',
u'p_eve': u'726',
u't_day': u'-14',
u't_eve': u'-13',
u'wind_day': u'\u0428',
u'wind_eve': u'\u0428'},
{u'day': u'6',
u'p_day': u'722',
u'p_eve': u'721',
u't_day': u'-13',
u't_eve': u'-13',
u'wind_day': u'\u0421\u0417 1\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 1\u043c/\u0441'},
{u'day': u'7',
u'p_day': u'716',
u'p_eve': u'717',
u't_day': u'-10',
u't_eve': u'-12',
u'wind_day': u'\u0421\u0417 2\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 2\u043c/\u0441'},
{u'day': u'8',
u'p_day': u'716',
u'p_eve': u'715',
u't_day': u'-9',
u't_eve': u'-8',
u'wind_day': u'\u0428',
u'wind_eve': u'\u0428'},
{u'day': u'9',
u'p_day': u'706',
u'p_eve': u'707',
u't_day': u'-1',
u't_eve': u'-2',
u'wind_day': u'\u0417 2\u043c/\u0441',
u'wind_eve': u'\u0417 2\u043c/\u0441'},
{u'day': u'10',
u'p_day': u'708',
u'p_eve': u'708',
u't_day': u'-3',
u't_eve': u'-5',
u'wind_day': u'\u042e\u0412 1\u043c/\u0441',
u'wind_eve': u'\u042e\u0412 1\u043c/\u0441'},
{u'day': u'11',
u'p_day': u'708',
u'p_eve': u'709',
u't_day': u'-5',
u't_eve': u'-6',
u'wind_day': u'\u0412 2\u043c/\u0441',
u'wind_eve': u'\u0412 2\u043c/\u0441'},
{u'day': u'12',
u'p_day': u'707',
u'p_eve': u'706',
u't_day': u'-2',
u't_eve': u'-3',
u'wind_day': u'\u042e\u0412 5\u043c/\u0441',
u'wind_eve': u'\u042e\u0412 5\u043c/\u0441'},
{u'day': u'13',
u'p_day': u'708',
u'p_eve': u'709',
u't_day': u'-3',
u't_eve': u'-3',
u'wind_day': u'\u0428',
u'wind_eve': u'\u0428'},
{u'day': u'14',
u'p_day': u'708',
u'p_eve': u'708',
u't_day': u'-3',
u't_eve': u'-6',
u'wind_day': u'\u042e\u0412 5\u043c/\u0441',
u'wind_eve': u'\u042e\u0412 5\u043c/\u0441'},
{u'day': u'15',
u'p_day': u'706',
u'p_eve': u'708',
u't_day': u'-6',
u't_eve': u'-6',
u'wind_day': u'\u0428',
u'wind_eve': u'\u0428'},
{u'day': u'16',
u'p_day': u'714',
u'p_eve': u'716',
u't_day': u'-8',
u't_eve': u'-10',
u'wind_day': u'\u0417 3\u043c/\u0441',
u'wind_eve': u'\u0417 3\u043c/\u0441'},
{u'day': u'17',
u'p_day': u'710',
u'p_eve': u'708',
u't_day': u'-10',
u't_eve': u'-11',
u'wind_day': u'\u042e\u0412 5\u043c/\u0441',
u'wind_eve': u'\u042e\u0412 5\u043c/\u0441'},
{u'day': u'18',
u'p_day': u'703',
u'p_eve': u'704',
u't_day': u'-10',
u't_eve': u'-15',
u'wind_day': u'\u0421\u0417 1\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 1\u043c/\u0441'},
{u'day': u'19',
u'p_day': u'708',
u'p_eve': u'707',
u't_day': u'-18',
u't_eve': u'-21',
u'wind_day': u'\u0428',
u'wind_eve': u'\u0428'},
{u'day': u'20',
u'p_day': u'705',
u'p_eve': u'707',
u't_day': u'-22',
u't_eve': u'-24',
u'wind_day': u'\u0421\u0417 1\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 1\u043c/\u0441'},
{u'day': u'21',
u'p_day': u'712',
u'p_eve': u'714',
u't_day': u'-18',
u't_eve': u'-15',
u'wind_day': u'\u0417 3\u043c/\u0441',
u'wind_eve': u'\u0417 3\u043c/\u0441'},
{u'day': u'22',
u'p_day': u'719',
u'p_eve': u'719',
u't_day': u'-12',
u't_eve': u'-15',
u'wind_day': u'\u0417 1\u043c/\u0441',
u'wind_eve': u'\u0417 1\u043c/\u0441'},
{u'day': u'23',
u'p_day': u'717',
u'p_eve': u'717',
u't_day': u'-15',
u't_eve': u'-16',
u'wind_day': u'\u0421\u0417 1\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 1\u043c/\u0441'},
{u'day': u'24',
u'p_day': u'717',
u'p_eve': u'718',
u't_day': u'-14',
u't_eve': u'-21',
u'wind_day': u'\u0428',
u'wind_eve': u'\u0428'},
{u'day': u'25',
u'p_day': u'718',
u'p_eve': u'718',
u't_day': u'-21',
u't_eve': u'-23',
u'wind_day': u'\u042e 3\u043c/\u0441',
u'wind_eve': u'\u042e 3\u043c/\u0441'},
{u'day': u'26',
u'p_day': u'713',
u'p_eve': u'712',
u't_day': u'-17',
u't_eve': u'-19',
u'wind_day': u'\u042e\u0412 2\u043c/\u0441',
u'wind_eve': u'\u042e\u0412 2\u043c/\u0441'},
{u'day': u'27',
u'p_day': u'712',
u'p_eve': u'713',
u't_day': u'-20',
u't_eve': u'-24',
u'wind_day': u'\u0421\u0417 1\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 1\u043c/\u0441'},
{u'day': u'28',
u'p_day': u'715',
u'p_eve': u'716',
u't_day': u'-24',
u't_eve': u'-26',
u'wind_day': u'\u0421\u0417 2\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 2\u043c/\u0441'},
{u'day': u'29',
u'p_day': u'720',
u'p_eve': u'722',
u't_day': u'-28',
u't_eve': u'-32',
u'wind_day': u'\u0417 2\u043c/\u0441',
u'wind_eve': u'\u0417 2\u043c/\u0441'},
{u'day': u'30',
u'p_day': u'726',
u'p_eve': u'727',
u't_day': u'-29',
u't_eve': u'-26',
u'wind_day': u'\u0421\u0417 1\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 1\u043c/\u0441'},
{u'day': u'31',
u'p_day': u'728',
u'p_eve': u'729',
u't_day': u'-19',
u't_eve': u'-22',
u'wind_day': u'\u0421\u0417 4\u043c/\u0441',
u'wind_eve': u'\u0421\u0417 4\u043c/\u0441'}]
In [9]:
import pandas as pd
df = pd.DataFrame.from_records(rj)
df['day'] = df['day'].apply(int)
df['p_day'] = df['p_day'].apply(int)
df['t_day'] = df['t_day'].apply(int)
df['p_eve'] = df['p_eve'].apply(int)
df['t_eve'] = df['t_eve'].apply(int)
df.dtypes
Out[9]:
day int64
p_day int64
p_eve int64
t_day int64
t_eve int64
wind_day object
wind_eve object
dtype: object
In [39]:
%matplotlib inline
import matplotlib.pyplot as plt
plt.figure(figsize=(20,10))
df['t_day'].plot()
Out[39]:
<matplotlib.axes._subplots.AxesSubplot at 0x7a955d0>
Content source: mihasK/pogoda
Similar notebooks: