def main(argv): """ Main function, for Q1 and Q2 :param argv: input path :return: none """ data_dict = data.Data(argv[1]) statistic_functions = [statistics.mean, statistics.median] print("Question 1:") feature_list = [ "hospitalized_with_symptoms", "intensive_care", "total_hospitalized", "home_insulation" ] letters_list = ['L', 'S'] districts_for_q1 = districts.Districts(data_dict) districts_for_q1.filter_districts(letters_list) districts_for_q1.print_details(feature_list, statistic_functions) print() # before question 2 print("Question 2:") data_dict_new = data.Data(argv[1]) districts_for_q2 = districts.Districts(data_dict_new) data.Data.get_all_districts(districts_for_q2.dataset) print("Number of districts:", len(districts_for_q2.dataset.all_districts_set)) color_dict = districts_for_q2.get_districts_class() not_green_counter = 0 for key in color_dict: if color_dict[key] == "not green": not_green_counter += 1 print("Number of not green districts:", not_green_counter) if not_green_counter > 10: print("Will a lockdown be forced on whole of Italy?: Yes") else: print("Will a lockdown be forced on whole of Italy?: No")
def main(argv): dataset = data.Data(argv[1]) district = districts.Districts(dataset) district.filter_districts({'L', 'S'}) print("Question 1:") statistic_methods = [statistics.mean, statistics.median] for key in [ "hospitalized_with_symptoms", "intensive_care", "total_hospitalized", "home_insulation" ]: district.print_details([key], statistic_methods) dataset = data.Data(argv[1]) distinct_districts = dataset.get_all_districts() print("\nQuestion 2:") print(f"Number of districts: {len(distinct_districts)}") district = districts.Districts(dataset) dict = district.get_districts_class() print(f"Number of not green districts: {len(dict['not_green'])}") if len(dict['not_green']) > 10: answer = "Yes" else: answer = "No" print(f"Will a lockdown be forced on whole of Italy?: {answer}")
def main(argv): # q1 print('Question 1:') the_data_q1 = data.Data(argv[1]) dist1 = districts.Districts(the_data_q1) features = ['hospitalized_with_symptoms', 'intensive_care', 'total_hospitalized', 'home_insulation'] statistic_functions = [statistics.mean, statistics.median] letters = ['S', 'L'] dist1.filter_districts(letters) dist1.print_details(features, statistic_functions) # q2 print('\nQuestion 2:') the_data_q2 = data.Data(argv[1]) # dpc-covid19-ita-regioni_sample.csv" dist2 = districts.Districts(the_data_q2) dist2.determine_day_type() not_green_count = 0 dist2.determine_day_type() districts_class = dist2.get_districts_class() for district in districts_class.keys(): if districts_class[district] == 'not green': not_green_count += 1 total_lockdown = not_green_count > 10 print(f'Number of districts: {len(districts_class.keys())}') print(f"Number of not green districts: {not_green_count}") print(f"Will a lockdown be forced on whole of Italy?: {'yes' if total_lockdown else 'no'}")
def main(argv): covid_data = data.Data(argv[1]) district_data = districts.Districts(covid_data) district_data.filter_districts(["L", "S"]) print("Question 1:") actions = [statistics.mean, statistics.median] features = [ "hospitalized_with_symptoms", "intensive_care", "total_hospitalized", "home_insulation" ] district_data.print_details(features, actions)
def main(argv): main_data_q1 = data.Data('dpc-covid19-ita-regioni.csv') main_data_q2 = data.Data('dpc-covid19-ita-regioni.csv') # Q1: print("Question 1:") data_q1 = districts.Districts(main_data_q1) districts_d = ['L', 'S'] data_q1.filter_districts(districts_d) statistics_features = [statistics.mean, statistics.median] feature_list = [ "hospitalized_with_symptoms", "intensive_care", "total_hospitalized", "home_insulation" ] data_q1.print_details(feature_list, statistics_features) # Q2: print("") print("Question 2:") data_q2 = districts.Districts(main_data_q2) data_q2.determine_day_type() districts_class = data_q2.get_districts_class() num_of_green_districts = 0 for key in districts_class.keys(): if districts_class[key] == "yes": num_of_green_districts += 1 number_of_districts = len(districts_class.keys()) print("Number of districts:", end=" ") print(number_of_districts) print("Number of not green districts:", end=" ") num_of_red_district = number_of_districts - num_of_green_districts print(num_of_red_district) print("Will a lockdown be forced on whole of Italy?:", end=" ") if num_of_red_district > 10: print("Yes") else: print("No")