Skip to content

COMPAT: make numpy NaT comparison use a view to avoid implicit conversions #7617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pandas/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down