diff --git a/pandas/core/internals.py b/pandas/core/internals.py index f10e1612f7fe9..fd9aed58798fe 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -23,7 +23,7 @@ from pandas.tslib import Timestamp from pandas import compat from pandas.compat import range, lrange, lmap, callable, map, zip - +from pandas.tseries.timedeltas import _coerce_scalar_to_timedelta_type class Block(PandasObject): @@ -1083,6 +1083,20 @@ def _try_fill(self, value): return value + def _try_coerce_args(self, values, other): + """ provide coercion to our input arguments + we are going to compare vs i8, so coerce to integer + values is always ndarra like, other may not be """ + values = values.view('i8') + if isnull(other) or (np.isscalar(other) and other == tslib.iNaT): + other = tslib.iNaT + elif isinstance(other, np.timedelta64): + other = _coerce_scalar_to_timedelta_type(other,unit='s').item() + else: + other = other.view('i8') + + return values, other + def _try_operate(self, values): """ return a version to operate on """ return values.view('i8')