Skip to content

Instantly share code, notes, and snippets.

@rrosasl
Created November 25, 2020 17:19
Show Gist options
  • Save rrosasl/8f8d3dd353aa769e211f038adfa5b206 to your computer and use it in GitHub Desktop.
Save rrosasl/8f8d3dd353aa769e211f038adfa5b206 to your computer and use it in GitHub Desktop.
FIrst round of voting
#Create Data Frame where results will be stored
results = []
vote_rounds = pd.DataFrame()
df_t = df.transpose() # Change rows and columns to have voters as columns
for col in df_t.columns:
top_choice = df_t[col].min() #Choose their Top Canidate
top_candidate = df_t[df_t[col] == top_choice].index.tolist()[0]
results.append(top_candidate)
vote_rounds[0] = results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment