#!/usr/bin/env python # coding: utf-8 # # BLS MSA stats # # By Andy Wheeler # # See blog post, [Use circles instead of choropleth for MSAs](https://andrewpwheeler.com/2022/03/13/use-circles-instead-of-choropleth-for-msas/) for overview. # # This scrapes the data from BLS website for particular employment codes. # In[1]: # Creating example bls maps from bls_geo import * # can check out https://www.bls.gov/oes/current/oes_stru.htm # or use this function os_cats = ocodes() os_cats # In[2]: # can check out https://www.bls.gov/oes/current/oes_stru.htm bio = '172031' bio_stats = oes_geo(bio) areas = get_areas() # this takes a few minutes state = state_albers() geo_bio = merge_occgeo(bio_stats,areas) ax = geo_bio.plot(column='Employment',cmap='inferno',legend=True,zorder=2) state.boundary.plot(ax=ax,color='grey',linewidth=0.5,zorder=1) ax.set_ylim(0.1*1e6,3.3*1e6) ax.set_xlim(-0.3*1e7,0.3*1e7) # lower 48 focus (for Albers proj) ax.set_axis_off() plt.show() # In[3]: # Can export to excel (csv parsing is tough, maybe use tsv instead) bio_stats.to_excel('biojobs.xlsx') att = ['areaName','Employment','Location Quotient','Employment per 1,000 jobs','Annual mean wage'] form = ['',',.0f','.2f','.2f',',.0f'] map_bio = fol_map(geo_bio,'Employment',['lat', 'lon'],att,form) #map_bio.save('biomap.html') map_bio # In[4]: # Data science jobs ds = '152051' ds_stats = oes_geo(ds) geo_ds = merge_occgeo(ds_stats,areas) geo_ds.sort_values(by='Employment',inplace=True,ascending=False) lim_fields = ['areaName','Employment','Annual mean wage','Annual 75th percentile wage'] geo_ds[lim_fields].head(10) # In[ ]: