@@ -2184,7 +2184,7 @@ def _holder(self):
2184
2184
2185
2185
@property
2186
2186
def fill_value (self ):
2187
- return tslibs . iNaT
2187
+ return np . datetime64 ( "NaT" , "ns" )
2188
2188
2189
2189
def get_values (self , dtype = None ):
2190
2190
"""
@@ -2266,14 +2266,9 @@ def _can_hold_element(self, element):
2266
2266
if self .is_datetimetz :
2267
2267
return tz_compare (element .tzinfo , self .dtype .tz )
2268
2268
return element .tzinfo is None
2269
- elif is_integer (element ):
2270
- return element == tslibs .iNaT
2271
2269
2272
2270
return is_valid_nat_for_dtype (element , self .dtype )
2273
2271
2274
- def _coerce_values (self , values ):
2275
- return values .view ("i8" )
2276
-
2277
2272
def _try_coerce_args (self , other ):
2278
2273
"""
2279
2274
Coerce other to dtype 'i8'. NaN and NaT convert to
@@ -2290,16 +2285,15 @@ def _try_coerce_args(self, other):
2290
2285
base-type other
2291
2286
"""
2292
2287
if is_valid_nat_for_dtype (other , self .dtype ):
2293
- other = tslibs .iNaT
2294
- elif is_integer (other ) and other == tslibs .iNaT :
2295
- pass
2288
+ other = np .datetime64 ("NaT" , "ns" )
2296
2289
elif isinstance (other , (datetime , np .datetime64 , date )):
2297
2290
other = self ._box_func (other )
2298
2291
if getattr (other , "tz" ) is not None :
2299
2292
raise TypeError ("cannot coerce a Timestamp with a tz on a naive Block" )
2300
- other = other .asm8 . view ( "i8" )
2293
+ other = other .asm8
2301
2294
elif hasattr (other , "dtype" ) and is_datetime64_dtype (other ):
2302
- other = other .astype ("i8" , copy = False ).view ("i8" )
2295
+ # TODO: can we get here with non-nano?
2296
+ pass
2303
2297
else :
2304
2298
# coercion issues
2305
2299
# let higher levels handle
@@ -2458,8 +2452,7 @@ def _slice(self, slicer):
2458
2452
return self .values [slicer ]
2459
2453
2460
2454
def _coerce_values (self , values ):
2461
- # asi8 is a view, needs copy
2462
- return _block_shape (values .view ("i8" ), ndim = self .ndim )
2455
+ return _block_shape (values , ndim = self .ndim )
2463
2456
2464
2457
def _try_coerce_args (self , other ):
2465
2458
"""
@@ -2484,21 +2477,17 @@ def _try_coerce_args(self, other):
2484
2477
other = self ._holder (other , dtype = self .dtype )
2485
2478
2486
2479
elif is_valid_nat_for_dtype (other , self .dtype ):
2487
- other = tslibs .iNaT
2488
- elif is_integer (other ) and other == tslibs .iNaT :
2489
- pass
2480
+ other = np .datetime64 ("NaT" , "ns" )
2490
2481
elif isinstance (other , self ._holder ):
2491
- if other .tz != self .values .tz :
2482
+ if not tz_compare ( other .tz , self .values .tz ) :
2492
2483
raise ValueError ("incompatible or non tz-aware value" )
2493
- other = _block_shape ( other . asi8 , ndim = self . ndim )
2484
+
2494
2485
elif isinstance (other , (np .datetime64 , datetime , date )):
2495
2486
other = tslibs .Timestamp (other )
2496
- tz = getattr (other , "tz" , None )
2497
2487
2498
2488
# test we can have an equal time zone
2499
- if tz is None or str ( tz ) != str ( self .values .tz ):
2489
+ if not tz_compare ( other . tz , self .values .tz ):
2500
2490
raise ValueError ("incompatible or non tz-aware value" )
2501
- other = other .value
2502
2491
else :
2503
2492
raise TypeError (other )
2504
2493
@@ -2654,8 +2643,8 @@ def fillna(self, value, **kwargs):
2654
2643
2655
2644
def _try_coerce_args (self , other ):
2656
2645
"""
2657
- Coerce values and other to int64 , with null values converted to
2658
- iNaT. values is always ndarray-like, other may not be
2646
+ Coerce values and other to datetime64[ns] , with null values
2647
+ converted to datetime64("NaT", "ns").
2659
2648
2660
2649
Parameters
2661
2650
----------
0 commit comments