https://www.ecdc.europa.eu/en/publicati ... ea-country). We will be working on these two datasets: • (data.json) The daily number of new reported COVID-19 cases and deaths by EU/EEA country: The data file contains information on newly reported COVID-19 cases and deaths in EU/EEA countries. Each entry contains the corresponding data for a certain day per country. You can also look at [this document] (https://www.ecdc.europa.eu/sites/defaul ... orting.pdf) to get more information. • (agecases.json) 14-day age-specific notification rate of new COVID-19 cases: It contains information on the 14-day notification rate of newly reported COVID-19 cases per 100,000 population by age group, week and country. Each entry contains the corresponding data for a certain week and a country. You can also look at this document to get more information.
Go to init function f Covid19Analyzer under at covid_db.py file. Our first goal is to read a json file and convert it to some data structure that can be used within Python. list of records. . Using a with open statement, read and load the data.json file using json.load() function. This loader retums you a nested lists of dicts under the records key. After that, you have • Iterate over the list of records. Each record corresponds to a dictionary, which includes the following information: { "dateRep" "15/05/2021", "day": "15", "month": "85", "year": "2021", "cases": 721, "deaths" 14, "countriesAndTerritories": "Austria", "geoId" : "AT", "countryterritoryCode" : "AUT", "popData2020": "8901064", "continent Exp": "Europe" Refer to the documentation that we linked before for the definitions of the keys and the values. • Inorder to store and process this data, we're going to use the power of object-oriented programming. In Covid19Analyzer class, there is an empty dictionary object called self.db. While iterating over the records, you must create a Country object with the parameters name (the full name of the country) and the population (int) if it doesn't exist and save it to the dictionary self.db with the key geoID as the representative of a unique country code. This way, we can access each country through our database dictionary. • We're going to save each record to a relevant Country object by using save_daily_data(), which takes three arguments: date (string), cases (int), and deaths (int) and appends the data to daily_records list as a dictionary. Here, we are going to process the data from March 7, 2021 to May 3, 2021 (both are not included.) • You can create specific dates by using datetime library of python. Adding, subtracting and comparing dates with standard operators are valid. This is called operator overloading in programming languages. To build a datetime object, you should decompose the string in a record given by dateRep key to days, month, and year. Hint: You can check strptime function.
Once you have finished storing the data, you can move to the next part. Q1.2) Saving Weekly Cases Similar to the first part, we are going to save weekly case data, but this time, by also including an age-group information as well. Again, each record contains information about a specific country: { "country" : "Austria", "country_code" : "AT", "year_week" : "2020-13", "age_group": "<15yr", "new_cases" : 156, "population": 1283060, "rate_14_day_per_100k": 16.7, "source": "TESSY COVID-19, national weekly data" } Our goal is to extract country_code, year_week, age group and population. This time, the Country objects is ready in the database db from before. We first need to save populations of age groups per country if it is not set before. We placed -1 as the sentinel values for age groups in the dictionary population_by_agegroup. Do not forget to convert this to an integer. This time, we are going to use save_weekly_data function to save our data, which takes age group (str), year_week (str), new_cases (int) as arguments. Here, the timestamps are in the year-week format. In order to align the dates that are given in the first part, you should only include the weeks between 9 and 18 (both are not included) of 2021. Note that some countries do not include this data such as France and Luxembourg.
In this assignment, our goal is to analyze COVID-19 data provided by European Centre for Disease Prevention and Control. We will use data containing 30 countries' populations (as well as the age groups), daily/weekly cases (together with age groups), and daily deaths. We will practice file reading, parsing, sorting data, and object-oriented programming. In the end, we will be able to calculate (per country): Cases/deaths per 1M, • Exposure per age group, and the most/least infected age groups. . Probability of belonging a new case to an age group, The distribution Ideaths according to age groups Finally, we will report extreme cases according to these statistics. Q1) Reading a File and Storing Data (30 pts) You can access the COVID-19 data using [this link] (In this assignment, our goal is to analyze COVID-19 data provided by European Centre for Disease Prevention and Control.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am