shashbha14 opened a new pull request, #49271: URL: https://github.com/apache/arrow/pull/49271
Fixes the pandas deprecation warnings we're seeing in the test suite. ## What was happening Pandas started warning when you create a `Categorical` with values that aren't in the categories list. We had a few places in the tests doing this: - `test_category`: Creating `cat_strings_with_na` with categories `['foo', 'bar']` but the data includes `'qux'` - `test_category_implicit_from_pandas`: Two places creating Categoricals with `['a', 'b', 'c']` but only allowing `['a', 'b']` in categories ## What I changed Instead of passing `categories` directly to `pd.Categorical()`, I: 1. Create the Categorical first with all the values 2. Then use `.set_categories()` to restrict it to what we want This is the recommended way to do it and avoids the warnings. ## Testing - Tests still pass (functionality unchanged) - No more deprecation warnings - No linter errors Fixes #49255 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
