@@ -371,7 +371,6 @@ def fillna(self, value, limit=None, inplace=False, downcast=None,
371
371
else :
372
372
return self .copy ()
373
373
374
- original_value = value
375
374
mask = isnull (self .values )
376
375
if limit is not None :
377
376
if not is_integer (limit ):
@@ -398,13 +397,15 @@ def fillna(self, value, limit=None, inplace=False, downcast=None,
398
397
399
398
# operate column-by-column
400
399
def f (m , v , i ):
400
+ block = self .coerce_to_target_dtype (value )
401
401
402
- # try again with a compatible block
403
- block = self .coerce_to_target_dtype (original_value )
404
- return block .fillna (original_value ,
402
+ # slice out our block
403
+ if i is not None :
404
+ block = block .getitem_block (slice (i , i + 1 ))
405
+ return block .fillna (value ,
405
406
limit = limit ,
406
407
inplace = inplace ,
407
- downcast = False )
408
+ downcast = None )
408
409
409
410
return self .split_and_operate (mask , f , inplace )
410
411
@@ -962,13 +963,11 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0,
962
963
# operate column-by-column
963
964
def f (m , v , i ):
964
965
965
- # TODO(jreback)
966
- # see if we can use coerce_to_target_dtype here instead
967
-
968
966
if i is None :
969
967
# ndim==1 case.
970
968
n = new
971
969
else :
970
+
972
971
if isinstance (new , np .ndarray ):
973
972
n = np .squeeze (new [i % new .shape [0 ]])
974
973
else :
@@ -1886,7 +1885,7 @@ def fillna(self, value, **kwargs):
1886
1885
1887
1886
# allow filling with integers to be
1888
1887
# interpreted as seconds
1889
- if not isinstance (value , np .timedelta64 ):
1888
+ if is_integer ( value ) and not isinstance (value , np .timedelta64 ):
1890
1889
value = Timedelta (value , unit = 's' )
1891
1890
return super (TimeDeltaBlock , self ).fillna (value , ** kwargs )
1892
1891
@@ -1917,11 +1916,11 @@ def _try_coerce_args(self, values, other):
1917
1916
elif isinstance (other , Timedelta ):
1918
1917
other_mask = isnull (other )
1919
1918
other = other .value
1919
+ elif isinstance (other , timedelta ):
1920
+ other = Timedelta (other ).value
1920
1921
elif isinstance (other , np .timedelta64 ):
1921
1922
other_mask = isnull (other )
1922
1923
other = Timedelta (other ).value
1923
- elif isinstance (other , timedelta ):
1924
- other = Timedelta (other ).value
1925
1924
elif hasattr (other , 'dtype' ) and is_timedelta64_dtype (other ):
1926
1925
other_mask = isnull (other )
1927
1926
other = other .astype ('i8' , copy = False ).view ('i8' )
0 commit comments