Skip to content

Use pandas type checking for numeric dtype detection in Altair backend#2917

Merged
EwoutH merged 1 commit intomainfrom
altair_dtype
Dec 4, 2025
Merged

Use pandas type checking for numeric dtype detection in Altair backend#2917
EwoutH merged 1 commit intomainfrom
altair_dtype

Conversation

@EwoutH
Copy link
Copy Markdown
Member

@EwoutH EwoutH commented Dec 3, 2025

Replace np.issubdtype() with pandas.api.types.is_numeric_dtype() to fix compatibility with pandas 3.0's new StringDtype.

NumPy's np.issubdtype() cannot handle pandas ExtensionDtype objects, particularly the new StringDtype introduced as default in pandas 3.0. This caused TypeError when checking if color columns were numeric:

"Cannot interpret '<StringDtype(storage='python', na_value=nan)>' as a data type"

Using pandas' is_numeric_dtype() provides several benefits:

  • Correctly handles all pandas dtypes (native NumPy and extension types)
  • Works with numeric extension dtypes (Int64, Float64, Decimal, etc.)
  • Compatible with both pandas 2.x and 3.x
  • More semantically clear - checks if data is numeric rather than checking dtype inheritance hierarchy

Replace np.issubdtype() with pandas.api.types.is_numeric_dtype() to fix compatibility with pandas 3.0's new StringDtype.

NumPy's np.issubdtype() cannot handle pandas ExtensionDtype objects, particularly the new StringDtype introduced as default in pandas 3.0. This caused TypeError when checking if color columns were numeric: "Cannot interpret '<StringDtype(storage='python', na_value=nan)>' as a data type"

Using pandas' is_numeric_dtype() provides several benefits:
- Correctly handles all pandas dtypes (native NumPy and extension types)
- Works with numeric extension dtypes (Int64, Float64, Decimal, etc.)
- Compatible with both pandas 2.x and 3.x
- More semantically clear - checks if data is numeric rather than
  checking dtype inheritance hierarchy
@EwoutH EwoutH added the bug Release notes label label Dec 3, 2025
@EwoutH
Copy link
Copy Markdown
Member Author

EwoutH commented Dec 3, 2025

The CI is still failing on another, unrelated error:

AttributeError: module 'reacton.ipyvuetify' has no attribute 'TabsItems'

I will try to address that in another PR.

@EwoutH EwoutH marked this pull request as ready for review December 3, 2025 18:23
@github-actions

This comment was marked as off-topic.

@github-actions

This comment was marked as off-topic.

Copy link
Copy Markdown
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this and #2919

@EwoutH EwoutH merged commit fe5670f into main Dec 4, 2025
15 of 16 checks passed
@EwoutH EwoutH deleted the altair_dtype branch January 23, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants