openelections / openelections-core

Core repo for election results data acquisition, transformation and output.
MIT License
176 stars 96 forks source link

Wisconsin results files don't have total votes/winner/write-in columns filled in #274

Open nbdavies opened 5 years ago

nbdavies commented 5 years ago

Total votes is present in the openelections-data-wi repo data, so all we should have to do is make sure that gets into the Mongo data and then output in the raw data.

The write-on column should be possible to fill based on candidate name (which ought to have (Write-In) or (Write In) if the candidate is one).

Marking the winner might be a little trickier, but maybe I can base that off of another state's logic.

nbdavies commented 5 years ago

There are some descriptions of these fields as defined on classes in the repo:

class RawResult(TimestampMixin, DynamicDocument):
    total_votes = IntField(help_text="Total candidate votes contest-wide, if provided in raw results.")
    winner = StringField(help_text="Winner flag, if provided in raw results.")
    write_in = StringField(help_text="Write-in flag, if provided in raw results.")

class Result(TimestampMixin, DynamicDocument):
    total_votes = IntField(help_text="Total candidate votes contest-wide, either from raw results or calculated by OpenElex."
            "Requires validation if migrated from raw results.")
    winner = BooleanField(help_text="Winner of jurisdiction, *not* contest winner. Some data flags lower-level results "
        "as winner if candidate won contest-wide. In such case, this field should blank")
    write_in = BooleanField()

Where a Contest is a match-up of candidates (specific to a date, an office, possibly a district, possibly a party).

It sounds like these are all optional at the Raw stage that we're currently at.

Write-In

There could be a case for removing (Write-In) from the candidate name (since it doesn't really belong there) and filling in the write-in column when that happens.

Here's an example of another state's results with the write-in column filled in: https://raw.githubusercontent.com/openelections/openelections-results-va/master/raw/20181106__va__general__precinct__raw.csv

Total Votes

Total votes, as I understand it, would be a little more challenging. It sounds like the value for that column is supposed to be the the candidate's total votes for the entire contest. This West Virginia column has that filled in: https://github.com/openelections/openelections-results-wv/blob/master/raw/20000509__wv__primary__county__raw.csv

The total votes in the CSVs from the openelections-data-wi repo is total across candidates per ward, so it's a different total.

Winner

It sounds like winner is meant to be the winner at the micro scale: whichever candidate for that race has the most votes in a given ward. So for example:

county,ward,office,district,total votes,party,candidate,votes
Brown,Town Of Lawrence Wards 1 - 3,State Senate,2,1331,REP,Robert L. Cowles,892
Brown,Town Of Lawrence Wards 1 - 3,State Senate,2,1331,DEM,Nancy J. Nusbaum,434
Brown,Town Of Lawrence Wards 1 - 3,State Senate,2,1331,,Scattering,5

For that reporting unit, Cowles would be the winner regardless of whether he won overall. Determining that would also take some further processing of the results. For non-partisan primary elections where the top two vote-getters proceed to the general election, we may need to clarify that winner at the micro level is still the top one candidate for the ward.

psa commented 4 years ago

Poking around for ways to contribute, is this fixed by #275?

nbdavies commented 4 years ago

I would say it's 1/3rd fixed? #275 filled in the write-in column, but not the winner or total votes columns