pandas2df: convert Arrow / extension-array columns (pandas 3 ready, pin retained) - #9
Merged
Merged
Conversation
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.
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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.
Makes nat.python ready for pandas 3 without changing the default install:
pandas2df()learns to convert pandas extension-array columns, butsimple_python()keeps thepandas < 3pin as the default (per maintainer decision, until the wider ecosystem settles). Supersedes #8 (auto-closed when its stacked base merged).Changes
R/convert.R—pandas2df()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 internalis_string_dtype()helper + tests exercisingstring[pyarrow]andint64[pyarrow].R/env.R— comment updated to record thatpandas2df()handles the Arrow dtype while thepandas < 3pin is deliberately retained (no behaviour change; still installspandas<3).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<3→pandas).🤖 Generated with Claude Code