In [ ]:
import hmis
import plotly
plotly.offline.init_notebook_mode()
import matplotlib.pylab as plt
%matplotlib notebook
import folium
import time as time
In [ ]:
# The name of the dictionary file that must be read in.
filename = '../test_data/hmis_test_data.pkl'
# Pull out the information on all the people
people = hmis.read_dictionary_file(filename)
In [ ]:
# The data are stored as a list of python dictionaries.
print("There is information about %d people" % (len(people)))
print(" ")
print(people[4])
print(" ")
hmis.pretty_print(people[4], dump_all=True)
print(" ")
hmis.pretty_print(people[4])
In [ ]:
# Pull out a subset of people based on their ages.
# This function returns a list of dicionaries, just like the original list of people.
# The range of ages to be analyzed.
lo=10
hi=40
ppl_based_on_age = hmis.select_by_age(people,lo=lo,hi=hi)
hmis.pretty_print(ppl_based_on_age)
In [ ]:
# Plot a time series for these individuals and save the image as a .png
# Use the matplotlib plotting library and save the image
image_name = "Ages10to40_plotly.png"
plt.figure(figsize=(9,5))
hmis.plot_time_series(ppl_based_on_age, image_name, plotly=False)
In [ ]:
# Plot a time series for these individuals and save the image as a .png
# Use the plotly plotting library which is more interacive, but does not allow us to
# save the image.
hmis.plot_time_series(ppl_based_on_age, plotly=True)
In [ ]:
# Get the list of dictionaries of the individuals.
num_of_programs = 1
ppl_based_on_programs = hmis.select_by_number_of_programs(people,num_of_programs)
#print(ppl_based_on_programs)
In [ ]:
# Taking the individuals from the previous selection, and plotting their time series.
plt.figure(figsize=(9,5))
hmis.plot_time_series(ppl_based_on_programs, plotly=False)
In [ ]: