data.loaders
Load data
Functions
| Name | Description |
|---|---|
| get_age_distribution | Load age distribution for a given country or countries. |
| get_age_distribution_over_time | Load age distribution for a given country or countries over time. |
| get_birth_rates | Load crude birth rates for a given country |
| get_country_aliases | Define aliases for countries with odd names in the data |
| get_death_rates | Load death rates for a given country or countries. |
| get_total_pop | Load total population for a given country or countries. |
| map_entries | Find a match between the JSON file and the provided location(s). |
get_age_distribution
data.loaders.get_age_distribution(
location=None,
year=None,
total_pop_file=None,
age_datafile=None,
)Load age distribution for a given country or countries.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| location | str | name of the country to load the age distribution for | None |
| year | int | year to load the age distribution for | None |
| total_pop_file | str | optional filepath to save total population size for every year | None |
Returns
| Name | Type | Description |
|---|---|---|
| age_data | array | Numpy array of age distributions, or dict if multiple locations |
get_age_distribution_over_time
data.loaders.get_age_distribution_over_time(location=None, popage_datafile=None)Load age distribution for a given country or countries over time.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| location | str | name of the country to load the age distribution for | None |
Returns
| Name | Type | Description |
|---|---|---|
| age_data | dataframe |
Pandas dataframe with age distribution over time |
get_birth_rates
data.loaders.get_birth_rates(location=None)Load crude birth rates for a given country
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| location | str or list | name of the country to load the birth rates for | None |
Returns
| Name | Type | Description |
|---|---|---|
| birth_rates | arr |
years and crude birth rates |
get_country_aliases
data.loaders.get_country_aliases()Define aliases for countries with odd names in the data
get_death_rates
data.loaders.get_death_rates(location=None, by_sex=True, overall=False)Load death rates for a given country or countries.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| location | str or list | name of the country or countries to load the age distribution for | None |
| by_sex | bool | whether to rates by sex | True |
| overall | bool | whether to load total rate | False |
Returns
| Name | Type | Description |
|---|---|---|
| death_rates | dict | death rates by age and sex |
get_total_pop
data.loaders.get_total_pop(location=None, pop_datafile=None)Load total population for a given country or countries.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| location | str or list | name of the country to load the total population for | None |
Returns
| Name | Type | Description |
|---|---|---|
| pop_data | dataframe |
Dataframe of year and pop_size columns |
map_entries
data.loaders.map_entries(json, location, df=None)Find a match between the JSON file and the provided location(s).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| json | list or dict | the data being loaded | required |
| location | list or str | the list of locations to pull from | required |