# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Overview over COVID-19 Data

# This notebook is used to get an overview over COVID-19 data sets from the RKI (Robert Koch Institut in Germany).
# It should help to get a first insight into the data.

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

df = pd.read_csv("web_app/data/testnumbers_combined.csv", delimiter=',')

df.tail()

df['Positiv getestet'] = pd.to_numeric(df['Positiv getestet'], errors='coerce')
df['Anzahl Testungen'] = pd.to_numeric(df['Anzahl Testungen'], errors='coerce')

y_number_positives = df['Positiv getestet'].iloc[:-1] # Leave last value out because it is the sum of all
y_number_tests = df['Anzahl Testungen'].iloc[:-1] # Leave last value out because it is the sum of all

x = df['Kalenderwoche'].iloc[1:]

 x_val = list(range(0, y_number_positives.shape[0]))

plt.plot(x, y_number_positives)
plt.plot(x, y_number_tests)
plt.xticks(np.arange(0, x.shape[0], step=10))
plt.xlabel('Week of year')
plt.ylabel('Number of tests/positives')
plt.title('Number of Corona tests vs. positively tested people')

# # Compare numbers of Germany and Sweden
# We first compare the number of positively tested people in Germany and Sweden. Both countries are currently on very different Covid-19 strategies which makes the comparison interesting.
# All numbers are standardized by the population to have a meaningful comparison.

# ### Comparison of positives

df2 = pd.read_csv("web_app/data/corona_numbers_world.csv", delimiter=',')
# Remove Letter from weeks to have same representation as in first data set
df2['year_week'] = df2['year_week'].str.replace(r'W', '')

df2.head()

x_germany = df2[df2.country == "Germany"].year_week
y_germany = df2[df2.country == "Germany"].new_cases
x_sweden = df2[df2.region_name == "Sweden"].year_week
normalizer = df2[df2.region_name == "Germany"].population.iloc[0]/df2[df2.region_name == "Sweden"].population.iloc[0]
y_sweden = df2[df2.region_name == "Sweden"].new_cases*normalizer

plt.plot(x_germany, y_germany, 'r', label="Germany")
plt.plot(x_sweden, y_sweden, 'k', label="Sweden")
plt.xticks(np.arange(0, x_germany.shape[0], step=15))
plt.xlabel('Week of year', fontsize=12)
plt.ylabel('Number of Positives',  fontsize=12)
plt.title('Number positively tested people: Germany vs. Sweden', fontsize=15)
plt.legend(loc="upper left", fontsize=12)
plt.show()

# ### Comparison of deaths

df3 = pd.read_csv("web_app/data/death_numbers.csv", delimiter=',')

df_deaths_germany = df3[df3.country == "Germany"]
df_deaths_sweden = df3[df3.country == "Sweden"]

# +
y_germany_deaths = df_deaths_germany[df_deaths_germany.indicator=="deaths"].weekly_count
x_germany_deaths = df_deaths_germany[df_deaths_germany.indicator=="deaths"].year_week

y_sweden_deaths = df_deaths_sweden[df_deaths_sweden.indicator=="deaths"].weekly_count*normalizer
x_sweden_deaths = df_deaths_sweden[df_deaths_sweden.indicator=="deaths"].year_week
# -

plt.plot(x_sweden_deaths, y_sweden_deaths, 'r', label="Sweden")
plt.plot(x_germany_deaths, y_germany_deaths, 'k', label="Germany")
plt.xticks(np.arange(0, x_germany_deaths.shape[0], step=15))
plt.xlabel('Week of year', fontsize=12)
plt.ylabel('Number of Deaths',  fontsize=12)
plt.title('Number of Covid-19 related deaths: Germany vs. Sweden', fontsize=15)
plt.legend(loc="upper left", fontsize=12)
plt.show()

StarcoderdataJupyterScriptsDedupFiltered