From d9c6dcf3810a06b6de115f8a4c74ed7c7f3f0164 Mon Sep 17 00:00:00 2001 From: saket3395 Date: Fri, 31 Jul 2026 13:16:50 +0530 Subject: [PATCH] fix: PandasArrayExtensionDtype._metadata must be a tuple, not a string Fixes #8375. pandas.api.extensions.ExtensionDtype expects _metadata to be a tuple of attribute names. As a plain string, pandas iterates over each character ('v', 'a', 'l', ...) when comparing dtypes (e.g. during dtype equality checks triggered by boolean-mask filtering), and crashes with AttributeError on the first character since there's no attribute named 'v'. Changed _metadata = "value_type" to _metadata = ("value_type",). Reproduced the underlying bug in isolation against a minimal ExtensionDtype subclass (outside the datasets package, using only pandas) to confirm the string form raises AttributeError on equality comparison and the tuple form does not. --- src/datasets/features/features.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datasets/features/features.py b/src/datasets/features/features.py index d58676ce730..4008fec0886 100644 --- a/src/datasets/features/features.py +++ b/src/datasets/features/features.py @@ -847,7 +847,7 @@ def to_pylist(self, maps_as_pydicts: Optional[Literal["lossy", "strict"]] = None class PandasArrayExtensionDtype(PandasExtensionDtype): - _metadata = "value_type" + _metadata = ("value_type",) def __init__(self, value_type: Union["PandasArrayExtensionDtype", np.dtype]): self._value_type = value_type