Skip to main content

Python library for retrieving BLS datasets

Project description


Making datasets easily accessible to python scripts.

Integrated datasets include:

For looking up BLS data via series-id lookups, please checkout OliverSherouse's library: BLS


>>> from bls_datasets import oes, qcew

# OES example:

>>> df_oes = oes.get_data(year=2017)
>>> df_oes.columns
       'A_MEAN', 'MEAN_PRSE', 'H_PCT10', 'H_PCT25', 'H_MEDIAN', 'H_PCT75',
       'H_PCT90', 'A_PCT10', 'A_PCT25', 'A_MEDIAN', 'A_PCT75', 'A_PCT90',
       'ANNUAL', 'HOURLY'],

# Which occupation had the highest total employment in 2017?

>>> detailed = df_oes[df_oes.OCC_GROUP == 'detailed']
>>> detailed[detailed.TOT_EMP == detailed.TOT_EMP.max()].OCC_TITLE
772    Retail Salespersons

# QCEW example:
>>> df_qcew = qcew.get_data('industry', rtype='dataframe', year='2017',
...             qtr='1', industry='10')
>>> df_qcew.columns
Index(['area_fips', 'own_code', 'industry_code', 'agglvl_code', 'size_code',
       'year', 'qtr', 'disclosure_code', 'qtrly_estabs', 'month1_emplvl',
       'month2_emplvl', 'month3_emplvl', 'total_qtrly_wages',
       'taxable_qtrly_wages', 'qtrly_contributions', 'avg_wkly_wage',
       'lq_disclosure_code', 'lq_qtrly_estabs', 'lq_month1_emplvl',
       'lq_month2_emplvl', 'lq_month3_emplvl', 'lq_total_qtrly_wages',
       'lq_taxable_qtrly_wages', 'lq_qtrly_contributions', 'lq_avg_wkly_wage',
       'oty_disclosure_code', 'oty_qtrly_estabs_chg',
       'oty_qtrly_estabs_pct_chg', 'oty_month1_emplvl_chg',
       'oty_month1_emplvl_pct_chg', 'oty_month2_emplvl_chg',
       'oty_month2_emplvl_pct_chg', 'oty_month3_emplvl_chg',
       'oty_month3_emplvl_pct_chg', 'oty_total_qtrly_wages_chg',
       'oty_total_qtrly_wages_pct_chg', 'oty_taxable_qtrly_wages_chg',
       'oty_taxable_qtrly_wages_pct_chg', 'oty_qtrly_contributions_chg',
       'oty_qtrly_contributions_pct_chg', 'oty_avg_wkly_wage_chg',

# What were the average weekly earnings in Fresno County for 2017 Q1?

# FIPS code, area title
# 06019, Fresno County, California

>>> fresno = df_qcew[(df_qcew.own_code == 0) & (df_qcew.area_fips == '06019')]
>>> fresno.avg_wkly_wage.values[0]


pip install bls-datasets


Documentation coming soon. Please reference the docstrings in the source code for now.

Notes on datasets


OES consists of occupational statistics, primarily: employment, age, and salary. To learn more about this survey, you can visit this link.

Note that due to idiosyncrasies in earlier OES datasets, this package only allows data access starting in 2014. Earlier files are available, although, they are given different naming patterns, are often broken into multiple excel spreadsheets due to size constraints of older excel version, and they do not always consist of the same datacuts. I will not integrate any earlier years, unless I see it necessary, or receive enough user requests.


QCEW consists of employer reported occupational statistics. Data can be cut/sliced by area, industry or company size. To learn more about this survey, you can visit this link

Common gotchas with QCEW data:

  • Datatypes are not always what you expect them to be. Reference the following tables when performing dataframe operations
  • Due to employer confidentiality, some of the figures may be unavailable. This is especially true when making more granular data cuts. Do check the disclosure_code columns for this.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for bls-datasets, version 0.0.9
Filename, size File type Python version Upload date Hashes
Filename, size bls_datasets-0.0.9-py3-none-any.whl (8.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size bls_datasets-0.0.9.tar.gz (6.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page