Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import pandas as pd
hs_poll_perc = {
'kok': 19.6,
'ps': 18.0,
'sdp': 17.9,
'kesk': 12.7,
'vihr': 11.1,
'vas': 8.2,
'rkp': 4.6,
'kd': 3.6,
'muut': 2.7,
'liik': 1.6
}
yle_poll_perc = {
'kok': 19.6,
'ps': 18.0,
'sdp': 17.0,
'kesk': 13.0,
'vihr': 10.9,
'vas': 8.5,
'rkp': 4.8,
'kd': 3.6,
'liik': 2.1,
'muut': 2.6
}
party_biases_pp = {
'kok': 0.25,
'sdp': 0.5,
'ps': -1.5
}
poll_percs = pd.DataFrame([hs_poll_perc, yle_poll_perc])
est_percs = poll_percs.mean()
for key, bias in party_biases_pp.items():
est_percs[key] += bias
est_percs = est_percs/est_percs.sum()*100
print(est_percs.sort_values().round(1).iloc[::-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment