hpvsim.data.loaders module¶
Load data
- map_entries(json, location, df=None, wb=False)[source]¶
Find a match between the JSON file and the provided location(s).
- Parameters:
json (list or dict) – the data being loaded
location (list or str) – the list of locations to pull from
- get_age_distribution(location=None, year=None, total_pop_file=None)[source]¶
Load age distribution for a given country or countries.
- Parameters:
location (str) – name of the country to load the age distribution for
year (int) – year to load the age distribution for
total_pop_file (str) – optional filepath to save total population size for every year
- Returns:
Numpy array of age distributions, or dict if multiple locations
- Return type:
age_data (array)
- get_age_distribution_over_time(location=None)[source]¶
Load age distribution for a given country or countries over time.
- Parameters:
location (str) – name of the country to load the age distribution for
- Returns:
Pandas dataframe with age distribution over time
- Return type:
age_data (dataframe)
- get_total_pop(location=None)[source]¶
Load total population for a given country or countries.
- Parameters:
location (str or list) – name of the country to load the total population for
- Returns:
Dataframe of year and pop_size columns
- Return type:
pop_data (dataframe)
- get_death_rates(location=None, by_sex=True, overall=False)[source]¶
Load death rates for a given country or countries.
- Parameters:
location (str or list) – name of the country or countries to load the age distribution for
by_sex (bool) – whether to rates by sex
overall (bool) – whether to load total rate
- Returns:
death rates by age and sex
- Return type:
death_rates (dict)
- get_birth_rates(location=None)[source]¶
Load crude birth rates for a given country
- Parameters:
location (str or list) – name of the country to load the birth rates for
- Returns:
years and crude birth rates
- Return type:
birth_rates (arr)
- get_life_expectancy(location=None, by_sex=True, overall=False)[source]¶
Load life expectancy by age for a given country or countries.
- Parameters:
location (str or list) – name of the country or countries to load the age distribution for
by_sex (bool) – whether to rates by sex
overall (bool) – whether to load total rate
- Returns:
life expectancy by age and sex
- Return type:
life_expectancy (dict)