docs(examples): add pandera interoperability recipe#169
Conversation
|
Strix is installed on this repository, but we couldn't run this PR security review because this workspace's trial has ended. Add a card to resume code reviews here. |
📝 WalkthroughWalkthroughAdds a runnable Pandera validation and repair recipe using an inline messy DataFrame, ChangesPandera interoperability example
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/09_pandera_recipe.py`:
- Line 57: Update the status normalization in the repaired dataframe flow to
strip surrounding whitespace before lowercasing values, ensuring inputs such as
" shipped " become "shipped" and pass the existing Check.isin validation.
- Around line 5-6: Add Pandera to the dependency declaration used by the Pandera
recipe and ML example context in pyproject.toml, selecting a version range
compatible with the supported pandas>=1.5,<3 target. Ensure installing the
documented extra provides the pandera.pandas import used by
examples/09_pandera_recipe.py.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e69907f5-56a7-4f43-890d-67202ba3da0e
📒 Files selected for processing (2)
examples/09_pandera_recipe.pyexamples/README.md
kevincostner17
left a comment
There was a problem hiding this comment.
Verdict: Valid — approve with minor nits
I checked this against #160 acceptance criteria, ran the recipe locally on current main (v2.0.0), and inspected what fd.clean actually does to the sample frame.
Acceptance criteria (#160)
| Criterion | Status |
|---|---|
| Runs top-to-bottom on a small inline DataFrame, no external data | Pass |
Shows pandera schema check before and/or after fd.clean(df) |
Pass (before + after + post-repair) |
Indexed in examples/README.md |
Pass |
Naming 09_pandera_recipe.py (vs the issue’s pandera_recipe.py) is better — it matches the numbered examples series.
Local run (evidence)
Step 1: raw schema fails (null Age) — expected
Step 2: after fd.clean — still fails (preserved nulls; PENDING casing)
Step 3: median fill + .str.lower() — schema passes
Observed fd.clean output on the sample:
- Renames:
Age→age,Amount($)→amount,Status→status - Parses
$19.99→ float;"n/a"→ NaN (sentinel) - Strips
" shipped "→"shipped" - Does not impute nulls (v2.0 safe-by-default) and does not lowercase
PENDING
So the recipe’s teaching point (validate vs repair; freshdata doesn’t do everything) is accurate for v2.0.
What’s good
- Clear 3-step narrative: fail → clean → still fail → manual repair → pass
- Correctly demonstrates complementarity with pandera (same framing as GE recipes)
- Scoped, small diff (+66), CI green
- Uses
pandera.pandasimport (current API)
Nits (non-blocking)
-
Install docs gap.
examples/README.mdstill sayspip install "freshdata-cleaner[ml]", but this script needspanderaand it is not in the[ml]extra. Please add a run hint in the module docstring, e.g.:# Run: # pip install "freshdata-cleaner" pandera # python examples/09_pandera_recipe.py
Optionally also note it next to the README table row. Without this, first-time runners hit
ModuleNotFoundError: pandera. -
Defensive status normalize (CodeRabbit). Prefer:
repaired["status"] = repaired["status"].str.strip().str.lower()
After
fd.clean, whitespace is already stripped, so today’s path works — but strip+lower makes the manual repair step self-contained if someone copies it elsewhere. -
Step 2 message is slightly incomplete. The print says freshdata “doesn't impute nulls or normalize casing,” which is true for those two issues, but this clean pass does rename columns, parse currency, convert sentinels, and strip whitespace. A one-line tweak would avoid underselling what freshdata already fixed.
-
Optional from #160: a short FAQ/docs paragraph was suggested but not required by acceptance criteria — fine to leave for a follow-up.
Conclusion
Valid PR. Merges cleanly against #160’s goals; recipe runs; pedagogy matches v2.0 defaults. Happy to see the install hint (+ optional strip) landed either in this PR or a tiny follow-up.
|
Great work on this, @naseem173 — thank you for the contribution! This is a clean, useful first PR: the Pandera recipe is clear, runnable, and a nice example of how validation and cleaning complement each other. Really appreciate you picking up #160 and landing it for the community. Looking forward to more contributions from you 🙌 |
Adds a runnable recipe to demonstrate pandera + freshdata interoperability:
column renaming/type coercion but no null imputation, text normalisation for the user.
Fixes #160
Summary by CodeRabbit