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.1

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.1
File Size Uploaded
pandas_blame-0.1.1.tar.gz 169.1 kB Details

Built distribution (wheel)

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

Total release size: 217.1 kB

Release files / pandas_blame-0.1.1.tar.gz

Download URL pandas_blame-0.1.1.tar.gz
Size 169.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9f995f5b8250a32281be83d1b8186a28553f5e4af9b83d7872abcc8433938a4a
BLAKE2b-256 checksum
How to use checksums
540cf44944ee783d3202cede233546fdb8136918e9fed4f12f915549a7aa8428
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.1-py3-none-any.whl

Download URL pandas_blame-0.1.1-py3-none-any.whl
Size 48.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ce433f968d2a68ec81a2f75e6c7d0a2bd2176fb192c06e6a61e5cb9b61c052d
BLAKE2b-256 checksum
How to use checksums
f48d56bd51219bd61d871f5ca3496928b410a554e0e14a493ab25b2202ef6549
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

This release

0.1.1 This release

2 release files

0.1.0

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