IPywidgets, interactive

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)·Jan 31

from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsdef f(x):
return xinteract(f, x=10);interactive(children=(IntSlider(value=10, description='x', max=30, min=-10), Output()), _dom_classes=('widget-…interact(f, x=True);interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))interact(f, x='Hi there!');interactive(children=(Text(value='Hi there!', description='x'), Output()), _dom_classes=('widget-interact',))@interact(x=True, y=1.0)
def g(x, y):
return (x, y)interactive(children=(Checkbox(value=True, description='x'), FloatSlider(value=1.0, description='y', max=3.0, …interact(f, x=['apples','oranges']);interactive(children=(Dropdown(description='x', options=('apples', 'oranges'), value='apples'), Output()), _do…from IPython.display import display
def f(a, b):
display(a + b)
return a+bw = interactive(f, a=10, b=20)type(w)ipywidgets.widgets.interaction.interactivew.children(IntSlider(value=10, description='a', max=30, min=-10),
IntSlider(value=20, description='b', max=60, min=-20),
Output())display(w)interactive(children=(IntSlider(value=10, description='a', max=30, min=-10), IntSlider(value=20, description='…

Get Justetc Social Services (non-profit)'s stories in your inbox

You cannot subscribe to yourself

More from Justetc Social Services (non-profit)

All proceeds from Medium will go to Justetc Social Services ( non-profit). Justetc Social Services provides services in the Training and Education Areas.

Published in Health System Performance·Jan 31

from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsdef f(x):
return xinteract(f, x=10);interactive(children=(IntSlider(value=10, description='x', max=30, min=-10), Output()), _dom_classes=('widget-…interact(f, x=True)…

Read more in Health System Performance · 1 min read


Published in Health System Performance·Jan 31

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsaccess_to_care = pd.read_excel('../data/access-to-care.xls')
access_to_care.head()
png
# find all indicators
access_to_care.set_index(['Indicator'])
indicators = pd.Index(access_to_care['Indicator']).unique()

# find all years
years = access_to_care['Data year'].dropna().unique()
indicators[0], years('Inability to Pay for Medical Bills',
array(['2016', 2016, 'Not applicable', '2015', '2013'], dtype=object))# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2013, 2015, 2016, 2016]plt.rcParams['figure.figsize'] = [10, 10]
def plot_access_to_care(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]
if ( year > 1 ):
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == aYear) ]
ax.scatter(indicator_data['Data …

Read more in Health System Performance · 5 min read


Published in Health System Performance·Jan 31

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetshealth_status = pd.read_excel('../data/health-status.xls')
health_status.head()
png
health_status.set_index(['Indicator'])
#health_status.loc[health_status['Cancer Mortality (F)']]
#health_status.index.unique()
indicators = pd.Index(health_status['Indicator']).unique()
years = health_status['Data year'].unique()
indicators[0], years[0]('Cancer Mortality (F)', '2013')cancer_mortality_2013 = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] == years[0]) ]
cancer_mortality = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] != 2012) ]
cancer_mortality

Read more in Health System Performance · 4 min read


Published in Health System Performance·Jan 31

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetshealth_status = pd.read_excel('../data/health-status.xls')
health_status.head()
png
# find all indicators
health_status.set_index(['Indicator'])
indicators = pd.Index(health_status['Indicator']).unique()

# find all years
years = health_status['Data year'].unique()
indicators[0], years[0]('Cancer Mortality (F)', '2013')# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2012, 2013, 2013, 2014, 2014, 2015, 2015]plt.rcParams['figure.figsize'] = [10, 10]
def plot_health_status(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == aYear) ]
ax.scatter(indicator_data['Data …

Read more in Health System Performance · 5 min read


Published in Health System Performance·Jan 31

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsnon_med_determinants = pd.read_excel('../data/non-med-determinants.xls')
non_med_determinants.head()
png
# find all indicators
non_med_determinants.set_index(['Indicator'])
indicators = pd.Index(non_med_determinants['Indicator']).unique()

# find all years
years = non_med_determinants['Data year'].dropna().unique()
indicators[0], years('Alcohol Consumption: Adults',
array(['2014', '2015', '2013', 2015, 'Not applicable', '2016'],
dtype=object))# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2013, 2014, 2015, 2015, 2016]plt.rcParams['figure.figsize'] = [10, 10]
def plot_non_med_determinants(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == aYear) ]
ax.scatter(indicator_data['Data …

Read more in Health System Performance · 5 min read