In [1]:
#SKIP_COMPARE_OUTPUT
import pixiedust


Pixiedust database opened successfully
Pixiedust version 1.1.14

In [2]:
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[2]:
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 [4]:
display(df,showLegend='true',no_margin='true',handlerId='barChart',org_params='gen_tests,nostore_pixiedust',prefix='8fc72221',aggregation='SUM',filter='{}',rowCount='100',nostore_vh='1098',valueFields='medals.gold,medals.silver,medals.bronze',rendererId='bokeh',keyFields='abbr',cell_id='AC4F51AFEF57444C9CCBD551F0C6C2D8',nostore_bokeh='true',nostore_pixiedust='true')


Bar Chart Options

In [5]:
# medals count for United States and Canada
display(df,showLegend='true',no_margin='true',handlerId='barChart',org_params='gen_tests,nostore_pixiedust',prefix='75fa131c',aggregation='SUM',filter='{"regex": "false","field": "abbr","case_matter": "true","value": "USA|CAN","constraint": "None"}',rowCount='100',nostore_vh='1098',valueFields='medals.gold,medals.silver,medals.bronze',rendererId='bokeh',keyFields='abbr',cell_id='AC4F51AFEF57444C9CCBD551F0C6C2D8',nostore_bokeh='true',nostore_pixiedust='true')


Bar Chart Options

In [6]:
# medals count for countries with more than 19 total medals
display(df,showLegend='true',no_margin='true',handlerId='barChart',org_params='gen_tests,nostore_pixiedust',prefix='5e14e0e8',aggregation='SUM',filter='{"regex": "False","field": "medals.total","case_matter": "False","value": "19","constraint": "greater_than"}',rowCount='100',nostore_vh='1098',valueFields='medals.gold,medals.silver,medals.bronze',rendererId='bokeh',keyFields='abbr',cell_id='AC4F51AFEF57444C9CCBD551F0C6C2D8',nostore_bokeh='true',nostore_pixiedust='true')


Bar Chart Options

In [7]:
display(df,cell_id='AC4F51AFEF57444C9CCBD551F0C6C2D8',nostore_pixiedust='true',showLegend='true',no_margin='true',handlerId='barChart',aggregation='SUM',filter='{}',rowCount='100',valueFields='medals.total',rendererId='matplotlib',keyFields='abbr',sortby='Values DESC',nostore_cw='1098',nostore_vh='1098',org_params='gen_tests,nostore_pixiedust',nostore_bokeh='true',prefix='11fa0564')


Bar Chart Options

In [8]:
# countries with most medals but no gold medals
display(df,showLegend='true',no_margin='true',handlerId='barChart',org_params='gen_tests,nostore_pixiedust',prefix='adf92c2c',aggregation='SUM',filter='{"regex": "False","field": "medals.gold","case_matter": "False","value": "1","constraint": "less_than"}',rowCount='100',nostore_vh='1098',valueFields='medals.total',rendererId='matplotlib',keyFields='abbr',sortby='Values DESC',cell_id='AC4F51AFEF57444C9CCBD551F0C6C2D8',nostore_bokeh='true',nostore_pixiedust='true')


Bar Chart Options