1
votes

I am working on a project about voting patterns in the US and I have some state-level data which I am having some trouble turning into a choropleth map.

I did some research and found ff.create_choropleth in the plotly figure factory library, however, from what I can understand in the notation, it requires county-level FIP data. I only have FIPS data for State-level analysis (1-56, up to Wyoming). How can I go around this?

edit: I have the data for previous elections, what I was trying to ask was how to use Python to create a choropleth map, given that I have ONLY state FIP and not county FIP.

Sorry for the amateurish question, this is my first Python project!

edit2: I'm using https://plotly.com/python-api-reference/generated/plotly.figure_factory.create_choropleth.html and here are some examples of the data I'm working with (I cut it out from a larger table with more variables other than "voted", it's actually quite simple data (don't want to make this question too long).enter image description here

1

1 Answers

0
votes

If you mean the current US election. I'm not certain where/if that data is available publicly. I know that there is a proprietary data feed from the Associated Press that is very pricey, you'd have to reach out to them to get it.

Alternatively, you could try to scrape a public source that is reporting results (such as Politico or another site) but then its still a question of your data granularity. I don't believe they report at the FIPS level.

I guess the short answer to your question is: "You have to buy it, to the best of my knowledge."

EDIT:

Ok, if you're going based off of this (https://plotly.com/python/choropleth-maps/) then if you only have the state FIPS code, I'd try looking up all the county fips and basically just applying the data across all counties:

State FIPS: https://www.nrcs.usda.gov/wps/portal/nrcs/detail/?cid=nrcs143_013696

County FIPS: https://www.nrcs.usda.gov/wps/portal/nrcs/detail/national/home/?cid=nrcs143_013697

If you make a final datasource with all of the county fips set to the value of the state FIPS, maybe it'll all show up the same color?