In [1]:
#SKIP_COMPARE_OUTPUT
import pixiedust
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]:
In [ ]:
#SKIP_COMPARE_OUTPUT
display(df, no_gen_tests='true')
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')
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')
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')
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')
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')