How to Read MSHA's Mine Data Set in Python
On this page
Problem statement
The Mine Safety and Health Administration (MSHA) registers every mine in the United States, from coal mines and copper pits to the sand and gravel pit down the road, and publishes the register as the Mines data set: 92,090 mines, 59 columns, updated every week. It is the source for any map or count of American mines, and the key that joins MSHA's employment, production, inspection and accident files. Read with defaults it breaks those joins, because pandas turns the seven-digit mine id into a number. This page reads it properly and walks through the ids, statuses, commodities, positions and employees.
Quick answer
Read the pipe-delimited file and look at the first rows and the types pandas guesses:
print(mines[["MINE_ID", "CURRENT_MINE_NAME", "COAL_METAL_IND", "CURRENT_MINE_TYPE", "CURRENT_MINE_STATUS", "STATE", "FIPS_CNTY_CD"]].head(3).to_string(index=False))
print(mines.dtypes[["MINE_ID", "FIPS_CNTY_CD", "LATITUDE", "NO_EMPLOYEES"]].to_string())
MINE_ID CURRENT_MINE_NAME COAL_METAL_IND CURRENT_MINE_TYPE CURRENT_MINE_STATUS STATE FIPS_CNTY_CD
100003 O'Neal Quarry & Mill M Surface Active AL 117
100004 Brierfield Quarry M Surface Active AL 7
100005 Birmingham Plant M Surface Abandoned AL 73
MINE_ID int64
FIPS_CNTY_CD int64
LATITUDE float64
NO_EMPLOYEES float64
The first rows are Alabama quarries: O'Neal Quarry & Mill and Brierfield Quarry, active, and a Birmingham plant, abandoned. pandas has read MINE_ID as an integer, 100003, and the county code too, so Brierfield's county is 7. Both should be text.
Ids, status, commodity and position
1. Ids and codes as numbers
print(f"MINE_ID as read: {mines.MINE_ID.iloc[0]!r}; unique: {mines.MINE_ID.is_unique}")
mines = pd.read_csv(Z.open("Mines.txt"), sep="|", encoding="latin-1", dtype=str, low_memory=False)
print(f"read as text: {mines.MINE_ID.iloc[0]!r}; lengths {mines.MINE_ID.str.len().value_counts().to_dict()}; county code lengths {mines.FIPS_CNTY_CD.str.len().value_counts().to_dict()}")
MINE_ID as read: np.int64(100003); unique: True
read as text: '0100003'; lengths {7: 92090}; county code lengths {3: 92090}
Read as a number the id loses its leading zero: MSHA's id is "0100003", seven characters for every one of the 92,090 mines, with the first two digits a Bureau of Mines state code. Read with dtype=str, every id keeps its seven characters and the county code its three. The county code is only the county part of a FIPS code; the state has to be added before it joins to anything.
2. Status
print(mines.CURRENT_MINE_STATUS.value_counts().to_string())
d = pd.to_datetime(mines.CURRENT_STATUS_DT, format="%m/%d/%Y", errors="coerce")
print(f"status dates from {d.min():%Y} to {d.max():%Y-%m-%d}; unparseable: {d.isna().sum()}")
CURRENT_MINE_STATUS
Abandoned 69608
Abandoned and Sealed 8823
Active 6667
Intermittent 5432
Temporarily Idled 902
NonProducing 369
New Mine 289
status dates from 1925 to 2026-10-22; unparseable: 0
Most of the file is history: 69,608 mines are abandoned and 8,823 abandoned and sealed. 6,667 are active and 5,432 intermittent, working only part of the year, with a few hundred idle, non-producing or new. The status dates run from 1925 to the week before the file was published, so the file also records when each mine closed.
3. Coal and the rest
print(pd.crosstab(mines.PRIMARY_CANVASS.fillna("none"), mines.CURRENT_MINE_TYPE.fillna("none")).to_string())
CURRENT_MINE_TYPE Facility Surface Underground none
PRIMARY_CANVASS
Coal 3407 17600 14576 39
Metal 574 2207 2237 2
Nonmetal 674 3676 273 1
SandAndGravel 268 30224 4 6
Stone 625 15126 300 2
none 10 98 15 146
Coal is the largest group, 17,600 surface and 14,576 underground mines and 3,407 coal facilities such as preparation plants. Sand and gravel pits are almost all surface operations, 30,224 of them, and stone quarries are 15,126 surface sites. Metal mines, a small group, are as often underground, 2,237, as on the surface, 2,207.
4. Positions
for c in ["LATITUDE", "LONGITUDE", "NO_EMPLOYEES"]:
mines[c] = pd.to_numeric(mines[c], errors="coerce")
print(f"with coordinates: {mines.LATITUDE.notna().sum():,} of {len(mines):,}; longitudes above 0: {(mines.LONGITUDE > 0).sum()}")
print(mines.groupby("CURRENT_MINE_STATUS").LATITUDE.apply(lambda s: s.notna().mean()).round(3).to_string())
with coordinates: 47,791 of 92,090; longitudes above 0: 0
CURRENT_MINE_STATUS
Abandoned 0.368
Abandoned and Sealed 0.998
Active 0.999
Intermittent 0.991
New Mine 0.152
NonProducing 1.000
Temporarily Idled 0.997
47,791 of the 92,090 mines have coordinates. Almost every active, intermittent, idle and sealed mine has a position, but only 36.8% of abandoned mines do, because most of them closed before positions were recorded. A map of the Mines file shows today's mines well and the past badly.
Mines by state and their size
The data used on this page
The US Mine Safety and Health Administration's Open Government Data sets: the Mines file of every mine ever registered, annual employment and production by mine since 2000, and the accident reports from 2000 on (24 of their 57 columns, without the narratives), all as published on 23 October 2026, downloaded on 28 October 2026 and saved on this site, because MSHA replaces the files every week. Public domain. The files are pipe-delimited and Latin-1 encoded.
from pathlib import Path
import zipfile
import geopandas as gpd
import numpy as np
import pandas as pd
import requests
Path("data").mkdir(exist_ok=True)
# MSHA's Mines file, annual employment and production by mine since 2000 and accident reports since 2000 (24 columns,
# no narratives), all of 23 October 2026, with the Census Bureau's county estimates, counties and states. Saved
# 28 October 2026: MSHA replaces the files every week.
# Live: https://arlweb.msha.gov/OpenGovernmentData/DataSets/Mines.zip (and MinesProdYearly.zip, Accidents.zip)
ARCHIVE = "msha-mines-2026-10-28.zip"
if not Path(f"data/{ARCHIVE}").exists():
Path(f"data/{ARCHIVE}").write_bytes(requests.get(f"https://data.spatialworkflow.io/{ARCHIVE}", timeout=900).content)
Z = zipfile.ZipFile(f"data/{ARCHIVE}")
for f in ["cb_2024_us_county_20m.zip", "cb_2024_us_state_20m.zip"]:
Path(f"data/{f}").write_bytes(Z.read(f))
mines = pd.read_csv(Z.open("Mines.txt"), sep="|", encoding="latin-1", low_memory=False)
print(f"MSHA Mines file: {len(mines):,} mines, {mines.shape[1]} columns")
MSHA Mines file: 92,090 mines, 59 columns
Example 1: mines by state
print(mines.STATE.value_counts().head(8).to_string())
act = mines[mines.CURRENT_MINE_STATUS == "Active"]
print(act.STATE.value_counts().head(5).to_dict())
STATE
KY 14085
WV 7157
PA 6399
VA 4607
TX 3665
AL 2605
NY 2577
CO 2542
{'TX': 623, 'PA': 408, 'CA': 300, 'TN': 262, 'MO': 227}
Kentucky has the most mines in the file, 14,085, then West Virginia and Pennsylvania: the coalfields of Appalachia, mostly abandoned now. Counting active mines only, Texas leads with 623, then Pennsylvania, California, Tennessee and Missouri, states with many quarries and pits.
Example 2: employees at active mines
print(act.NO_EMPLOYEES.describe(percentiles=[0.5, 0.9, 0.99]).round(0).to_string())
print(act.nlargest(4, "NO_EMPLOYEES")[["CURRENT_MINE_NAME", "STATE", "PRIMARY_CANVASS", "NO_EMPLOYEES"]].to_string(index=False))
count 6661.0
mean 26.0
std 104.0
min 1.0
50% 8.0
90% 44.0
99% 405.0
max 5870.0
CURRENT_MINE_NAME STATE PRIMARY_CANVASS NO_EMPLOYEES
Freeport-McMoRan Morenci Inc. AZ Metal 5870.0
Freeport-McMoRan Bagdad Inc AZ Metal 1386.0
North Antelope Rochelle Mine WY Coal 1207.0
South Area NV Metal 1200.0
Active mines are small: the median reports 8 employees and nine in ten report 44 or fewer. The largest is Freeport-McMoRan's Morenci copper mine in Arizona with 5,870, then its Bagdad mine, the North Antelope Rochelle coal mine in Wyoming and an operation in Nevada called South Area. NO_EMPLOYEES is what the operator reported on its information form, not an annual average.
Internal links
- MSHA's mine data explained β what counts as a mine, and getting the data without code
- Ids that lose their zeros β the join this page protects
- Mines with no coordinates β half the file has none
- Active mines by county β the mines on a map