hmis package

Submodules

hmis.parsing module

hmis.parsing.create_dictionary_list(directory='~/hmis_data/', filenames=['Enrollment.csv', 'Exit.csv', 'Project.csv', 'Client.csv', 'Site.csv'], max_people=None)[source]

This function creates a list of all dictionaries in the enrollment file.

Args:

directory (string, optional): The directory where all of the HMIS files are stored. Defaults to ‘~/hmis_data/’.

filenames (string, optional): The name of the files to get information from. Defaults to None.

max_people (int, optional): For debugging. The maximum number of people you use to build the file. Defaults to None which reads in all people.

Returns:
individuals (list): This is a list of all the individual’s dictionaries.
hmis.parsing.get_pids(enrollment_data)[source]

This function returns the personal IDs of the individuals from the enrollment file.

Args:
enrollment_data (pandas Data Frame): Data from the enrollment file that has been already read in. The file should have been read in with Pandas so we are passing it in as a pandas.DataFrame.
Returns:
personalids (numpy array): All Personal IDs from the individuals in the enrollment file. The Personal ID is used to identify individuals.
hmis.parsing.project_types()[source]
hmis.parsing.read_dictionary_file(filename)[source]

This function returns the list of dictionaries that are in the inputted file.

Args:
filename (str): The file to be read in using pickle.
Return:
dictionary_list (list): List of the dictionaries in the file passed in.
hmis.parsing.read_in_data(directory='~/hmis_data/', filenames=['Enrollment.csv', 'Exit.csv', 'Project.csv', 'Client.csv', 'Site.csv'], verbose=False)[source]

This function reads all of the HMIS files inputted using pandas.

Args:

directory (string, optional): The directory where all of the HMIS files are stored. Defaults to ‘~/hmis_data/’.

filenames (list, optional): A list of the filenames from which we will be reading the data.
These files come from the standard HMIS data dump. Defaults to [‘Enrollment.csv’,’Exit.csv’,’Project.csv’,’Client.csv’,’Site.csv’].

verbose (bool, optional): If this is True, additional information is printed to the screen. Defaults to False.

Returns:

A dictionary containing the following pieces of information, with keys referenced by the original file names (e.g. Enrollment.csv –> Enrollment)

enrollment_data (Data Frame): All of the information from the enrollment file.

exit_data (Data Frame): All of the information from the exit file.

project_data (Data Frame): All of the information from the project file.

client_data (Data Frame): All of the information from the client file.

site_data (Data Frame): All of the information from the site file.

hmis.parsing.save_file(inds, filename)[source]

This function creates a file of the dictionaries that passed in.

Args:

inds (list): The list of dictionaries.

filename (string): The name of the file that the dictionaries will be saved as. This should be a .pkl file.

hmis.visualizing module

hmis.visualizing.get_plotting_style(ptype)[source]

This function gets the plotting styles depending on the program type.

Args:
ptype (string): The project type.
Returns:

color (string): The color of the program in RGB.

width (int): The width of the line of the program.

alpha (float): The opaque value of the program.

style (string): The marker style of the program.

hmis.visualizing.plot_program_locations(dictionaries, cluster=True, exploded=False)[source]

This function plots all of the program’s zip codes with the folium package.

Args:
dictionaries (list): The list of dictionaries that are going to be plotted.
Return:
map1 (Map): The map to be displayed in a Jupyter notebook.
hmis.visualizing.plot_time_series(inds, image_name=None, exploded_view=False, plotly=False)[source]

This function plots a time-series plot of the programs for the list of individuals.

Args:

inds (list): The list of dictionaries that are going to be plotted.

image_name (string): The name of the figure to be saved.

exploded_view (bool, optional): If True: each program for each individual will be plotted on the y-axis. If False: each individual will be plotted on a different point on the y-axis with multiple programs on one line. Defaulted to: False.

plotly (bool, optional): If True: this time-series plot will plot with plotly. This has a mouse-over feature that is useful for understanding the data that is visualized. If False: this time-series plot will be plotted with matplotlib. Defaulted to: False.

hmis.selection module

