Skip to content

Instantly share code, notes, and snippets.

@gebelo
gebelo / nytmeyer.htm
Last active Jan 19, 2021
NYT Meyer Award links
View nytmeyer.htm
These are the links submitted as part of the New York Times 2020 Philip Meyer Award entry:
@gebelo
gebelo / top40health
Created Apr 19, 2020
Breakdown of Health care occupations by gender, race, ethnicity and nativity, via our New York Times story https://www.nytimes.com/2020/04/18/us/coronavirus-women-essential-workers.html
View top40health
Occupation,workers,Female,NonWhite,Black,Hispanic,Asian,ForeignBorn-Citizen,ForeignBorn-NonCitizen
Registered nurses,"3,171,358",89%,29%,11%,7%,9%,12%,3%
Nursing assistants,"1,369,106",89%,57%,34%,14%,5%,14%,9%
Physicians,"882,804",38%,35%,5%,6%,21%,21%,7%
Licensed practical and licensed vocational nurses,"863,026",87%,45%,26%,12%,5%,10%,4%
Personal care aides,"720,868",84%,56%,27%,18%,8%,12%,11%
Medical and health services managers,"631,539",72%,30%,12%,10%,5%,9%,3%
Medical assistants,"497,345",92%,49%,13%,29%,4%,10%,5%
"Secretaries and administrative assistants, except legal, medical, and executive","470,105",96%,30%,11%,13%,4%,7%,3%
Receptionists and information clerks,"459,777",95%,39%,11%,21%,4%,6%,4%
@gebelo
gebelo / gist:94dbc276882846175d74b0b1360d53d1
Created Apr 18, 2020
These are industry and occupation codes used in a New York Times story about gender dynamics of the coronavirus pandemic "essential" workforce, https://www.nytimes.com/2020/04/18/us/coronavirus-women-essential-workers.html
View gist:94dbc276882846175d74b0b1360d53d1
"isHealth=ifelse((IND>=7970 & IND<=8290) | (OCC>=3000 & OCC<=3550),1,0),
isHealth=ifelse(OCC==3250 |OCC==3424, 0, isHealth)," "Offices of physicians
Offices of dentists
Offices of chiropractors
Offices of optometrists
Offices of other health practitioners
Outpatient care centers
Home health care services
Other health care services
General medical and surgical hospitals, and specialty (except psychiatric and substance abuse) hospitals
@gebelo
gebelo / nytcounties.csv
Created Oct 29, 2019
this is population distribution by county based on our density estimates... pop is tract level aggregated, from 2013-2017 ACS
View nytcounties.csv
statename countyfips countyname urban inner outer rural total urban_pct isuburb_pct osuburb_pct
al01 01001 Autauga County 0 9965 18709 26362 55036 0 0.18106330401918744 0.3399411294425467
al01 01003 Baldwin County 0 0 149067 54293 203360 0 0 0.7330202596380803
al01 01005 Barbour County 0 0 6045 20156 26201 0 0 0.23071638487080645
al01 01007 Bibb County 0 0 0 22580 22580 0 0 0
al01 01009 Blount County 0 0 0 57667 57667 0 0 0
al01 01011 Bullock County 0 0 0 10478 10478 0 0 0
al01 01013 Butler County 0 0 4368 15758 20126 0 0 0.21703269402762596
al01 01015 Calhoun County 1197 3854 82703 27773 115527 0.010361214261601184 0.03336016688739429 0.7158759424203865
al01 01017 Chambers County 0 0 12473 21422 33895 0 0 0.36798937896444905
View nytdensity.csv
We can't make this file beautiful and searchable because it's too large.
geoid,pop_density,paved_density,tract_type
01001020100,3,3,3) OUTER RING
01001020200,5,5,3) OUTER RING
01001020300,5,4,3) OUTER RING
01001020400,5,4,3) OUTER RING
01001020500,6,6,2) INNER RING
01001020600,4,4,3) OUTER RING
01001020700,3,3,3) OUTER RING
01001020801,2,2,4) RURAL
@gebelo
gebelo / hudpublic.csv
Last active Jun 25, 2019
Nursing Home List
View hudpublic.csv
These 74 nursing homes with HUD-backed mortgages appeared recently a Congressional list of facilities that have “serious deficiencies.”
View choropleth with custom bins
from matplotlib.colors import LinearSegmentedColormap
bins = [0,1]
# Maps values to a bin.
# The mapped values must start at 0 and end at 1.
def bin_mapping(x):
for idx, bound in enumerate(bins):
if x < bound:
return idx / (len(bins) - 1.0)
@gebelo
gebelo / gist:902815fd76c080a4a668e96a93cb430d
Last active Mar 26, 2021
Converting Z-Score to Percentile in Python
View gist:902815fd76c080a4a668e96a93cb430d
def zptile(z_score):
return .5 * (math.erf(z_score / 2 ** .5) + 1)
zptile(0.95)
# excel says: 0.8289438737
0.8289438736915181
via: http://stackoverflow.com/questions/2782284/function-to-convert-a-z-score-into-a-percentage
@gebelo
gebelo / gist:4aee93ba6d622b42ced6953881310b14
Created Jun 7, 2016
Ugly but effective MySQL conversion of m/d/y string into yyyy-mm-dd date
View gist:4aee93ba6d622b42ced6953881310b14
SELECT dob, SUBSTRING_INDEX( `dob` , '/', 1 ) AS mo,
SUBSTRING_INDEX(SUBSTRING_INDEX( `dob` , '/', 2 ),'/',-1) AS dy,
SUBSTRING_INDEX(SUBSTRING_INDEX( `dob` , '/', 3 ),'/',-1) AS yr,
CONCAT(SUBSTRING_INDEX(SUBSTRING_INDEX( `dob` , '/', 3 ),'/',-1),"-",SUBSTRING_INDEX( `dob` , '/', 1 ),"-",SUBSTRING_INDEX(SUBSTRING_INDEX( `dob` , '/', 2 ),'/',-1)) AS dt
FROM table
"dob" "mo" "dy" "yr" "dt"
"7/19/1970" "7" "19" "1970" "1970-7-19"
@gebelo
gebelo / gist:5cc47579a2259d7e0d9953ddd3b0b2ea
Last active May 10, 2016
US Native American Population
View gist:5cc47579a2259d7e0d9953ddd3b0b2ea
2010-2014, ACS 5-year sample
Source: IPUMS.org
Nativer American Alone, by Tribal Identification
302: Apache 70,940
303: Blackfoot 28,256
304: Cherokee 279,721
305: Cheyenne 14,386
306: Chickasaw 23,110
307: Chippewa 114,423