Skip to content

Instantly share code, notes, and snippets.

@alexrutherford
Last active March 18, 2020 17:31
Show Gist options
  • Save alexrutherford/2a0467c2403e2b14ef6af43541bbac77 to your computer and use it in GitHub Desktop.
Save alexrutherford/2a0467c2403e2b14ef6af43541bbac77 to your computer and use it in GitHub Desktop.
# Grab data from https://drive.google.com/open?id=18IVEIp5qn4OnoWerC4f3e9MUwcBnM5U-
df = pd.read_excel('all_data_M_2018.xlsx')
df = df[df['o_group']=='detailed']
# Drop broad occupation groups
df = df[df['area']==99]
# Drop occupations for states, keep only those for the entire US
df = df[df['i_group'] == '4-digit']
# Drop 2 digit NAICS codes
df[pd.isna(df['tot_emp'])]
# Drop NAs in employment numbers
ceoDf = df[df['occ_code'] == '11-1011']
# Focus on CEOs only
ceoDf[ceoDf['naics']=='611100']
# Gives you 3 rows for CEOs in Elementary schools, with different ownerships
'''
naics naics_title own_code tot_emp
118921 611100 Elementary and Secondary Schools 235 9210
118922 611100 Elementary and Secondary Schools 5 930
118923 611100 Elementary and Secondary Schools 3 8270
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment