FEAT add pandas support - #552
Open
adrinjalali wants to merge 5 commits into
Open
adrinjalali wants to merge 5 commits into
adrinjalali wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
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
Open (6)
Avoid global dtype registry when reconstructing trusted pandas dtypes · New Preserve MultiIndex sortorder during reconstruction · New Preserve StringDtype storage metadata during round-trip · New Add category_encoders to CI to run the regression test · New Document omitted array frequencies and DataFrame flags · New Document omitted array frequencies and DataFrame flags · New
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.
| 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") |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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