F01.justanswer.com



This is the code that the teacher already wrote in the python workbook, it is like a guide for how to do it. Working with this would make it seem less like cheating.Pairwise Comparison workbookimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport operator# Task 1: Import data from csv file. data = pd.read_csv(r"/Users/John/Downloads/Mid_term_sample_1.csv")data# store the number of voters for each voting group in an array number_of_voters = list(data.columns)[1:]# convert string to numeric number_of_voters = [int(i) for i in number_of_voters]number_of_voters# store the voting groups in an arrayvotes = data.values[:,1:]votesPlurality with elimination workbookimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport operator# Task 1: Import data from csv file. data = pd.read_csv(r"\")data# store the number of voters for each voting group in an array number_of_voters = list(data.columns)[1:]# convert string to numeric number_of_voters = [int(i) for i in number_of_voters]number_of_voters# store number of candidateslength = data.shape[0] length# store threshold of winning electionmajority_req = sum(number_of_voters)//2majority_req ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download