コード例 #1
0
    def test_python_ex_4_1_basic(cls):
        '''Test for existence and callability of read_into_dataframe'''

        # Check that the function exists
        assert hasattr(exam, "read_into_dataframe"), "Function not found"

        # Check that the function can be called
        exam.read_into_dataframe("owid-covid-data.csv")
コード例 #2
0
    def test_python_ex_4_3_basic(cls):
        '''Test for existence and callability of get_weekly_per_100k_country_vs_date'''

        # Check that the function exists
        assert hasattr(exam, "get_weekly_per_100k_country_vs_date"), "Function not found"

        # Check that the function can be called
        exam.get_weekly_per_100k_country_vs_date(exam.get_weekly_per_100k(exam.read_into_dataframe("owid-covid-data.csv")))
コード例 #3
0
print(
    exam.get_weekly_per_100k_for_country_date(covid_dict_3, "Czech Republic",
                                              '2020-10-20'))

# Q2:
dates, values = exam.get_weekly_per_100k_for_country(covid_dict_3,
                                                     "Czech Republic")

#Q3:
import matplotlib.pyplot as plt
exam.plot_weekly_per_100k_for_country(covid_dict_3, "Czech Republic")
plt.savefig('weekly_cases_cze.png')

# Part 4:
# Q1:
df = exam.read_into_dataframe('owid-covid-data.csv')
df_selected_countries = exam.read_into_dataframe('owid-covid-data.csv', [
    'Austria', 'Belarus', 'Belgium', 'Bulgaria', 'Czech Republic', 'Denmark',
    'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Italy',
    'Netherlands', 'Norway', 'Poland', 'Portugal', 'Romania', 'Russia',
    'Serbia', 'Slovakia', 'Spain', 'Sweden', 'Switzerland', 'Ukraine',
    'United Kingdom', 'United States'
])

# Q2:
weekly_per_100k = exam.get_weekly_per_100k(df_selected_countries)

# Q3:
country_vs_date = exam.get_weekly_per_100k_country_vs_date(weekly_per_100k)

import matplotlib