Compare manufacturing orders and inventory in Python
Compare machinery and transportation equipment using Census M3 shipments, new orders, backlogs, inventories and published ratios.
Compare orders, shipments and inventory across industries
A business analyst tracking manufacturing activity wants to know whether incoming orders are keeping pace with shipments and how much inventory is held. This example compares the national machinery and transportation equipment groups in December 2025 using Census M3 estimates. It combines monthly flows, month-end stocks and a published inventory ratio into a compact industry comparison.
The optional input.csv contains two genuine M3 industry choices: machinery (33S) and transportation equipment (36S). The same choices appear in the selections list in the Python code below. These are industry groups, not fictional company records.
Download monthly_observations.csv into your working folder. It is a genuine subset of the purchased table: 864 monthly source cells for these two groups during 2024–2025, with all nine measures, both adjustments and all 20 fields unchanged. The full $29 edition supplies 309,600 reported values across 760 series and 87 industry/aggregate groups, plus explicit gaps, definitions and historical coverage. Inspect the full product.
Code example
This standard-library code runs in a notebook cell, IPython or a script. It selects seasonally adjusted observations for one month and checks that the needed values and units are present before comparing them.
Paths are relative to your working folder; use from pathlib import Path; print(Path.cwd()) to check it, or supply full paths.
"""Compare national machinery and transportation manufacturing in December 2025."""
import csv
from decimal import Decimal
# Real M3 industry choices, also provided in input.csv.
selections = [{'industry_code': '33S'}, {'industry_code': '36S'}]
month = '2025-12'
measures = {'VS': 'shipments_millions', 'NO': 'new_orders_millions',
'UO': 'backlog_millions', 'TI': 'inventory_millions',
'IS': 'inventory_shipments_ratio'}
wanted = {r['industry_code'] for r in selections}
lookup = {}
with open('monthly_observations.csv', newline='', encoding='utf-8') as source:
for row in csv.DictReader(source):
if (row['industry_code'] in wanted and row['month'] == month
and row['seasonal'] == 'A' and row['measure_code'] in measures):
expected_unit = 'ratio' if row['measure_code'] == 'IS' else 'millions_of_current_dollars'
if row['availability'] != 'reported' or row['unit'] != expected_unit:
raise ValueError('Inspect the source availability or units')
key = (row['industry_code'], row['measure_code'])
if key in lookup:
raise ValueError(f'Duplicate industry/measure: {key}')
lookup[key] = row
results = []
for selection in selections:
code = selection['industry_code']
if any((code, m) not in lookup for m in measures):
raise ValueError(f'Comparison is incomplete for {code}')
result = {'industry_code': code, 'industry': lookup[code, 'VS']['industry_name']}
result.update({label: lookup[code, m]['value'] for m, label in measures.items()})
# A derived difference between two monthly flows, not a direct backlog change.
result['orders_less_shipments_millions'] = str(
Decimal(result['new_orders_millions']) - Decimal(result['shipments_millions']))
results.append(result)
print(f"{result['industry']} | shipments ${result['shipments_millions']}m | "
f"new orders ${result['new_orders_millions']}m | "
f"orders less shipments ${result['orders_less_shipments_millions']}m | "
f"backlog ${result['backlog_millions']}m | inventory ${result['inventory_millions']}m | "
f"inventory/shipments {result['inventory_shipments_ratio']}")
Analysis of the output
Machinery | shipments $40038m | new orders $40255m | orders less shipments $217m | backlog $144673m | inventory $103987m | inventory/shipments 2.60
Transportation Equipment | shipments $102530m | new orders $114376m | orders less shipments $11846m | backlog $961402m | inventory $187734m | inventory/shipments 1.83
Machinery shipments were $40,038 million and new orders were $40,255 million. Orders exceeded shipments by $217 million. The group held $144,673 million in backlog and $103,987 million in inventory at month end; its published inventory-to-shipments ratio was 2.60.
Transportation equipment had a larger monthly gap: $114,376 million of new orders against $102,530 million of shipments, a difference of $11,846 million. Its backlog was $961,402 million, while the inventory-to-shipments ratio was 1.83. These measures help separate current activity from outstanding orders and stock already held.
The gap calculated by the code compares two flows during the month. It is not presented as an exact change in the separately adjusted backlog series. Backlogs and inventory are month-end stocks; adding them over months would not produce an annual total. All dollar amounts are nominal, and a lower inventory ratio alone does not establish better management or profitability.
Add context for a manufacturing analysis
Manufacturing activity, prices and labor brings together the relevant starting files. Producer-price history describes prices received, employment history adds jobs and hours, and annual productivity data describes output per hour and unit labor costs. Review the industry definitions and survey populations before aligning them; the products do not supply an automatic crosswalk.
Using the full dataset
Extract the purchased ZIP and replace the sample with its complete monthly_observations.csv. The code runs unchanged. Change month and the inline selections, or load your own CSV of M3 industry codes. Keep identifiers as text. The unique observation key is series_id + month.
series.csv records each series’ actual first and last reported month. industries.csv supplies historical group names with documentation page references; measures.csv explains units, flows, stocks and ratios. M3 codes such as 33S are not generic NAICS codes, and overlapping aggregates must not be added together.
coverage.csv distinguishes reported values, source blanks, explicit NA and years with no source row. Missing values are not zero. The separate semiconductor history ends in March 2010; Census discontinued that detail in April 2010 while retaining it in applicable aggregates. Orders exclude semiconductors.
The example uses the published inventory/shipments ratio (IS). The separate backlog/shipments ratio (US) excludes industries without unfilled orders and semiconductors, so its denominator is not all manufacturing shipments. Ratios retain the publisher’s definition and two-decimal precision. The original XML number remains in raw_value when a tiny binary-storage tail is removed from value.
Sources and versions
Source: Census M3 historical NAICS workbooks, modified November 3 and captured November 7, 2026 UTC. This edition contains January 1992–December 2025 where available, as revised in that snapshot. Partial 2026 is excluded. Source capture dates are not observation dates or original-release vintages.
Census’s definitions and methodology explain the measures and nonprobability survey panel. Inventories use non-LIFO costs; estimates are not inflation adjusted. The May 2025 benchmark uses the 2022 Economic Census on a 2017 NAICS basis.
Census supplies the source workbooks free. ACD sells preparation, checks, documentation and delivery. Processing improvements and publisher error corrections to this purchased edition are included; future source publications may be sold separately. Read the source and preparation record.
Example checked November 7, 2026 against both these samples and the complete purchased files. Source and processing records, sample checksums · Expected result CSV. Independent preparation; no agency endorsement.