Group Abstract Group Abstract

Message Boards Message Boards

Electoral Votes 2016

Posted 9 years ago
POSTED BY: Joel Klein
6 Replies

Voter Power Rankings:

rankings=With[{entities=KeyMap[Interpreter["AdministrativeDivision"],as]},Reverse@Dataset@Sort@Association[KeyValueMap[#1->(N@#2/#1["Population"])&,entities]]
];
rankings[{1;;5,-5;;-1}]

enter image description here

POSTED BY: Bob Sandheinrich

Here is a slightly cleaner import and an image collage using Entity.

data = Import[
"http://www.infoplease.com/us/government/electoral-college-votes-state-elections.html", "Data"];
as = Association[Rule @@@ Cases[data, {_String, _Integer}, {5}]]; 

With[{entities = 
       KeyMap[Interpreter["AdministrativeDivision"], as]}, 
     ImageCollage[
      KeyMap[AssociationMap[#["Flag"] &, Keys[entities]][#] &, entities], 
      ImagePadding -> 2, Background -> GrayLevel[.8]]
     ]

enter image description here

POSTED BY: Bob Sandheinrich
KeyMap[Interpreter["AdministrativeDivision"], as]

This is really inefficient, because you'd be interpreting things serially.

AssociationThread[Interpreter["AdministrariveDivision"][Keys[as]], Values[as]]

is probably a bit less elegant, but can be as much as 50 times faster.

POSTED BY: Carlo Barbieri

enter image description here - you have earned "Featured Contributor" badge, congratulations! This is a great post and it has been selected for the curated Staff Picks group. Your profile is now distinguished by a "Featured Contributor" badge and displayed on the "Featured Contributor" board.

POSTED BY: EDITORIAL BOARD

Nice post, Joel!

Why don't you try to turn those strings into entities and do some maps, or normalize by population? I think it would be interesting to see whether those states account for more or less than half of the population of the US. I recall reading somewhere that Californians were the ones whose vote actually counted the least.

POSTED BY: Carlo Barbieri
Posted 9 years ago

Yep, I have some other material where states are dealt with as entities. Those are all good suggestions for thing to study based on this.

The types of directions I was thinking for this were supporting what-if scenarios for battleground states, projections, etc.

POSTED BY: Joel Klein
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard