@@ -2090,13 +2090,7 @@ def _can_hold_element(self, element: Any) -> bool:
2090
2090
class DatetimeLikeBlockMixin (Block ):
2091
2091
"""Mixin class for DatetimeBlock, DatetimeTZBlock, and TimedeltaBlock."""
2092
2092
2093
- @property
2094
- def _holder (self ):
2095
- return DatetimeArray
2096
-
2097
- @property
2098
- def fill_value (self ):
2099
- return np .datetime64 ("NaT" , "ns" )
2093
+ _can_hold_na = True
2100
2094
2101
2095
def get_values (self , dtype = None ):
2102
2096
"""
@@ -2162,10 +2156,8 @@ def to_native_types(self, na_rep="NaT", **kwargs):
2162
2156
class DatetimeBlock (DatetimeLikeBlockMixin ):
2163
2157
__slots__ = ()
2164
2158
is_datetime = True
2165
-
2166
- @property
2167
- def _can_hold_na (self ):
2168
- return True
2159
+ _holder = DatetimeArray
2160
+ fill_value = np .datetime64 ("NaT" , "ns" )
2169
2161
2170
2162
def _maybe_coerce_values (self , values ):
2171
2163
"""
@@ -2256,15 +2248,16 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeBlock):
2256
2248
is_extension = True
2257
2249
2258
2250
internal_values = Block .internal_values
2251
+
2252
+ _holder = DatetimeBlock ._holder
2259
2253
_can_hold_element = DatetimeBlock ._can_hold_element
2260
2254
to_native_types = DatetimeBlock .to_native_types
2261
2255
diff = DatetimeBlock .diff
2262
- fill_value = np .datetime64 ("NaT" , "ns" )
2263
- array_values = ExtensionBlock .array_values
2256
+ fillna = DatetimeBlock .fillna # i.e. Block.fillna
2257
+ fill_value = DatetimeBlock .fill_value
2258
+ _can_hold_na = DatetimeBlock ._can_hold_na
2264
2259
2265
- @property
2266
- def _holder (self ):
2267
- return DatetimeArray
2260
+ array_values = ExtensionBlock .array_values
2268
2261
2269
2262
def _maybe_coerce_values (self , values ):
2270
2263
"""
@@ -2330,17 +2323,6 @@ def external_values(self):
2330
2323
# return an object-dtype ndarray of Timestamps.
2331
2324
return np .asarray (self .values .astype ("datetime64[ns]" , copy = False ))
2332
2325
2333
- def fillna (self , value , limit = None , inplace = False , downcast = None ):
2334
- # We support filling a DatetimeTZ with a `value` whose timezone
2335
- # is different by coercing to object.
2336
- if self ._can_hold_element (value ):
2337
- return super ().fillna (value , limit , inplace , downcast )
2338
-
2339
- # different timezones, or a non-tz
2340
- return self .astype (object ).fillna (
2341
- value , limit = limit , inplace = inplace , downcast = downcast
2342
- )
2343
-
2344
2326
def quantile (self , qs , interpolation = "linear" , axis = 0 ):
2345
2327
naive = self .values .view ("M8[ns]" )
2346
2328
@@ -2355,11 +2337,9 @@ def quantile(self, qs, interpolation="linear", axis=0):
2355
2337
return self .make_block_same_class (aware , ndim = res_blk .ndim )
2356
2338
2357
2339
2358
- class TimeDeltaBlock (DatetimeLikeBlockMixin , IntBlock ):
2340
+ class TimeDeltaBlock (DatetimeLikeBlockMixin ):
2359
2341
__slots__ = ()
2360
2342
is_timedelta = True
2361
- _can_hold_na = True
2362
- is_numeric = False
2363
2343
fill_value = np .timedelta64 ("NaT" , "ns" )
2364
2344
2365
2345
def _maybe_coerce_values (self , values ):
0 commit comments