Skip to content

pandas2df: convert Arrow / extension-array columns (pandas 3 ready, pin retained) - #9

Merged
jefferis merged 2 commits into
mainfrom
pandas3-support
Sep 12, 2026
Merged

jefferis merged 2 commits into
mainfrom
pandas3-support

Conversation

@jefferis

Copy link
Copy Markdown
Member

Makes nat.python ready for pandas 3 without changing the default install: pandas2df() learns to convert pandas extension-array columns, but simple_python() keeps the pandas < 3 pin as the default (per maintainer decision, until the wider ecosystem settles). Supersedes #8 (auto-closed when its stacked base merged).

Changes

  • R/convert.Rpandas2df() now converts pandas extension-array columns that reticulate leaves as raw python objects, in particular pandas 3.0's default Arrow-backed string dtype (PDEP-14): string columns become R character vectors, and other Arrow columns (e.g. int64[pyarrow] ids) map to the same R types as their native-dtype equivalents. New internal is_string_dtype() helper + tests exercising string[pyarrow] and int64[pyarrow].
  • R/env.R — comment updated to record that pandas2df() handles the Arrow dtype while the pandas < 3 pin is deliberately retained (no behaviour change; still installs pandas<3).
  • NEWS.md — notes the new conversion support and that the pin is kept as a caution.

Verification

The conversion code was verified on CI against real pandas 3.0.5 (during development, via a temporary unpin): test-coverage FAIL 0 SKIP 0 PASS 140; R-CMD-check FAIL 0 SKIP 3 (the pyarrow-gated Arrow tests skip only where pyarrow is absent). This PR keeps the pin, so its own CI runs on pandas 2.x + pyarrow. Lifting the pin later is a one-line change in R/env.R (pandas<3pandas).

🤖 Generated with Claude Code

Recover pandas extension-array columns that reticulate leaves as raw python
objects -- above all pandas 3.0's default Arrow-backed string dtype (PDEP-14).
String columns (is_string_dtype: str/string/large_string family) become R
character vectors; other Arrow columns (e.g. int64[pyarrow]) are classified
like object columns, so Arrow-backed ids map to the same R types as native
ones. Adds tests using explicit Arrow dtypes (reproducing the ArrowStringArray
under pandas 2 + pyarrow) and regenerates pandas2df.Rd.
@jefferis
jefferis merged commit 82f27a4 into main Sep 12, 2026
4 checks passed
@jefferis
jefferis deleted the pandas3-support branch September 12, 2026 08:24
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.66%. Comparing base (f226dda) to head (847ce01).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
R/convert.R 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #9      +/-   ##
==========================================
+ Coverage   66.18%   66.66%   +0.48%     
==========================================
  Files           6        6              
  Lines         485      495      +10     
==========================================
+ Hits          321      330       +9     
- Misses        164      165       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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