In [2]:
#SKIP_COMPARE_OUTPUT
import pixiedust


Pixiedust database opened successfully
Pixiedust version 1.1.18
Warning: You are not running the latest version of PixieDust. Current is 1.1.18, Latest is 1.1.17
Please copy and run the following command in a new cell to upgrade: !pip install --user --upgrade pixiedust
Please restart kernel after upgrading.

In [3]:
from bokeh.sampledata.olympics2014 import data
from pandas.io.json import json_normalize

df = json_normalize(data['data'])

# try:
#     from bkcharts.utils import df_from_json
# except ImportError:
#     from bokeh.charts.utils import df_from_json

# # utilize utility to make it easy to get json/dict data converted to a dataframe
# df = df_from_json(data)

# filter by countries with at least one medal and sort by total medals
df = df[df['medals.total'] > 0]
df = df.sort_values("medals.total", ascending=False)

# show top 5
df.head(5)


Out[3]:
abbr medals.bronze medals.gold medals.silver medals.total name
65 RUS 7 6 8 21 Russian Fed.
81 USA 10 6 4 20 United States
54 NLD 8 6 6 20 Netherlands
56 NOR 7 8 4 19 Norway
13 CAN 4 4 8 16 Canada

In [ ]:
#SKIP_COMPARE_OUTPUT
display(df, no_gen_tests='true')


Hey, there's something awesome here! To see it, open this notebook outside GitHub, in a viewer like Jupyter
Field types:
abbr: object
medals.bronze: int64
medals.gold: int64
medals.silver: int64
medals.total: int64
name: object
Showing 26 of 26 rows
abbr
medals.bronze
medals.gold
medals.silver
medals.total
name
abbr
medals.bronze
medals.gold
medals.silver
medals.total
name
RUS 7 6 8 21 Russian Fed.
USA 10 6 4 20 United States
NLD 8 6 6 20 Netherlands
NOR 7 8 4 19 Norway
CAN 4 4 8 16 Canada
DEU 4 8 3 15 Germany
CHE 1 6 3 10 Switzerland
FRA 5 3 2 10 France
SWE 2 2 5 9 Sweden
AUT 1 2 6 9 Austria
SVN 4 2 1 7 Slovenia
JPN 2 1 4 7 Japan
CHN 1 3 2 6 China
CZE 2 1 3 6 Czech Republic
ITA 4 0 2 6 Italy
BLR 1 5 0 6 Belarus
POL 0 4 0 4 Poland
KOR 1 2 1 4 Korea
AUS 1 0 2 3 Australia
LVA 2 0 1 3 Latvia
FIN 0 0 3 3 Finland
GBR 1 1 0 2 Great Britain
SVK 0 1 0 1 Slovakia
HRV 0 0 1 1 Croatia
UKR 1 0 0 1 Ukraine
KAZ 1 0 0 1 Kazakhstan

In [15]:
display(df,cell_id='8a2e83d6eb8546df875cc18864d4c964',nostore_pixiedust='true',aggregation='SUM',binsize='10',chartsize='96',charttype='stacked',handlerId='tableView',keyFields='name',lineChartType='subplots',rendererId='bokeh',rowCount='100',showLegend='true',valueFields='medals.total',nostore_cw='1098',nostore_vh='1014',org_params='gen_tests,nostore_pixiedust',nostore_bokeh='true',prefix='318deeec',color='abbr')


Field types:
abbr: object
medals.bronze: int64
medals.gold: int64
medals.silver: int64
medals.total: int64
name: object
Showing 26 of 26 rows
abbr
medals.bronze
medals.gold
medals.silver
medals.total
name
abbr
medals.bronze
medals.gold
medals.silver
medals.total
name
RUS 7 6 8 21 Russian Fed.
USA 10 6 4 20 United States
NLD 8 6 6 20 Netherlands
NOR 7 8 4 19 Norway
CAN 4 4 8 16 Canada
DEU 4 8 3 15 Germany
CHE 1 6 3 10 Switzerland
FRA 5 3 2 10 France
SWE 2 2 5 9 Sweden
AUT 1 2 6 9 Austria
SVN 4 2 1 7 Slovenia
JPN 2 1 4 7 Japan
CHN 1 3 2 6 China
CZE 2 1 3 6 Czech Republic
ITA 4 0 2 6 Italy
BLR 1 5 0 6 Belarus
POL 0 4 0 4 Poland
KOR 1 2 1 4 Korea
AUS 1 0 2 3 Australia
LVA 2 0 1 3 Latvia
FIN 0 0 3 3 Finland
GBR 1 1 0 2 Great Britain
SVK 0 1 0 1 Slovakia
HRV 0 0 1 1 Croatia
UKR 1 0 0 1 Ukraine
KAZ 1 0 0 1 Kazakhstan
Table View Options

