Skip to content

Instantly share code, notes, and snippets.

@jampekka
Created June 13, 2021 11:26
Show Gist options
  • Save jampekka/ab7aafa1fa0b9e5045d3702099317863 to your computer and use it in GitHub Desktop.
Save jampekka/ab7aafa1fa0b9e5045d3702099317863 to your computer and use it in GitHub Desktop.
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