2 party vote share python program for DRA to get 2012 info.(not a full script)
       |           

Welcome, Guest. Please login or register.
Did you miss your activation email?
April 26, 2024, 03:57:50 PM
News: Election Simulator 2.0 Released. Senate/Gubernatorial maps, proportional electoral votes, and more - Read more

  Talk Elections
  General Politics
  Political Geography & Demographics (Moderators: muon2, 100% pro-life no matter what)
  2 party vote share python program for DRA to get 2012 info.(not a full script)
« previous next »
Pages: [1]
Author Topic: 2 party vote share python program for DRA to get 2012 info.(not a full script)  (Read 310 times)
lfromnj
Atlas Politician
Atlas Icon
*****
Posts: 19,368


Show only this user's posts in this thread
« on: February 22, 2020, 02:19:28 AM »
« edited: February 22, 2020, 02:44:01 AM by lfromnj »

Anyway a slightly annoying lack of a feature in DRA 2020 is lack of 2012 Data in states that get PVI and 2016 Data. This is because PVI is effectively calculated from a formula of an average of 2012+2016 two party vote share. So we have only one missing variable here, and a formula to calculate it so its pretty simple to just make a short program here that allows you to get some data if you wanted to see how your congressional district voted in 2012.
Quote
country = 48.2/(46.1+48.2)
country2012=51.1/(47.2+51.1)
C2016 = float(input("Input 2016 Clinton raw Votes or Percentage"))
T2016= float(input("Input 2016 Trump raw votes or Percentage"))
PV = float(input("Give PVI value 2012/2016 negative if R"))
PVI = PV/100
p2016= C2016/(C2016+T2016)
PVI2016=p2016-country
PVI2012 =2*PVI-PVI2016
Obama= PVI2012+country2012
print ("Obama share is",Obama*100)
print ("Romney share is",(1-Obama)*100)

It isn't a script but just lets you input 3 data values to get the 2012 TWO PARTY VOTE SHARE if you wanted it quicker than manually calculating it.
I was just listening to Joe Biden about learning to code, we all gotta start somewhere.
Anyway you can either type in the raw votes aka Clinton getting 23000 in a country and Trump getting 25000 or just give the percentage they got that is shown on DRA 2020. I would recommend typing in the raw votes as this reduces the risk of one of the possible rounding errors as my original rounding error when using the percentage like 2%.
Logged
America Needs a 13-6 Progressive SCOTUS
Solid4096
Junior Chimp
*****
Posts: 8,750


Political Matrix
E: -8.88, S: -8.51

P P P
Show only this user's posts in this thread
« Reply #1 on: February 22, 2020, 01:12:43 PM »

by the way, the script an be optimized better by using PVI + 51.54 (which is literally how it is in the code of DRA) to calculate the average Dem share of the vote across 2012 and 2016.
Logged
Pages: [1]  
« previous next »
Jump to:  


Login with username, password and session length

Terms of Service - DMCA Agent and Policy - Privacy Policy and Cookies

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Page created in 0.019 seconds with 11 queries.