@@ -1345,6 +1345,31 @@ def delete(self, loc) -> None:
1345
1345
# _cache not yet initialized
1346
1346
pass
1347
1347
1348
+ @cache_readonly
1349
+ def array_values (self ) -> ExtensionArray :
1350
+ return self .values
1351
+
1352
+ def get_values (self , dtype : DtypeObj | None = None ) -> np .ndarray :
1353
+ """
1354
+ return object dtype as boxed values, such as Timestamps/Timedelta
1355
+ """
1356
+ values = self .values
1357
+ if dtype == _dtype_obj :
1358
+ values = values .astype (object )
1359
+ # TODO(EA2D): reshape not needed with 2D EAs
1360
+ return np .asarray (values ).reshape (self .shape )
1361
+
1362
+ def interpolate (
1363
+ self , method = "pad" , axis = 0 , inplace = False , limit = None , fill_value = None , ** kwargs
1364
+ ):
1365
+ values = self .values
1366
+ if values .ndim == 2 and axis == 0 :
1367
+ # NDArrayBackedExtensionArray.fillna assumes axis=1
1368
+ new_values = values .T .fillna (value = fill_value , method = method , limit = limit ).T
1369
+ else :
1370
+ new_values = values .fillna (value = fill_value , method = method , limit = limit )
1371
+ return self .make_block_same_class (new_values )
1372
+
1348
1373
1349
1374
class ExtensionBlock (EABackedBlock ):
1350
1375
"""
@@ -1469,15 +1494,6 @@ def setitem(self, indexer, value):
1469
1494
self .values [indexer ] = value
1470
1495
return self
1471
1496
1472
- def get_values (self , dtype : DtypeObj | None = None ) -> np .ndarray :
1473
- # ExtensionArrays must be iterable, so this works.
1474
- # TODO(EA2D): reshape not needed with 2D EAs
1475
- return np .asarray (self .values ).reshape (self .shape )
1476
-
1477
- @cache_readonly
1478
- def array_values (self ) -> ExtensionArray :
1479
- return self .values
1480
-
1481
1497
def take_nd (
1482
1498
self ,
1483
1499
indexer ,
@@ -1549,12 +1565,6 @@ def fillna(
1549
1565
values = self .values .fillna (value = value , limit = limit )
1550
1566
return [self .make_block_same_class (values = values )]
1551
1567
1552
- def interpolate (
1553
- self , method = "pad" , axis = 0 , inplace = False , limit = None , fill_value = None , ** kwargs
1554
- ):
1555
- new_values = self .values .fillna (value = fill_value , method = method , limit = limit )
1556
- return self .make_block_same_class (new_values )
1557
-
1558
1568
def diff (self , n : int , axis : int = 1 ) -> list [Block ]:
1559
1569
if axis == 0 and n != 0 :
1560
1570
# n==0 case will be a no-op so let is fall through
@@ -1662,27 +1672,12 @@ class NDArrayBackedExtensionBlock(EABackedBlock):
1662
1672
1663
1673
values : NDArrayBackedExtensionArray
1664
1674
1665
- @property
1666
- def array_values (self ) -> NDArrayBackedExtensionArray :
1667
- return self .values
1668
-
1669
1675
@property
1670
1676
def is_view (self ) -> bool :
1671
1677
""" return a boolean if I am possibly a view """
1672
1678
# check the ndarray values of the DatetimeIndex values
1673
1679
return self .values ._ndarray .base is not None
1674
1680
1675
- def get_values (self , dtype : DtypeObj | None = None ) -> np .ndarray :
1676
- """
1677
- return object dtype as boxed values, such as Timestamps/Timedelta
1678
- """
1679
- values = self .values
1680
- if dtype == _dtype_obj :
1681
- # DTA/TDA constructor and astype can handle 2D
1682
- values = values .astype (object )
1683
- # TODO(EA2D): reshape not needed with 2D EAs
1684
- return np .asarray (values ).reshape (self .shape )
1685
-
1686
1681
def iget (self , key ):
1687
1682
# GH#31649 we need to wrap scalars in Timestamp/Timedelta
1688
1683
# TODO(EA2D): this can be removed if we ever have 2D EA
@@ -1799,8 +1794,6 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeLikeBlock):
1799
1794
putmask = NDArrayBackedExtensionBlock .putmask
1800
1795
fillna = NDArrayBackedExtensionBlock .fillna
1801
1796
1802
- get_values = NDArrayBackedExtensionBlock .get_values
1803
-
1804
1797
# error: Incompatible types in assignment (expression has type
1805
1798
# "Callable[[NDArrayBackedExtensionBlock], bool]", base class "ExtensionBlock"
1806
1799
# defined the type as "bool") [assignment]
0 commit comments