newsdev / elex

A wrapper for the AP v2 Elections API.
Other
170 stars 53 forks source link

Add special-election indicator to Elex data structure #333

Open mileswwatkins opened 6 years ago

mileswwatkins commented 6 years ago

The AP serves special elections alongside regular results, and typically the only indicators of specialness are in the text fields racetype, seatname, and description.

I've confirmed with AP Support that the 2018 general-election data will use these fields like so:

2016 general special elections had similar content; for example, the special House races:

id,racetype,racetypeid,description,seatname
12979-polid-53401-state-HI-1,Special General,G,2014 - Unexpired Term,1-Unexpired Term
18848-polid-54203-state-KY-1,Special General,G,2014 - Unexpired Term,1-Unexpired Term
40288-polid-49768-state-PA-1,Special General,G,Replace Fattah,2-Unexpired Term

Obviously, we'd have to get further confirmations from the AP before we just assume string parsing like racetype ILIKE '%special%' AS is_special_election would produce an accurate new column. But I think that it'd be a valuable addition to the schema, surfacing/structuring a meaningful piece of information that is useful in data pipelines and graphics, but isn't explicitly structured by the AP.

The Elex CSV schema already has an is_ballot_measure column, which is an analogous "calculated field." This seems to suggest that an is_special_election flag would fit as well.

TylerFisher commented 6 years ago

This is a great idea IMO. Already doing that exact string parsing on my end.

palewire commented 6 years ago

Sounds like a good PR if you have the time to put it together.

mileswwatkins commented 6 years ago

I don't think I'll have a chance to implement this during the 2018 election cycle.

That said, I'm going to send a support email to AP to confirm how this field should be calculated, and'll drop it back here.

mileswwatkins commented 6 years ago

A separate support email contradicts the first:

For the two 2018 US Senate races (officeid=S) in question), in MN and MS, the racetype will NOT be Special General as we do need to set the national flag/needs to be figured into the national trend table, but there will be differentiated by a seatname which depicts the starting year of the term (seatname will be 2014 for both races). The “regular” MN and MS US Senate races will not have a seatname.

So, racetype ILIKE '%special%' AS is_special_election isn't even going to do the trick for November 2018, much less into the future. Good to know, but frustrating!