Skip to content

Commit 0bbae3b

Browse files
committed
Merge pull request #5040 from jreback/sparc_fix
TST: added null conversions for TimeDeltaBlock in core/internals related (GH4396)
2 parents a58bc6a + f2776f1 commit 0bbae3b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pandas/core/internals.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from pandas.tslib import Timestamp
2424
from pandas import compat
2525
from pandas.compat import range, lrange, lmap, callable, map, zip
26-
26+
from pandas.tseries.timedeltas import _coerce_scalar_to_timedelta_type
2727

2828
class Block(PandasObject):
2929

@@ -1083,6 +1083,20 @@ def _try_fill(self, value):
10831083

10841084
return value
10851085

1086+
def _try_coerce_args(self, values, other):
1087+
""" provide coercion to our input arguments
1088+
we are going to compare vs i8, so coerce to integer
1089+
values is always ndarra like, other may not be """
1090+
values = values.view('i8')
1091+
if isnull(other) or (np.isscalar(other) and other == tslib.iNaT):
1092+
other = tslib.iNaT
1093+
elif isinstance(other, np.timedelta64):
1094+
other = _coerce_scalar_to_timedelta_type(other,unit='s').item()
1095+
else:
1096+
other = other.view('i8')
1097+
1098+
return values, other
1099+
10861100
def _try_operate(self, values):
10871101
""" return a version to operate on """
10881102
return values.view('i8')

0 commit comments

Comments
 (0)