hmis.selection.get_additional_info(IDs, idtype='Personal', org_data=None, info=None)[source]

This function gets additional information on an individual, project, or an indiviuals entry into a project based on their PersonalID, ProjectID, or ProjectEntryID respectively.

Args:

IDs (list or string): The list of IDs as strings or a single ID.

idtype (string): ‘Personal’ or ‘Project’ or ‘ProjectEntry’ which tells the program what type of data to retrieve.

org_data: (dictionary of Panda data frames) This is the output of the read_in_data command.

info (list or string): This is a string or list of strings, where the strings are the headers of the Pandas dataframes and the information to be returned.

Return:
information (dictionary) This is a dictionary with the keys representing the IDs passed in and the values are dictionaries with those keys being the different pieces of information passed in with the info variable.
hmis.selection.select_by_age(master_dictionary, lo=0, hi=1000000000.0, date_to_calc_age=None)[source]

This function returns the dictionaries of the individuals within the age range.

Args:

master_dictionary (list): Full list of the dictionaries.

lo (int): The lower bound of the targeted age range. Defaults to: 0

hi (int): The upper bound of the targeted age range. Defaults to: 1e9

Returns:
dictionary_subset (list): The list of dictionaries of the individuals that are within the age range.
hmis.selection.select_by_number_of_programs(master_dictionary, num_of_programs)[source]

This function returns the dictionaries of the individuals that have at least the number of programs entered.

Args:

master_dictionary (list): Full list of the dictionaries.

num_of_programs (int): The lower number to how many programs an individual must have to be returned.

Returns:
dictionary_subset (list): The list of dictionaries of the individuals that have at least the number of programs inputted.
hmis.selection.select_by_program_type(master_dictionary, prog_type)[source]

This function returns the dictionaries of the individuals that have stayed at the inputted program type.

Args:

master_dictionary (list): Full list of the dictionaries.

prog_type (str): The type of prgram that the individual must have stayed at.

Returns:
dictionary_subset (list): The list of dictionaries of the individuals that have
hmis.selection.subset_from_dictionary(personal_IDs, full_dictionary, matching_key='Personal ID')[source]

This function gets the subset of dictionaries from the personal IDs that are passed in.

Args:

personal_IDs (array): The list of personal IDs to get the dictionaries.

full_dictionary (list): The full list of dictionaries that has been made.

matching_key (string): The key that determines the cross referencing between the files. Defaults to: ‘Personal ID’

Returns:
inds (list): The subset of dictionaries with the personal IDs inputted.

hmis.general module

hmis.general.calc_age(birthdate, date_to_calc_age=None)[source]

This function calculates the age of an individual using their birthdate.

Args:

birthdate (datetime.datetime): The birthday of the individual.

age_at_date (datetime.datetime or string): The date on which you want to know the individual’s age.

Returns:
age (int): The age of the individual.
hmis.general.calc_average_age_by_year(ppl)[source]

Calculates the average age split up by year. The years are split up from 2013, 2014, 2015, 2016 and earlier than 2013. This is primarily an example of how a semi-standard analysis could be added to the libraries in this hmis module.

Args:
ppl (list): The list of dictionaries of the individuals to be analyzed.
Return:
average_age_list (list): The list of average ages, starting with 2013, 2014, 2015, and 2016 and then the average age for the years before 2013.
hmis.general.convert_to_coordinates(zip_code)[source]

Converts the list of zip codes to latitude and ongitude coordinates.

Args:
zip_code (string): The zip code to be converted.
Return:

location.latitude (float): The latitude corrdinate of the zip code.

location.longitude (float): The longitude coordinate of the zip code.

hmis.general.get_date_from_string(datestring)[source]

This function converts the date as a string to a datetime object.

Args:
datestring (string): the date as a string.
Returns:
date (datetime object): the date as a datetime object.
hmis.general.pretty_print(inds, dump_all=False)[source]

This function prints the dictionaries passed to it in a way that is very easy to read.

Args:
inds (list): The list of dictionaries that dump_all (bool): If True, this shows the category name. If False, this function just prints out the numerical values without the decription.

Module contents