forked from Tiridus/assignments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw1.py
73 lines (56 loc) · 2.53 KB
/
hw1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from typing import List
import pandas as pd
CONFIRMED_CASES_URL = f"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data" \
f"/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv "
"""
When downloading data it's better to do it in a global scope instead of a function.
This speeds up the tests significantly
"""
confirmed_cases = pd.read_csv(CONFIRMED_CASES_URL, error_bad_lines=False)
def poland_cases_by_date(day: int, month: int, year: int = 2020) -> int:
"""
Returns confirmed infection cases for country 'Poland' given a date.
Ex.
>>> poland_cases_by_date(7, 3, 2020)
5
>>> poland_cases_by_date(11, 3)
31
:param year: 4 digit integer representation of the year to get the cases for, defaults to 2020
:param day: Day of month to get the cases for as an integer indexed from 1
:param month: Month to get the cases for as an integer indexed from 1
:return: Number of cases on a given date as an integer
"""
# Your code goes here (remove pass)
pass
def top5_countries_by_date(day: int, month: int, year: int = 2020) -> List[str]:
"""
Returns the top 5 infected countries given a date (confirmed cases).
Ex.
>>> top5_countries_by_date(27, 2, 2020)
['China', 'Korea, South', 'Cruise Ship', 'Italy', 'Iran']
>>> top5_countries_by_date(12, 3)
['China', 'Italy', 'Iran', 'Korea, South', 'France']
:param day: 4 digit integer representation of the year to get the countries for, defaults to 2020
:param month: Day of month to get the countries for as an integer indexed from 1
:param year: Month to get the countries for as an integer indexed from 1
:return: A list of strings with the names of the coutires
"""
# Your code goes here (remove pass)
pass
# Function name is wrong, read the pydoc
def no_new_cases_count(day: int, month: int, year: int = 2020) -> int:
"""
Returns the number of countries/regions where the infection count in a given day
was NOT the same as the previous day.
Ex.
>>> no_new_cases_count(11, 2, 2020)
35
>>> no_new_cases_count(3, 3)
57
:param day: 4 digit integer representation of the year to get the cases for, defaults to 2020
:param month: Day of month to get the countries for as an integer indexed from 1
:param year: Month to get the countries for as an integer indexed from 1
:return: Number of countries/regions where the count has not changed in a day
"""
# Your code goes here (remove pass)
pass