Skip to content

GH-49255: [Python] Fix pandas Categorical DeprecationWarnings in tests#50543

Merged
rok merged 3 commits into
apache:mainfrom
GujaLomsadze:fix-categorical-deprecation-49255
Jul 18, 2026
Merged

GH-49255: [Python] Fix pandas Categorical DeprecationWarnings in tests#50543
rok merged 3 commits into
apache:mainfrom
GujaLomsadze:fix-categorical-deprecation-49255

Conversation

@GujaLomsadze

@GujaLomsadze GujaLomsadze commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

pandas 3.0.0 deprecated constructing or casting to a Categorical with
non-NA values that are not present in the specified dtype.categories.
This surfaces as DeprecationWarnings in the PyArrow
test suite when run against pandas >= 3.0 (GH-49255), in test_category
and test_category_implicit_from_pandas.

What changes are included in this PR?

  • test_category: remove the cat_strings_with_na column (relied on
    silent 'qux' -> NaN; redundant, cat_strings already carries nulls).
  • test_category_implicit_from_pandas: use explicit None
    (['a','b',None]) instead of out-of-category 'c'.

Are these changes tested?

Yes - test-only. Verified no DeprecationWarning under pandas 3.0.3.

Are there any user-facing changes?

No.

Closes #49255.

@GujaLomsadze

Copy link
Copy Markdown
Contributor Author

pandas-dev/pandas#40996

@rok rok 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.

This seems good, I would add erroring on deprecation warning to pytest perhaps so we don't backslide.

@rok
rok merged commit 59c3872 into apache:main Jul 18, 2026
36 checks passed
@rok rok removed the awaiting review Awaiting review label Jul 18, 2026
@AlenkaF

AlenkaF commented Jul 18, 2026

Copy link
Copy Markdown
Member

Yay, thanks for the contribution @GujaLomsadze! 🎉

@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 59c3872.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 44 possible false positives for unstable benchmarks that are known to sometimes produce them.

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.

[Python] Fix DeprecationWarnings in PyArrow tests

3 participants