Commit d1fa7e5
authored
Use pandas type checking for numeric dtype detection in Altair backend
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 hierarchy1 parent ba82fa5 commit d1fa7e5
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
| |||
0 commit comments