memilio.epidata.geoModificationGermany
geoModificationGermany.py
- Provides methods to return lists of local entities such as federal states
and counties and geographical merging criteria.
Functions
|
Checks if all states are mentioned |
|
Creates region information based on county aggregation level which is finer than federal state aggregation and based on mobility. |
|
" Get list of county IDs sorted according to county ID. |
|
" Get list of county names sorted according to county ID. |
|
" Get list of county names and IDs sorted according to county ID. |
Creates a hash map from county IDs to intermediate region IDs |
|
" Returns a hash map from county ID to county name. |
|
|
Creates a hash map from county IDs to state IDs |
|
Creates a sorted list of governing regions which may simply be federal states or intermediate regions which themselves are a real subset of a federal state and to which a certain number of counties is attributed. |
|
" Get list of intermediate region IDs sorted according to ID. |
|
" Get list of intermediate region names sorted according to ID. |
" Get list of intermediate region names and IDs sorted according to ID. |
|
|
" Returns a hash map from federal state ID to state name. |
Creates a hash map from intermediate region IDs to lists of county IDs |
|
Downloads county list file from destatis and creates hash map from NUTS3 ID to county ID. |
|
Downloads a table with information on all German counties from destatis. |
|
|
" Get list of federal state IDs sorted according to state ID. |
" Get list of federal state names sorted according to state ID. |
|
|
" Get list of federal state names and IDs sorted according to state ID. |
|
Creates a hash map from state IDs to lists of county IDs |
" Returns a hash map from federal state ID to state name. |
|
|
Adds a column with names of counties given a dataframe with state ids |
|
Adds a column with names of states given a dataframe with state ids |
|
Merges the data frame data of different local entities such as the districts of Berlin or counties that were merged on political decision in between. |
|
Merges the data frame data of different local entities such as the districts of Berlin or counties that were merged on political decision in between according to the lists provided in the dictionary geoModificationGermany.CountyMerging. |
- memilio.epidata.geoModificationGermany.check_for_all_counties(
- unique_county_list,
- merge_berlin=True,
- merge_eisenach=True,
Checks if all states are mentioned
This function checks if all counties are available in the list provided. If data is incomplete this function returns false and a parent function may try to download from another source. Note 1: There is no check if data for every day of every county is available. Note 2: If the source data file contains more local entities than the official
county list True is returned and the user has to check on its own.
- Parameters:
unique_county_list – unique county list to check.
merge_berlin – (Default value = True)
merge_eisenach – (Default value = True)
- Returns:
Boolean to say if data is complete or not.
- memilio.epidata.geoModificationGermany.create_intermediateregion_level(
- merge_eisenach=True,
Creates region information based on county aggregation level which is finer than federal state aggregation and based on mobility. The new regions aggregate a certain level of counties. For more information, see the following references.
IMPORTANT: This function does not need to be executed. Since the input file is not publicly available, the results have been copied to defaultDict.
Zika et al. (2020) https://www.iab.de/897/section.aspx/Publikation/k200206302 Kropp/Schwengler (2016) https://doi.org/10.1080/00343404.2014.923093 Kropp/Schwengler (2011) https://doi.org/10.1007/s13147-011-0076-4
- Parameters:
merge_eisenach – (Default value = True)
- memilio.epidata.geoModificationGermany.get_county_ids(
- merge_berlin=True,
- merge_eisenach=True,
- zfill=False,
” Get list of county IDs sorted according to county ID.
- Parameters:
merge_berlin – Default: True] Defines whether the different districts are listed separately or combined as one entity ‘Berlin’.
merge_eisenach – Default: True] Defines whether the counties ‘Wartburgkreis’ and ‘Eisenach’ are listed separately or combined as one entity ‘Wartburgkreis’.
zfill – Default: False] Defines whether county IDs are zero-filled to five digits and returned as a string or returned as an integer.
- Returns:
List of county IDs sorted according to county ID.
- memilio.epidata.geoModificationGermany.get_county_names(
- merge_berlin=True,
- merge_eisenach=True,
” Get list of county names sorted according to county ID.
- Parameters:
merge_berlin – Default: True] Defines whether the different districts are listed separately or combined as one entity ‘Berlin’.
merge_eisenach – Default: True] Defines whether the counties ‘Wartburgkreis’ and ‘Eisenach’ are listed separately or combined as one entity ‘Wartburgkreis’.
- Returns:
List of county names sorted according to county ID.
- memilio.epidata.geoModificationGermany.get_county_names_and_ids(
- merge_berlin=True,
- merge_eisenach=True,
- zfill=False,
” Get list of county names and IDs sorted according to county ID.
- Parameters:
merge_berlin – Default: True] Defines whether the different districts are listed separately or combined as one entity ‘Berlin’.
merge_eisenach – Default: True] Defines whether the counties ‘Wartburgkreis’ and ‘Eisenach’ are listed separately or combined as one entity ‘Wartburgkreis’.
zfill – Default: False] Defines whether county IDs are zero-filled to five digits and returned as a string or returned as an integer.
- Returns:
List of county names and IDs sorted according to county ID.
- memilio.epidata.geoModificationGermany.get_countyid_to_intermediateregionid_map(
- merge_ulm=True,
- merge_eisenach=True,
- zfill=False,
Creates a hash map from county IDs to intermediate region IDs
- Parameters:
merge_ulm – Combines region of Ulm (32) with region of Stuttgart (30). (Default value = True)
merge_eisenach – Default: True] Defines whether the counties ‘Wartburgkreis’ and ‘Eisenach’ are listed separately or combined as one entity ‘Wartburgkreis’.
zfill – Default: False]. Defines whether or not all IDs are returned as zero-filled strings. By default, integer maps are returned.
- Returns:
County ID to intermediate region ID map.
- memilio.epidata.geoModificationGermany.get_countyid_to_name()
” Returns a hash map from county ID to county name.
- Returns:
hash map from county ID to county name.
- memilio.epidata.geoModificationGermany.get_countyid_to_stateid_map(
- merge_berlin=True,
- merge_eisenach=True,
- zfill=False,
Creates a hash map from county IDs to state IDs
- Parameters:
merge_berlin – Default: True] Defines whether the different districts are listed separately or combined as one entity ‘Berlin’.
merge_eisenach – Default: True] Defines whether the counties ‘Wartburgkreis’ and ‘Eisenach’ are listed separately or combined as one entity ‘Wartburgkreis’.
zfill – Default: False]. Defines whether or not all IDs are returned as zero-filled strings. By default, integer maps are returned.
- Returns:
County ID to state ID map.
- memilio.epidata.geoModificationGermany.get_governing_regions(strict=True)
Creates a sorted list of governing regions which may simply be federal states or intermediate regions which themselves are a real subset of a federal state and to which a certain number of counties is attributed.
Governing regions are generally denoted by the first three digits of the belonging county IDs. In cases of a trailing zero, only two digits are taken and for Rhineland Palatinate and Saxony, the strict definition returns the two digit code of the federal state (i.e. 07 and 14).
Note that this list may include former ‘governing regions’. However, this function may only be used to equally distribute information which only exist on the ‘governing region’ level but not on county level itself or where the county level information seems to be wrong. Then, information is extrapolated with the help of governing regions.
- Parameters:
strict – Default: True] Defines whether only regions currently considered as governing regions are returned.
- Returns:
List of governing regions.
- memilio.epidata.geoModificationGermany.get_intermediateregion_ids(
- merge_ulm=True,
- zfill=False,
” Get list of intermediate region IDs sorted according to ID.
- Parameters:
merge_ulm – Combines region of Ulm (32) with region of Stuttgart (30). (Default value = True)
zfill – Default: False] Defines whether IDs are zero-filled to two digits and returned as a string or returned as an integer.
- Returns:
List of intermediate region IDs sorted according to ID.
- memilio.epidata.geoModificationGermany.get_intermediateregion_names(
- merge_ulm=True,
” Get list of intermediate region names sorted according to ID.
- Parameters:
merge_ulm – Combines region of Ulm (32) with region of Stuttgart (30). (Default value = True)
- Returns:
List of intermediate region names sorted according to ID.
- memilio.epidata.geoModificationGermany.get_intermediateregion_names_and_ids(
- merge_ulm=True,
- zfill=False,
” Get list of intermediate region names and IDs sorted according to ID.
- Parameters:
merge_ulm – Combines region of Ulm (32) with region of Stuttgart (30). (Default value = True)
zfill – Default: False] Defines whether IDs are zero-filled to two digits and returned as a string or returned as an integer.
- Returns:
List of intermediate region names and IDs sorted according to region ID.
- memilio.epidata.geoModificationGermany.get_intermediateregion_to_name(
- merge_ulm=True,
” Returns a hash map from federal state ID to state name.
- Parameters:
merge_ulm – Combines region of Ulm (32) with region of Stuttgart (30). (Default value = True)
- Returns:
hash map from federal state ID to state name.
- memilio.epidata.geoModificationGermany.get_intermediateregionid_to_countyids_map(
- merge_ulm=True,
- merge_eisenach=True,
- zfill=False,
Creates a hash map from intermediate region IDs to lists of county IDs
- Parameters:
merge_ulm – Combines region of Ulm (32) with region of Stuttgart (30). (Default value = True)
merge_eisenach – Default: True] Defines whether the counties ‘Wartburgkreis’ and ‘Eisenach’ are listed separately or combined as one entity ‘Wartburgkreis’.
zfill – Default: False]. Defines whether or not all IDs are returned as zero-filled strings. By default, integer maps are returned.
- Returns:
Intermediate region IDs to lists of county IDs map
- memilio.epidata.geoModificationGermany.get_nuts3_county_id_map()
Downloads county list file from destatis and creates hash map from NUTS3 ID to county ID.
- Returns:
Hash map of NUTS3 ID to county ID
- memilio.epidata.geoModificationGermany.get_official_county_table()
Downloads a table with information on all German counties from destatis.
- Returns:
County table with essential columns.
- memilio.epidata.geoModificationGermany.get_state_ids(zfill=False)
” Get list of federal state IDs sorted according to state ID.
- Parameters:
zfill – Default: False] Defines whether state IDs are zero-filled to two digits and returned as a string or returned as an integer.
- Returns:
List of federal IDs sorted according to state ID.
- memilio.epidata.geoModificationGermany.get_state_names()
” Get list of federal state names sorted according to state ID.
- Returns:
List of federal names sorted according to state ID.
- memilio.epidata.geoModificationGermany.get_state_names_and_ids(zfill=False)
” Get list of federal state names and IDs sorted according to state ID.
- Parameters:
zfill – Default: False] Defines whether state IDs are zero-filled to two digits and returned as a string or returned as an integer.
- Returns:
List of federal names and IDs sorted according to state ID.
- memilio.epidata.geoModificationGermany.get_stateid_to_countyids_map(
- merge_eisenach=True,
- zfill=False,
Creates a hash map from state IDs to lists of county IDs
- Parameters:
merge_eisenach – Default: True] Defines whether the counties ‘Wartburgkreis’ and ‘Eisenach’ are listed separately or combined as one entity ‘Wartburgkreis’.
zfill – Default: False]. Defines whether or not all IDs are returned as zero-filled strings. By default, integer maps are returned.
- Returns:
State IDs to lists of county IDs map
- memilio.epidata.geoModificationGermany.get_stateid_to_name()
” Returns a hash map from federal state ID to state name.
- Returns:
hash map from federal state ID to state name.
- memilio.epidata.geoModificationGermany.insert_names_of_counties(
- df,
- county_id_col='ID_County',
- merge_berlin=True,
Adds a column with names of counties given a dataframe with state ids
- Parameters:
df – dataframe with county ids and missing county names
county_id_col – column name of the column containing the county ids (Default value = dd.EngEng[“idCounty”])
merge_berlin – Default: True] Defines whether the different districts are listed separately or combined as one entity ‘Berlin’.
- Returns:
dataframe df with column of state names corresponding to county ids
- memilio.epidata.geoModificationGermany.insert_names_of_states(
- df,
- state_id_col='ID_State',
Adds a column with names of states given a dataframe with state ids
- Parameters:
df – dataframe with state ids and missing state names
state_id_col – column name of the column containing the state ids (Default value = dd.EngEng[“idState”])
- Returns:
dataframe df with column of state names corresponding to county ids
- memilio.epidata.geoModificationGermany.merge_df_counties(
- df,
- merged_id,
- separated_ids,
- sorting=['Date'],
- columns='Date',
- method='sum',
Merges the data frame data of different local entities such as the districts of Berlin or counties that were merged on political decision in between.
- Parameters:
df – Original pandas dataframe.
merged_id – One new ID or old ID that is part of the list in separated_ids that will be used in the returned data frame.
separated_ids – List of old IDs that will be merged.
sorting – Column or criterion on how to sort the rearranged frame. (Default value = [dd.EngEng[‘date’]])
columns – columns to be grouped by, Default: ‘Date’.
method – Method of merging (‘sum’ [default], ‘mean’, ‘median’, ‘min’, ‘max’)
- Returns:
Reduced data frame with separated_ids information merged to merged_id rows.
- memilio.epidata.geoModificationGermany.merge_df_counties_all(
- df,
- sorting=['Date'],
- columns='Date',
- method='sum',
Merges the data frame data of different local entities such as the districts of Berlin or counties that were merged on political decision in between according to the lists provided in the dictionary geoModificationGermany.CountyMerging.
- Parameters:
df – Original pandas dataframe.
columns – columns to be grouped by, Default: ‘Date’.
sorting – Column or criterion on how to sort the rearranged frame. Default: [‘Date’]
method – Method of merging (‘sum’ [default], ‘mean’, ‘median’, ‘min’, ‘max’)
- Returns:
Reduced data frame with IDs merged as given in CountyMerging dict.