5050 is_dtype_equal ,
5151 is_extension_array_dtype ,
5252 is_list_like ,
53- is_object_dtype ,
5453 is_sparse ,
5554 pandas_dtype ,
5655)
@@ -207,13 +206,6 @@ def is_bool(self) -> bool:
207206 def external_values (self ):
208207 return external_values (self .values )
209208
210- @final
211- def internal_values (self ):
212- """
213- The array that Series._values returns (internal values).
214- """
215- return self .values
216-
217209 @property
218210 def array_values (self ) -> ExtensionArray :
219211 """
@@ -1771,7 +1763,8 @@ def get_values(self, dtype: Optional[DtypeObj] = None) -> np.ndarray:
17711763 return object dtype as boxed values, such as Timestamps/Timedelta
17721764 """
17731765 values = self .values
1774- if is_object_dtype (dtype ):
1766+ if dtype == _dtype_obj :
1767+ # DTA/TDA constructor and astype can handle 2D
17751768 values = values .astype (object )
17761769 # TODO(EA2D): reshape not needed with 2D EAs
17771770 return np .asarray (values ).reshape (self .shape )
@@ -1821,7 +1814,7 @@ def diff(self, n: int, axis: int = 0) -> List[Block]:
18211814
18221815 Returns
18231816 -------
1824- A list with a new TimeDeltaBlock .
1817+ A list with a new Block .
18251818
18261819 Notes
18271820 -----
@@ -1869,19 +1862,16 @@ def delete(self, loc) -> None:
18691862 pass
18701863
18711864
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."""
18761867
1868+ __slots__ = ()
18771869 is_numeric = False
18781870
1879-
1880- class DatetimeBlock (DatetimeLikeBlockMixin ):
1881- __slots__ = ()
1871+ values : Union [DatetimeArray , TimedeltaArray ]
18821872
18831873
1884- class DatetimeTZBlock (ExtensionBlock , DatetimeLikeBlockMixin ):
1874+ class DatetimeTZBlock (ExtensionBlock , DatetimeLikeBlock ):
18851875 """ implement a datetime64 block with a tz attribute """
18861876
18871877 values : DatetimeArray
@@ -1890,21 +1880,19 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeLikeBlockMixin):
18901880 is_extension = True
18911881 is_numeric = False
18921882
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
18971889
18981890 # error: Incompatible types in assignment (expression has type
18991891 # "Callable[[NDArrayBackedExtensionBlock], bool]", base class "ExtensionBlock"
19001892 # defined the type as "bool") [assignment]
19011893 is_view = NDArrayBackedExtensionBlock .is_view # type: ignore[assignment]
19021894
19031895
1904- class TimeDeltaBlock (DatetimeLikeBlockMixin ):
1905- __slots__ = ()
1906-
1907-
19081896class ObjectBlock (Block ):
19091897 __slots__ = ()
19101898 is_object = True
@@ -2022,10 +2010,8 @@ def get_block_type(values, dtype: Optional[Dtype] = None):
20222010 # Note: need to be sure PandasArray is unwrapped before we get here
20232011 cls = ExtensionBlock
20242012
2025- elif kind == "M" :
2026- cls = DatetimeBlock
2027- elif kind == "m" :
2028- cls = TimeDeltaBlock
2013+ elif kind in ["M" , "m" ]:
2014+ cls = DatetimeLikeBlock
20292015 elif kind in ["f" , "c" , "i" , "u" , "b" ]:
20302016 cls = NumericBlock
20312017 else :
0 commit comments