Repository navigation
[python] Migrate dataframe computation to Narwhals with pandas compatibility - #587
Draft
brunocarlin wants to merge 88 commits into
Draft
brunocarlin wants to merge 88 commits into
brunocarlin wants to merge 88 commits into
Conversation
…bels and benchmarks
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.
Polars inputs previously encountered pandas-specific edits, statistics and result pipelines. This contribution moves eager dataframe processing to
narwhals.stable.v2, retaining native pandas/Polars/Arrow model batches and typed result storage while preserving the existing writable pandas API. Refs #575.Python >=3.10 is proposed, dropping 3.9; Python 3.14 is primary. Runtime minimums are pandas 1.5.3 and Narwhals 2.0, without speculative future-major caps. Only actual tested versions are compatibility evidence. Current stable pandas is 3.1.0; no pandas 4 release exists. The available 3.2 development build is tested separately. Maintainer review of the minimum-version change is requested.
Scope and compatibility
result_as()provides independent typed exports. Incompatible mixed scalar/large-integer columns require explicit partitions rather than silent narrowing. Native observation snapshots retain precise metadata.Validation status
Latest source af6b862 streamlines Gaussian numerical work, clean-float importance means and CP metadata writes, and completes native fairness console preparation. Local checks pass: 177 targeted kernel cases, 490 integration/plot cases, 65 new Gaussian/console cases, 107 minimum-stack cases and 107 pandas-nightly cases. All 29 numerical outputs and 114 private/text outputs match unmodified upstream. Exact-source full CI is running; the preceding checkpoint does not certify these latest changes.
Validated checkpoint fdb23b0: 22/22 fork CI jobs passed. Downloaded artifacts verify:
The stronger nonlinear reference case exposed an RNG-reset error missed by earlier linear examples; fdb23b0 fixes the shared serial stream across hierarchy cuts. Comparisons use a documented NumPy spelling shim for the untouched reference. Consolidation report and source fingerprints · Integration map.
Benchmarks and regressions
Fresh alternating-source measurements are running for af6b862, using identical saved fitted models, data/target hashes, seeds and settings. They include conversion from original Polars frames, explanation fitting and compatible result publication; elapsed phases, sampled RSS and numerical outcomes are retained. Results will be reported with their exact source, including regressions.
Earlier end-to-end measurements belong to 080f946, not these later commits. They reported native Polars advantages for the measured original-Polars workflows, but pandas importance remained about 20% slower and partial/conditional explanation calculations about 45–50% slower than untouched upstream. Wide-frame Polars RSS was higher. Those results remain historical until remeasurement. Full previous trials and limitations.
Separate plotting-only measurements are source-stamped: CP and fairness. The fairness case includes a pandas timing regression and pandas/Polars RSS increases. Plotting gains do not establish faster explanation fitting.
Boundaries and review
Pandas remains required for writable legacy results, index/dtype/scalar formatting and the external PPS call. NumPy/SciPy, estimator and tensor boundaries are explicit. PPS dependency constraints and SHAP's automatic GIL fallback remain upstream limitations. Exact incompatible axes require separate selections; automatic interpolation retains its floating-grid policy. Raw LightGBM dictionary/Enum inputs and older sklearn/modern-Polars combinations need the documented model-owned bridges. Lazy/distributed/GPU execution, other engines, multiclass, arbitrary objects and arbitrary extension concurrency are uncertified.
Compatibility reference is pinned to upstream
77ea3ad9580a3b68aaa94d8dca75d11bd527848f. No upstream default-branch writes or merge are performed. Fork CI does not imply approval of upstream workflow execution. This PR remains draft and unmerged for the author's manual review. Prepared with AI assistance (Codex); no maintainer approval of AI-assisted contributions is implied.