Skip to content

fix: support pandas 3 without regressing multilabel matching - #146

Merged
afermg merged 1 commit into
mainfrom
compat/pandas3
Sep 30, 2026
Merged

afermg merged 1 commit into
mainfrom
compat/pandas3

Conversation

@afermg

@afermg afermg commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Review scope

Follow-up to the merged #144. Rebased onto current main (3f4770c); this PR now contains only the pandas compatibility changes in db72f8e. Python version requirements and the existing Python CI matrix are unchanged.

Summary

  • Remove the temporary pandas<3 constraint introduced in feat: support Python 3.13/3.14 with pandas 2 #144.
  • Require DuckDB >=1.4.4: 1.4.2 and 1.4.3 reject pandas 3's inferred Python-backed str columns with Data type 'str' not recognized.
  • Normalize only pandas ExtensionArray cells in find_pairs_multilabel using .tolist(). This covers groupby().unique() string arrays without breaking NumPy integer/float32/bool arrays or whole-cell missing values, which unconditional apply(list) does.
  • Add 17 regression cases covering inferred Python/Arrow strings, grouped object/extension-array labels, numeric arrays, nullable arrays, missing/empty label cells, and unchanged input data.
  • Add a pandas 2/3 CI matrix on Python 3.11 and 3.14, explicitly testing the minimum DuckDB version and installing PyArrow. Use --no-sync during tests so the pandas 2 lockfile cannot silently replace the selected pandas major.
  • Keep the ordinary frozen CI matrix and pandas 2 lockfile; the dedicated compatibility jobs exercise pandas 3.

Runtime cost

Local normalization-only timings per 100,000 profiles (three labels each; median of nine runs, Python 3.12): ~13 ms for existing NumPy arrays (pandas 2.3.3), ~402 ms for Python-backed StringArrays, and ~604 ms for Arrow-backed StringArrays (pandas 3.0.6). Multilabel average_precision normalizes twice, for positive and negative pairs. These are synthetic preprocessing measurements, not total matching times or an overall slowdown estimate.

Validation

All runs use DuckDB 1.4.4:

Python pandas PyArrow Result
3.9 2.3.3 absent 83 passed, 2 optional Arrow cases skipped
3.14 2.3.3 25.0.1 85 passed
3.11 3.0.6 25.0.1 85 passed
3.12 3.0.6 25.0.1 85 passed
3.14 3.0.6 25.0.1 85 passed

Before the normalization fix, six of the new regression cases failed under pandas 3. After the fix, all pass.

After rebasing onto the merged #144, git range-diff confirms an unchanged patch and the resulting source tree is identical to the previously tested tree. Re-ran the 25 focused compatibility/multilabel tests under both pandas 2 and 3: all pass. ruff check, ruff format --check, uv lock --check, and git diff --check also pass.

Normalize pandas extension-array cells without changing native lists, NumPy arrays, or missing cells. Require DuckDB 1.4.4 for pandas 3 inferred string columns. Remove the temporary pandas cap and test both pandas majors with the minimum DuckDB version.
@afermg
afermg marked this pull request as ready for review September 30, 2026 18:13
@afermg
afermg merged commit de7125c into main Sep 30, 2026
13 checks passed
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.

1 participant