From d5224151b17722929631958a354c4223d5a8a4ac Mon Sep 17 00:00:00 2001 From: jreback Date: Mon, 30 Jun 2014 10:35:35 -0400 Subject: [PATCH] COMPAT: make numpy NaT comparison use a view to avoid implicit conversions --- pandas/tslib.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/tslib.pyx b/pandas/tslib.pyx index 70675875c8143..d32978c881244 100644 --- a/pandas/tslib.pyx +++ b/pandas/tslib.pyx @@ -892,7 +892,7 @@ cdef convert_to_tsobject(object ts, object tz, object unit): if ts is None or ts is NaT or ts is np_NaT: obj.value = NPY_NAT elif is_datetime64_object(ts): - if ts == np_NaT: + if ts.view('i8') == iNaT: obj.value = NPY_NAT else: obj.value = _get_datetime64_nanos(ts) @@ -1222,7 +1222,7 @@ def array_to_datetime(ndarray[object] values, raise_=False, dayfirst=False, continue raise elif util.is_datetime64_object(val): - if val == np_NaT or val.view('i8') == iNaT: + if val is np_NaT or val.view('i8') == iNaT: iresult[i] = iNaT else: try: @@ -1303,7 +1303,7 @@ def array_to_datetime(ndarray[object] values, raise_=False, dayfirst=False, if _checknull_with_nat(val): oresult[i] = np.nan elif util.is_datetime64_object(val): - if val == np_NaT: + if val is np_NaT or val.view('i8') == iNaT: oresult[i] = np.nan else: oresult[i] = val.item()