memilio.epidata.getHospitalizationData

getHospitalizationData.py Downloads the hospitalization data of the Robert Koch-Institute (RKI) and provides it in different ways.

The raw hospitalization data can be found at https://github.com/robert-koch-institut/COVID-19-Hospitalisierungen_in_Deutschland

Functions

get_hospitailzations_per_day(seven_days_values)

Gets the daily cases of hospitalizations from the seven day sum.

get_hospitalization_data([read_data, ...])

Downloads or reads the RKI hospitalization data and writes them in different files.

hospit_sanity_checks(df)

Checks the sanity of the hospitalization_data dataframe

main()

Main program entry.

memilio.epidata.getHospitalizationData.get_hospitailzations_per_day(
seven_days_values,
)

Gets the daily cases of hospitalizations from the seven day sum.

A zero filled array is created where the one day data is stored. For each calculated daily case the copied array is adjusted to include only the remaining values. Whenever the seven day sum changes to the following day, the difference is the same as the daily case difference from last week. The computation can be done forward and backward. Both is done until the array is flattened. If there are constant cases left on each day, they are divided on each date by one seventh. After that, a few tests are done to check if all cases were distributed correctly.

Parameters:

seven_days_values – Array. Total hospitalizations over the last seven days

Returns:

daily_values Hospitalizations per day.

memilio.epidata.getHospitalizationData.get_hospitalization_data(
read_data=False,
file_format='json_timeasstring',
out_folder='/home/docs/checkouts/readthedocs.org/user_builds/memilio/data/',
start_date=datetime.date(2020, 1, 1),
end_date=datetime.date(2026, 6, 15),
impute_dates=False,
moving_average=0,
**kwargs,
)

Downloads or reads the RKI hospitalization data and writes them in different files.

Available data starts from 2020-03-01. If it does not already exist, the folder Germany is generated in the given out_folder. If read_data == True and the file “RKIHospitFull.json” exists, the data is read from this file and stored in a pandas dataframe. If read_data = True and the file does not exist the program is stopped.

The downloaded dataframe is written to the file “RKIHospitFull”. After that, the columns are renamed to english. From the sum of the cases of the last seven days the daily cases are calculated. Afterwards, the data is stored in four different files: “hospit_state_age”, “hospit_state”, “hospit_germany_age” and “hospit_germany” for states or germany and age groups.

Parameters:
  • read_data – True or False. Defines if data is read from file or downloaded. Default defined in defaultDict.

  • file_format – File format which is used for writing the data. Default defined in defaultDict.

  • out_folder – Folder where data is written to. Default defined in defaultDict.

  • start_date – Date of first date in dataframe. Default defined in defaultDict.

  • end_date – Date of last date in dataframe. Default defined in defaultDict.

  • impute_dates – True or False. Defines if values for dates without new information are imputed. Default defined in defaultDict. Here Dates are always imputed so False changes nothing.

  • moving_average – Currently not used] Integers >=0. Applies an ‘moving_average’-days moving average on all time series to smooth out weekend effects. Default defined in defaultDict.

  • **kwargs

memilio.epidata.getHospitalizationData.hospit_sanity_checks(df)

Checks the sanity of the hospitalization_data dataframe

Checks if type of the given data is a dataframe Checks if the headers of the dataframe are those which are needed

Parameters:

df – The dataframe which has to be checked

memilio.epidata.getHospitalizationData.main()

Main program entry.