synthpops.people.loaders module

Load data

get_country_aliases()[source]

Define aliases for countries with odd names in the data

map_entries(json, location)[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
show_locations(location=None, output=False)[source]

Print a list of available locations.

Parameters:
  • location (str) – if provided, only check if this location is in the list
  • output (bool) – whether to return the list (else print)

Examples:

sp.people.show_locations() # Print a list of valid locations
sp.people.show_locations('lithuania') # Check if Lithuania is a valid location
sp.people.show_locations('Viet-Nam') # Check if Viet-Nam is a valid location

New in version 1.10.0.

get_age_distribution(location=None)[source]

Load age distribution for a given country or countries.

Parameters:location (str or list) – name of the country or countries to load the age distribution for
Returns:Numpy array of age distributions, or dict if multiple locations
Return type:age_data (array)

New in version 1.10.0.

get_household_size(location=None)[source]

Load average household size distribution for a given country or countries.

Parameters:location (str or list) – name of the country or countries to load the age distribution for
Returns:Size of household, or dict if multiple locations
Return type:house_size (float)

New in version 1.10.0.