Skip to content

COMPAT: comparisons vs numpy nat not working on windows #7597

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 28, 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
18 changes: 12 additions & 6 deletions pandas/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ cdef int64_t NPY_NAT = util.get_nat()
compat_NaT = np.array([NPY_NAT]).astype('m8[ns]').item()

# numpy actual nat object
np_NaT = np.datetime64('NaT',dtype='M8')
np_NaT = np.datetime64('NaT')

try:
basestring
Expand Down Expand Up @@ -892,8 +892,11 @@ 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):
obj.value = _get_datetime64_nanos(ts)
pandas_datetime_to_datetimestruct(obj.value, PANDAS_FR_ns, &obj.dts)
if ts == np_NaT:
obj.value = NPY_NAT
else:
obj.value = _get_datetime64_nanos(ts)
pandas_datetime_to_datetimestruct(obj.value, PANDAS_FR_ns, &obj.dts)
elif is_integer_object(ts):
if ts == NPY_NAT:
obj.value = NPY_NAT
Expand Down Expand Up @@ -1218,7 +1221,7 @@ def array_to_datetime(ndarray[object] values, raise_=False, dayfirst=False,
continue
raise
elif util.is_datetime64_object(val):
if val is np_NaT or val.view('i8') == iNaT:
if val == np_NaT or val.view('i8') == iNaT:
iresult[i] = iNaT
else:
try:
Expand Down Expand Up @@ -1296,10 +1299,13 @@ def array_to_datetime(ndarray[object] values, raise_=False, dayfirst=False,
val = values[i]

# set as nan if is even a datetime NaT
if _checknull_with_nat(val) or val is np_NaT:
if _checknull_with_nat(val):
oresult[i] = np.nan
elif util.is_datetime64_object(val):
oresult[i] = val.item()
if val == np_NaT:
oresult[i] = np.nan
else:
oresult[i] = val.item()
else:
oresult[i] = val
return oresult
Expand Down