I developed these while analyzing COVID-19 data. I wanted to be able to use the FIPS number (a US Census terms), a field in the New York Times (https://github.com/nytimes/covid-19-data) COVID-19 database, as a key to augment their data with State and County populations.
using CSV
function get_state_populations()
url = "https://raw.githubusercontent.com/prairie-guy/2019-State-and-County-Population-with-FIPS-key/master/2019_state_populations.csv"
CSV.read(download(url),type=String,types=Dict(3=>Int64))
endget_state_populations (generic function with 1 method)
get_state_populations()51 rows × 3 columns
| fips | state | population | |
|---|---|---|---|
| String | String | Int64 | |
| 1 | 01000 | Alabama | 4903185 |
| 2 | 02000 | Alaska | 731545 |
| 3 | 04000 | Arizona | 7278717 |
| 4 | 05000 | Arkansas | 3017804 |
| 5 | 06000 | California | 39512223 |
| 6 | 08000 | Colorado | 5758736 |
| 7 | 09000 | Connecticut | 3565287 |
| 8 | 10000 | Delaware | 973764 |
| 9 | 11000 | District of Columbia | 705749 |
| 10 | 12000 | Florida | 21477737 |
| 11 | 13000 | Georgia | 10617423 |
| 12 | 15000 | Hawaii | 1415872 |
| 13 | 16000 | Idaho | 1787065 |
| 14 | 17000 | Illinois | 12671821 |
| 15 | 18000 | Indiana | 6732219 |
| 16 | 19000 | Iowa | 3155070 |
| 17 | 20000 | Kansas | 2913314 |
| 18 | 21000 | Kentucky | 4467673 |
| 19 | 22000 | Louisiana | 4648794 |
| 20 | 23000 | Maine | 1344212 |
| 21 | 24000 | Maryland | 6045680 |
| 22 | 25000 | Massachusetts | 6892503 |
| 23 | 26000 | Michigan | 9986857 |
| 24 | 27000 | Minnesota | 5639632 |
| 25 | 28000 | Mississippi | 2976149 |
| 26 | 29000 | Missouri | 6137428 |
| 27 | 30000 | Montana | 1068778 |
| 28 | 31000 | Nebraska | 1934408 |
| 29 | 32000 | Nevada | 3080156 |
| 30 | 33000 | New Hampshire | 1359711 |
| ⋮ | ⋮ | ⋮ | ⋮ |
using CSV
function get_county_populations()
url = "https://raw.githubusercontent.com/prairie-guy/2019-State-and-County-Population-with-FIPS-key/master/2019_county_populations.csv"
CSV.read(download(url),type=String,types=Dict(4=>Int64))
endget_county_populations (generic function with 1 method)
get_county_populations()3,142 rows × 4 columns
| fips | state | county | population | |
|---|---|---|---|---|
| String | String | String | Int64 | |
| 1 | 01001 | Alabama | Autauga County | 55869 |
| 2 | 01003 | Alabama | Baldwin County | 223234 |
| 3 | 01005 | Alabama | Barbour County | 24686 |
| 4 | 01007 | Alabama | Bibb County | 22394 |
| 5 | 01009 | Alabama | Blount County | 57826 |
| 6 | 01011 | Alabama | Bullock County | 10101 |
| 7 | 01013 | Alabama | Butler County | 19448 |
| 8 | 01015 | Alabama | Calhoun County | 113605 |
| 9 | 01017 | Alabama | Chambers County | 33254 |
| 10 | 01019 | Alabama | Cherokee County | 26196 |
| 11 | 01021 | Alabama | Chilton County | 44428 |
| 12 | 01023 | Alabama | Choctaw County | 12589 |
| 13 | 01025 | Alabama | Clarke County | 23622 |
| 14 | 01027 | Alabama | Clay County | 13235 |
| 15 | 01029 | Alabama | Cleburne County | 14910 |
| 16 | 01031 | Alabama | Coffee County | 52342 |
| 17 | 01033 | Alabama | Colbert County | 55241 |
| 18 | 01035 | Alabama | Conecuh County | 12067 |
| 19 | 01037 | Alabama | Coosa County | 10663 |
| 20 | 01039 | Alabama | Covington County | 37049 |
| 21 | 01041 | Alabama | Crenshaw County | 13772 |
| 22 | 01043 | Alabama | Cullman County | 83768 |
| 23 | 01045 | Alabama | Dale County | 49172 |
| 24 | 01047 | Alabama | Dallas County | 37196 |
| 25 | 01049 | Alabama | DeKalb County | 71513 |
| 26 | 01051 | Alabama | Elmore County | 81209 |
| 27 | 01053 | Alabama | Escambia County | 36633 |
| 28 | 01055 | Alabama | Etowah County | 102268 |
| 29 | 01057 | Alabama | Fayette County | 16302 |
| 30 | 01059 | Alabama | Franklin County | 31362 |
| ⋮ | ⋮ | ⋮ | ⋮ | ⋮ |