Skip to content

FEAT add pandas support - #552

Open
adrinjalali wants to merge 5 commits into
skops-dev:mainfrom
adrinjalali:feat/pandas-persistence
Open

adrinjalali wants to merge 5 commits into
skops-dev:mainfrom
adrinjalali:feat/pandas-persistence

Conversation

@adrinjalali

Copy link
Copy Markdown
Member

This adds pandas support. Since the CI is testing enough versions after pandas v2, I'm confident this wouldn't give us too many headaches.

Fixes #450

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Dtype reconstruction can invoke untrusted extension code, and some pandas state is not preserved correctly.

Review effort: Balanced
Findings: 1 High severity · 3 Medium severity · 2 Low severity

Open (6)
What changed in this PR

Adds pandas persistence support to skops.io, including support for estimators such as TargetEncoder.

Changes:

  • Adds pandas serializers, loaders, and trusted types.
  • Adds round-trip, cross-version, and integration tests.
  • Updates pandas dependencies and documentation.
File Description
skops/​io/​_pandas.py Implements pandas persistence nodes.
skops/​io/​_persist.py Registers pandas handlers lazily.
skops/​io/​_trusted_types.py Trusts supported pandas types.
skops/​io/​tests/​test_pandas.py Adds pandas persistence tests.
skops/​io/​tests/​data/​pandas-2.0.3.skops Adds pandas 2 compatibility fixture.
skops/​io/​tests/​data/​pandas-3.0.3.skops Adds pandas 3 compatibility fixture.
pyproject.toml Configures pandas test versions.
pixi.lock Updates resolved dependencies.
docs/​requirements.txt Raises the pandas documentation minimum.
docs/​persistence.rst Documents pandas support.
docs/​changes.rst Adds the release note.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread skops/io/_pandas.py Outdated
Comment thread skops/io/_pandas.py
Comment thread skops/io/_pandas.py
def extension_dtype_get_state(obj: Any, save_context: SaveContext) -> dict[str, Any]:
# Extension dtypes are rebuilt from their string form, e.g. "Int64",
# "datetime64[ns, UTC]" or "period[M]".
content = {"name": str(obj)}
@pytest.mark.filterwarnings("ignore")
def test_category_encoders_target_encoder():
# the report in https://github.com/skops-dev/skops/issues/450
ce = pytest.importorskip("category_encoders")
Comment thread docs/changes.rst Outdated
Comment thread docs/persistence.rst Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The new trusted deserialization surface and cross-version persistence format warrant final human security review.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
Resolved since last review (4)

This branch has not been deployed

No deployments
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.

skops can't load TargetEncoder object

2 participants