Skip to content

GH-51302: [Python] Avoid deprecated .values call in pandas->pyarrow conversion - #51484

Merged
AlenkaF merged 2 commits into
apache:mainfrom
jorisvandenbossche:gh-51302-pandas-values
Oct 1, 2026
Merged

AlenkaF merged 2 commits into
apache:mainfrom
jorisvandenbossche:gh-51302-pandas-values

Conversation

@jorisvandenbossche

@jorisvandenbossche jorisvandenbossche commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Rationale for this change

Pandas has deprecated certain aspects of .values (when it looses information), which our pandas->pyarrow conversion currently relies upon. So updating that code path to avoid this usage.

What changes are included in this PR?

Removed usage of .values for the deprecated cases (period, interval, datetimetz). In the custom get_values, we already avoided this for period and interval, added a special case for converting datetimetz to a numpy array. And ensured that other cases were we did a direct .values goes through this get_values helper.

Are these changes tested?

Yes, I added more tests first to ensure full coverage of all cases that might run into the deprecation (e.g. the Schema.from_pandas(df) or pa.array(EA) with period/datetimetz dtypes were not currently covered)

Are there any user-facing changes?

No

Was AI used for this PR?

No

@jorisvandenbossche

Copy link
Copy Markdown
Member Author

@github-actions crossbow submit test-conda-python-3.14-pandas-nightly-numpy-nightly

@github-actions

Copy link
Copy Markdown

Revision: 800fb5a

Submitted crossbow builds: ursacomputing/crossbow @ actions-883d546e1c

Task Status
test-conda-python-3.14-pandas-nightly-numpy-nightly GitHub Actions

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The threaded DataFrame path still accesses .values for timezone-aware columns, and tests do not assert warning-free behavior.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR updates pandas-to-PyArrow conversion to avoid deprecated .values access for timezone-aware, period, and interval dtypes.

Changes:

  • Added dtype-aware pandas value extraction.
  • Updated array conversion and DataFrame type inference.
  • Expanded pandas and schema tests.
File Summary
python/​pyarrow/​tests/​test_schema.py Adds schema coverage across supported pandas types.
python/​pyarrow/​tests/​test_pandas.py Adds conversion and round-trip tests.
python/​pyarrow/​pandas-shim.pxi Adds timezone-aware datetime handling.
python/​pyarrow/​pandas_compat.py Updates DataFrame type inference.
python/​pyarrow/​array.pxi Routes array-like inputs through shared value extraction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/pyarrow/pandas_compat.py
@jorisvandenbossche

Copy link
Copy Markdown
Member Author

The nightly crossbow build now shows no related warnings anymore

Copilot AI review requested due to automatic review settings September 24, 2026 13:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review issues remain.

Review effort: Lite
Findings: None

Resolved since last review (1)

@raulcd raulcd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorisvandenbossche this is a release blocker, right? I just have one question even though I am not an expert on the area, @AlenkaF do you want to take a look?

Comment thread python/pyarrow/pandas_compat.py
@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Oct 1, 2026

@AlenkaF AlenkaF left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Happy to merge if my understanding of the .values call in pandas_compat.py is correct.

@AlenkaF
AlenkaF merged commit 6f161d6 into apache:main Oct 1, 2026
43 checks passed
@AlenkaF AlenkaF removed the awaiting changes Awaiting changes label Oct 1, 2026
@jorisvandenbossche
jorisvandenbossche deleted the gh-51302-pandas-values branch October 1, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants