<jupyter_start><jupyter_text>Final Assessment<NAME> (i6235448)  1. IntroductionResearch question: How high was the case fatality rate associated with covid-19 in Germany compared to other countries of the European Union in January 2022?  2. Data preparation<jupyter_code>import pandas as pd
import altair as alt
import ipywidgets as widgets
covid = pd.read_csv('https://covid.ourworldindata.org/data/owid-covid-data.csv')<jupyter_output><empty_output><jupyter_text>After importing the relevant libraries and loading the dataset I first calculated the case fatality rate and then I selected the rows and columns relevant for my research question.(case_fatality_rate = new_deaths_smoothed_per_million / new_cases_smoothed_per_million * 100)<jupyter_code>covid['case_fatality_rate'] = covid['new_deaths_smoothed_per_million'] / covid['new_cases_smoothed_per_million'] * 100
relevant_columns = ['continent', 'location', 'date', 'new_cases_smoothed_per_million', 'new_deaths_smoothed_per_million', 'case_fatality_rate']
europe = covid.loc[covid.continent == 'Europe', relevant_columns]
covid_europe = europe.loc[covid.date.str.contains('2022-01-')]
covid_europe<jupyter_output><empty_output><jupyter_text>3. Exploring and cleaning data First, I grouped the data by location and used descriptive statistics to get an overview of the values for each country and to see whether there are typos or missing data.<jupyter_code>covid_europe.groupby('location').describe()<jupyter_output><empty_output><jupyter_text>While I did not detect any typos, I saw that for some countries the data is incomplete (NaN).I decided to delete all rows with missing data.<jupyter_code>ce = covid_europe.dropna()
ce<jupyter_output><empty_output><jupyter_text>After deleting the rows with missing data, I wanted to see which countries had data for every day of January 2022 which is why I looked at the value counts for the countries.<jupyter_code>ce['location'].value_counts()<jupyter_output><empty_output><jupyter_text>While most countries have values for all 31 days of January 2022, the UK, did not which is why I decided to exclude this country. (I only want to include countries with complete data.)<jupyter_code>ce = ce[ce['location'].str.contains('United Kingdom') == False]
ce<jupyter_output><empty_output><jupyter_text>4. Descriptives and visualizations In order to describe the population, I grouped the data by location (country) and used descriptive statistics.<jupyter_code>ce.groupby('location').agg(
    {
        'new_cases_smoothed_per_million':['min', 'max', 'mean', 'skew'],
        'new_deaths_smoothed_per_million':['min', 'max', 'mean', 'skew'],
        'case_fatality_rate':['min', 'max', 'mean', 'skew'],
    })<jupyter_output><empty_output><jupyter_text>In the interactive table below, you can select any member of the European Union to see the new cases, new deaths and case fatality rate for every day of January 2022.<jupyter_code>from ipywidgets import interact
from ipywidgets import fixed
def select_country_data(location, df):
  return df.loc[df['location'] == location, ]
interact(select_country_data, location = ['Germany', 'Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czechia', 'Denmark', 'Estonia', 'Finland', 'France', 'Greece', 'Hungary', 'Ireland', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Spain', 'Sweden'], df = fixed(ce))<jupyter_output><empty_output><jupyter_text>In the interactive chart below, you can select any member of the European Union to see the case fatality rate (%) for every day of January 2022.<jupyter_code>def select_country_data_chart(location, df):
  return df.loc[df['location'] == location, ]
def visualize_country_data_chart(location, df):
  visualized_data = select_country_data_chart(location, df)
  
  lineplot = alt.Chart(visualized_data).mark_line().encode(
    x='date:O',
    y='case_fatality_rate:Q',
    color='location:N'
  )

  display(lineplot)
interact(visualize_country_data_chart, location = ['Germany', 'Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czechia', 'Denmark', 'Estonia', 'Finland', 'France', 'Greece', 'Hungary', 'Ireland', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Spain', 'Sweden'], df = fixed(ce))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12063854047890536, 'fraction_numerical': 0.010718358038768529, 'mean_word_length': 7.10720887245841, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 38, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '440964', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1394, 'n_words': 404, 'path': 'notebooks/My_Notebook_i6235448 (1).ipynb', 'repo_name': 'LAURAD98/voila', 'size': '4389'}