Commit ef5d543
fix(examples): guard against ZeroDivisionError in PII subset stats
Address CodeRabbit feedback on PR #1906
(examples/notebooks/data/build_pii_detection_subset.py around line 293).
The "Avg entities per PII-bearing row" stat computed
`entity_count / (len(rows) - rows_no_pii)`, which would raise ZeroDivisionError
if a user reused the script to build a subset where every row is an FP-test
row (no PII). The current 20-row subset has 17 PII / 3 no-PII rows so this
never trips in practice, but the build script is meant to be reusable.
Fix: extract `rows_with_pii = len(rows) - rows_no_pii`, guard with
`if rows_with_pii:`, and print "N/A (no PII-bearing rows in subset)" in the
fallback case.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 4f4d7fe commit ef5d543
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| 291 | + | |
291 | 292 | | |
292 | 293 | | |
293 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
294 | 298 | | |
295 | 299 | | |
296 | 300 | | |
| |||
0 commit comments