4
4
from typing import (
5
5
List ,
6
6
TypeVar ,
7
+ Union ,
7
8
)
8
9
9
10
import numpy as np
25
26
ABCSeries ,
26
27
)
27
28
28
- from pandas .core .arrays import ExtensionArray
29
+ from pandas .core .arrays import IntervalArray
29
30
from pandas .core .arrays ._mixins import NDArrayBackedExtensionArray
30
31
from pandas .core .indexers import deprecate_ndim_indexing
31
32
from pandas .core .indexes .base import Index
@@ -216,7 +217,7 @@ class ExtensionIndex(Index):
216
217
# The base class already passes through to _data:
217
218
# size, __len__, dtype
218
219
219
- _data : ExtensionArray
220
+ _data : Union [ IntervalArray , NDArrayBackedExtensionArray ]
220
221
221
222
__eq__ = _make_wrapped_comparison_op ("__eq__" )
222
223
__ne__ = _make_wrapped_comparison_op ("__ne__" )
@@ -240,8 +241,7 @@ def __getitem__(self, key):
240
241
return type (self )(result , name = self .name )
241
242
# Unpack to ndarray for MPL compat
242
243
243
- # error: "ExtensionArray" has no attribute "_data"
244
- result = result ._data # type: ignore[attr-defined]
244
+ result = result ._ndarray
245
245
246
246
# Includes cases where we get a 2D ndarray back for MPL compat
247
247
deprecate_ndim_indexing (result )
@@ -276,6 +276,12 @@ def insert(self, loc: int, item):
276
276
# ExtensionIndex subclasses must override Index.insert
277
277
raise AbstractMethodError (self )
278
278
279
+ def _validate_fill_value (self , value ):
280
+ """
281
+ Convert value to be insertable to underlying array.
282
+ """
283
+ return self ._data ._validate_setitem_value (value )
284
+
279
285
def _get_unique_index (self ):
280
286
if self .is_unique :
281
287
return self
0 commit comments