Skip to content

docs(examples): add pandera interoperability recipe#169

Merged
kevincostner17 merged 1 commit into
FreshCode-Org:mainfrom
naseem173:add-pandera-recipe
Jul 23, 2026
Merged

docs(examples): add pandera interoperability recipe#169
kevincostner17 merged 1 commit into
FreshCode-Org:mainfrom
naseem173:add-pandera-recipe

Conversation

@naseem173

@naseem173 naseem173 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Adds a runnable recipe to demonstrate pandera + freshdata interoperability:

  1. Validate a raw messy DataFrame with pandera (fails as expected).
  2. Clean with freshdata and validate again – demonstrates freshdata handles
    column renaming/type coercion but no null imputation, text normalisation for the user.
  3. Correct the remaining errors and test one last time (passes).

Fixes #160

Summary by CodeRabbit

  • New Features
    • Added an example demonstrating Pandera schema validation, data cleaning, and manual repair workflows.
    • The example covers handling invalid types, casing inconsistencies, missing values, and restricted status values.
  • Documentation
    • Added the new Pandera validation example to the examples guide.

@strix-security

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a runnable Pandera validation and repair recipe using an inline messy DataFrame, freshdata.clean, manual fixes, and final validation. The examples README links to the new script.

Changes

Pandera interoperability example

Layer / File(s) Summary
Validation and repair recipe
examples/09_pandera_recipe.py, examples/README.md
The new script validates raw and cleaned data with Pandera, repairs remaining null and casing issues, performs final validation, and is indexed in the examples table.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • #8 — Adds a validation recipe showing freshdata.clean(df) followed by schema validation, similar to the existing Great Expectations objective.

Suggested reviewers: johnnywilson-portfolio

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives a useful summary and links the issue, but it omits the template's Type of Change and Checklist sections. Add the Type of Change section and complete the checklist items required by the repository template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the new Pandera interoperability recipe added under examples.
Linked Issues check ✅ Passed The PR matches #160 by adding a runnable inline DataFrame recipe that validates with pandera before and after freshdata cleaning and indexes it in the README.
Out of Scope Changes check ✅ Passed The changes stay scoped to the new example script and its README index entry, with no obvious unrelated additions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 82463d1 and c01d247.

📒 Files selected for processing (2)
  • examples/09_pandera_recipe.py
  • examples/README.md

Comment thread examples/09_pandera_recipe.py
Comment thread examples/09_pandera_recipe.py

@kevincostner17 kevincostner17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: Ageage, Amount($)amount, Statusstatus
  • 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.pandas import (current API)

Nits (non-blocking)

  1. Install docs gap. examples/README.md still says pip install "freshdata-cleaner[ml]", but this script needs pandera and 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.

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

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

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

@kevincostner17
kevincostner17 merged commit 2e7be8e into FreshCode-Org:main Jul 23, 2026
16 checks passed
@kevincostner17

Copy link
Copy Markdown
Contributor

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 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

examples: add a pandera interoperability recipe (validate + repair)

2 participants