From f2776f19fe3ae879b7e8eb48bf4a1aa8f12233fd Mon Sep 17 00:00:00 2001 From: jreback Date: Sun, 29 Sep 2013 11:49:02 -0400 Subject: [PATCH] TST: added null conversions for TimeDeltaBlock in core/internals related (GH4396) --- pandas/core/internals.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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')