Skip to main content

blame

Cell-level "why" for pandas pipelines. No code changes.

Your report says 41,900 and it should say 38,400. Today you find that out by adding print statements down a thirty-step pipeline until something looks wrong. blame records the pipeline as it runs, so you can point at the number instead.

clicking the wrong number lights up the rows that made it

Install

pip install pandas-blame

Use

import blame, pandas as pd

with blame.trace():
    orders    = pd.read_csv("orders.csv")
    customers = pd.read_csv("customers.csv")
    clean     = orders[orders.qty > 0]
    joined    = clean.merge(customers, on="customer_id")
    report    = joined.groupby("region", as_index=False)["total"].sum()

print(blame.last_run().why(row=1, col="total"))
why(groupby.sum [f5] 3x2, row [1], column 'total')

  derivation:
    step   3 groupby.sum('region') [demo.py:9] <- f4:2 rows
    step   2 merge(on='customer_id') [demo.py:8] <- f3:1 row, f1:2 rows
    step   0 filter(<frame>) [demo.py:6] <- f0:1 row

  source rows:
    read_csv('customers.csv') [f1]: 2 row(s) -> [1, 4]
    read_csv('orders.csv') [f0]: 1 row(s) -> [1]

One order row, but two customer rows: customers.csv has customer_id 11 twice, so the merge duplicated that order and the group-by counted it twice. Two row numbers in two files, not "somewhere in these steps".

blame steps    # every operation the pipeline ran, with line numbers
blame ui       # the picture above: click a cell, watch its sources light up
blame diff     # what changed since the last run, and which input row did it

blame diff is the one that earns its keep in a test suite:

assert not before.diff(after, on="order_id").unexplained_rows()

Inputs that did not move should not produce outputs that did. When they do, blame names the input row responsible — or says plainly that none explains it, which means the pipeline changed rather than the data.

Honest limits

Lineage is exact for filters, slices, sorts, joins, group-bys, resample, concats, pivot, pivot_table, melt, unstack and the row-preserving transforms. It is approximate, and says so with a ~, for apply/map with a user function, and for operations it does not cover (transpose, stack, explode). Approximate answers are widened to every candidate row, never narrowed and never presented as exact — see docs/accuracy.md.

Capture costs about 2x wall time and 5 ms per step on a million rows (benchmarks). Tested on pandas 2.0.3, 2.2.3 and 3.0.5; the eight pandas documentation tutorials run under it with no exceptions, no changed results and no approximate steps (validation).

Status

Alpha, and honest about it. It works, it is tested against ground truth, and it has never been run on your pipeline. If it gets something wrong about a real one, that is the bug report worth filing. Roadmap.

Apache-2.0.

Metadata

Release files for pandas-blame 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pandas-blame 0.1.0
File Size Uploaded
pandas_blame-0.1.0.tar.gz 169.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pandas-blame 0.1.0
File Interpreter ABI Platform
pandas_blame-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 217.0 kB

Release files / pandas_blame-0.1.0.tar.gz

Download URL pandas_blame-0.1.0.tar.gz
Size 169.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7e7563b11d1c03d2fb5b8ade324548ca60d0c2b3e3e2ba8d17a51169caf45dd0
BLAKE2b-256 checksum
How to use checksums
e12e6b8d3c7832ec3f6c3f3b1990d875ecec417cccf872157833cce0e1b0ed26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / pandas_blame-0.1.0-py3-none-any.whl

Download URL pandas_blame-0.1.0-py3-none-any.whl
Size 47.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a345d2c560b10880f9c0fcaadeca40f7eff50fc2f0bc74259f09a5cd2ab510cd
BLAKE2b-256 checksum
How to use checksums
1da373e0848b7c1b9c2cbcb8d5eb5ca60423ccf4b9a18035ef5bab3f6b9baad2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release history Release notifications | RSS feed

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page