In [6]:
display(df,cell_id='8a2e83d6eb8546df875cc18864d4c964',nostore_pixiedust='true',aggregation='SUM',binsize='10',chartsize='96',charttype='stacked',handlerId='histogram',keyFields='name',lineChartType='subplots',rendererId='bokeh',rowCount='100',showLegend='true',valueFields='medals.total',nostore_cw='1098',nostore_vh='1014',org_params='gen_tests,nostore_pixiedust',nostore_bokeh='true',prefix='2fe811d5')


Histogram Options

In [9]:
display(df,cell_id='8a2e83d6eb8546df875cc18864d4c964',nostore_pixiedust='true',aggregation='SUM',binsize='10',chartsize='96',charttype='stacked',handlerId='scatterPlot',keyFields='medals.total',lineChartType='subplots',rendererId='bokeh',rowCount='100',showLegend='true',valueFields='medals.gold',nostore_vh='1014',org_params='gen_tests,nostore_pixiedust',nostore_bokeh='true',prefix='6103559e',color='abbr')


Scatter Plot Options

In [11]:
display(df,cell_id='8a2e83d6eb8546df875cc18864d4c964',nostore_pixiedust='true',aggregation='SUM',binsize='10',chartsize='96',charttype='stacked',handlerId='lineChart',keyFields='medals.silver',lineChartType='subplots',rendererId='bokeh',rowCount='100',showLegend='true',valueFields='medals.gold',nostore_vh='1014',org_params='gen_tests,nostore_pixiedust',nostore_bokeh='true',prefix='4f9da661',color='abbr')


Line Chart Options

In [13]:
display(df,cell_id='8a2e83d6eb8546df875cc18864d4c964',nostore_pixiedust='true',aggregation='SUM',binsize='10',chartsize='96',charttype='stacked',handlerId='barChart',keyFields='name',lineChartType='subplots',rendererId='bokeh',rowCount='100',showLegend='true',valueFields='medals.bronze,medals.silver,medals.gold',nostore_vh='1014',org_params='gen_tests,nostore_pixiedust',nostore_bokeh='true',prefix='8c0c4ba5',color='abbr')


Bar Chart Options

In [ ]:
#TARGET=NO_RUN
#GoogleReader has stopped working properly, disabling for now
#SKIP_COMPARE_OUTPUT
import pixiedust
import pandas as pd
from pandas_datareader import data as web
import datetime

start = datetime.date(2015,1,1)
end = datetime.date.today()

ibm = web.DataReader('IBM','google',start,end)
apple = web.DataReader('AAPL', 'google', start, end)
microsoft = web.DataReader('MSFT','google',start,end)

stocks = pd.DataFrame({"IBM": ibm['Close'],\
                      "AAPL": apple['Close'],\
                      "MSFT": microsoft['Close']})
stocks.reset_index(inplace=True)

In [ ]:
#TARGET=NO_RUN
#SKIP_COMPARE_OUTPUT
display(stocks, no_gen_tests='true', dateFormat='%m/%d')

In [ ]:
#TARGET=NO_RUN
display(stocks, dateFormat='%m/%d',cell_id='C30E350068A445F9821AA5DCB2278A35',rendererId='bokeh',handlerId='lineChart',keyFields='Date',valueFields='AAPL,IBM,MSFT',aggregation='AVG',rowCount='100',charttype='subplots',nostore_cw='1099',nostore_pixiedust='true',org_params='gen_tests,dateFormat',nostore_bokeh='true',prefix='cbd6265b')

In [ ]:
#TARGET=NO_RUN
display(stocks, dateFormat='%m/%d',cell_id='C30E350068A445F9821AA5DCB2278A35',rendererId='bokeh',handlerId='lineChart',keyFields='Date',valueFields='AAPL,IBM,MSFT',aggregation='AVG',rowCount='100',charttype='subplots',nostore_cw='1099',nostore_pixiedust='true',org_params='gen_tests,dateFormat',nostore_bokeh='true',prefix='540af31c')

In [ ]:
#TARGET=NO_RUN
display(stocks, dateFormat='%m/%d',cell_id='C30E350068A445F9821AA5DCB2278A35',rendererId='bokeh',handlerId='barChart',keyFields='Date',valueFields='AAPL,IBM,MSFT',aggregation='AVG',rowCount='100',charttype='subplots',nostore_cw='1099',nostore_pixiedust='true',org_params='gen_tests,dateFormat',nostore_bokeh='true',prefix='13dfaad0')

In [ ]:
#TARGET=NO_RUN
display(stocks, dateFormat='%m/%d',cell_id='C30E350068A445F9821AA5DCB2278A35',rendererId='bokeh',handlerId='barChart',keyFields='Date',valueFields='AAPL,IBM,MSFT',aggregation='AVG',rowCount='100',nostore_cw='1099',nostore_pixiedust='true',org_params='gen_tests,dateFormat',nostore_bokeh='true',prefix='1e1e8556')