50
50
is_dtype_equal ,
51
51
is_extension_array_dtype ,
52
52
is_list_like ,
53
- is_object_dtype ,
54
53
is_sparse ,
55
54
pandas_dtype ,
56
55
)
@@ -207,13 +206,6 @@ def is_bool(self) -> bool:
207
206
def external_values (self ):
208
207
return external_values (self .values )
209
208
210
- @final
211
- def internal_values (self ):
212
- """
213
- The array that Series._values returns (internal values).
214
- """
215
- return self .values
216
-
217
209
@property
218
210
def array_values (self ) -> ExtensionArray :
219
211
"""
@@ -1771,7 +1763,8 @@ def get_values(self, dtype: Optional[DtypeObj] = None) -> np.ndarray:
1771
1763
return object dtype as boxed values, such as Timestamps/Timedelta
1772
1764
"""
1773
1765
values = self .values
1774
- if is_object_dtype (dtype ):
1766
+ if dtype == _dtype_obj :
1767
+ # DTA/TDA constructor and astype can handle 2D
1775
1768
values = values .astype (object )
1776
1769
# TODO(EA2D): reshape not needed with 2D EAs
1777
1770
return np .asarray (values ).reshape (self .shape )
@@ -1821,7 +1814,7 @@ def diff(self, n: int, axis: int = 0) -> List[Block]:
1821
1814
1822
1815
Returns
1823
1816
-------
1824
- A list with a new TimeDeltaBlock .
1817
+ A list with a new Block .
1825
1818
1826
1819
Notes
1827
1820
-----
@@ -1869,19 +1862,16 @@ def delete(self, loc) -> None:
1869
1862
pass
1870
1863
1871
1864
1872
- class DatetimeLikeBlockMixin (NDArrayBackedExtensionBlock ):
1873
- """Mixin class for DatetimeBlock, DatetimeTZBlock, and TimedeltaBlock."""
1874
-
1875
- values : Union [DatetimeArray , TimedeltaArray ]
1865
+ class DatetimeLikeBlock (NDArrayBackedExtensionBlock ):
1866
+ """Mixin class for DatetimeLikeBlock, DatetimeTZBlock."""
1876
1867
1868
+ __slots__ = ()
1877
1869
is_numeric = False
1878
1870
1879
-
1880
- class DatetimeBlock (DatetimeLikeBlockMixin ):
1881
- __slots__ = ()
1871
+ values : Union [DatetimeArray , TimedeltaArray ]
1882
1872
1883
1873
1884
- class DatetimeTZBlock (ExtensionBlock , DatetimeLikeBlockMixin ):
1874
+ class DatetimeTZBlock (ExtensionBlock , DatetimeLikeBlock ):
1885
1875
""" implement a datetime64 block with a tz attribute """
1886
1876
1887
1877
values : DatetimeArray
@@ -1890,21 +1880,19 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeLikeBlockMixin):
1890
1880
is_extension = True
1891
1881
is_numeric = False
1892
1882
1893
- diff = DatetimeBlock .diff
1894
- where = DatetimeBlock .where
1895
- putmask = DatetimeLikeBlockMixin .putmask
1896
- fillna = DatetimeLikeBlockMixin .fillna
1883
+ diff = NDArrayBackedExtensionBlock .diff
1884
+ where = NDArrayBackedExtensionBlock .where
1885
+ putmask = NDArrayBackedExtensionBlock .putmask
1886
+ fillna = NDArrayBackedExtensionBlock .fillna
1887
+
1888
+ get_values = NDArrayBackedExtensionBlock .get_values
1897
1889
1898
1890
# error: Incompatible types in assignment (expression has type
1899
1891
# "Callable[[NDArrayBackedExtensionBlock], bool]", base class "ExtensionBlock"
1900
1892
# defined the type as "bool") [assignment]
1901
1893
is_view = NDArrayBackedExtensionBlock .is_view # type: ignore[assignment]
1902
1894
1903
1895
1904
- class TimeDeltaBlock (DatetimeLikeBlockMixin ):
1905
- __slots__ = ()
1906
-
1907
-
1908
1896
class ObjectBlock (Block ):
1909
1897
__slots__ = ()
1910
1898
is_object = True
@@ -2022,10 +2010,8 @@ def get_block_type(values, dtype: Optional[Dtype] = None):
2022
2010
# Note: need to be sure PandasArray is unwrapped before we get here
2023
2011
cls = ExtensionBlock
2024
2012
2025
- elif kind == "M" :
2026
- cls = DatetimeBlock
2027
- elif kind == "m" :
2028
- cls = TimeDeltaBlock
2013
+ elif kind in ["M" , "m" ]:
2014
+ cls = DatetimeLikeBlock
2029
2015
elif kind in ["f" , "c" , "i" , "u" , "b" ]:
2030
2016
cls = NumericBlock
2031
2017
else :
0 commit comments