Skip to content

Fix pandas StringDtype compatibility in anomalies module#362

Closed
fazelehh wants to merge 2 commits intomainfrom
fix-pandas-string-dtype-compat
Closed

Fix pandas StringDtype compatibility in anomalies module#362
fazelehh wants to merge 2 commits intomainfrom
fix-pandas-string-dtype-compat

Conversation

@fazelehh
Copy link
Collaborator

Summary

Fix test failures caused by pandas version differences in string dtype handling.

Changes

  • Use pd.api.types.is_string_dtype() instead of checking dtype == "object" in anomalies.py
  • Update test_anomalies.py to use is_string_dtype() for dtype assertions

Problem

Newer pandas versions infer string columns as StringDtype instead of dtype('O') (object), causing:

  • test_encode_categorical_columns to fail on dtype assertions
  • test_return_anomalies_idx to fail because string columns weren't being encoded

Solution

The pd.api.types.is_string_dtype() function handles both old (object) and new (StringDtype) pandas behavior.

Test plan

  • CI tests should now pass on all pandas versions

🤖 Generated with Claude Code

fazelehh and others added 2 commits January 25, 2026 10:37
- Use pd.api.types.is_string_dtype() instead of checking for dtype == "object"
- This handles both object dtype (older pandas) and StringDtype (newer pandas)
- Update test to use is_string_dtype() for dtype assertions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@fazelehh fazelehh closed this Jan 27, 2026
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