Yes, that seems like a mistake. This applies to this part of lib.ismember :
for i in range(n): val = util.get_value_at(arr, i) if val in values: result[i] = 1 else: result[i] = 0
val is a numpy.datetime64 object, and values is a set of Timestamp objects. Membership testing should work, but not:
>>> import pandas as pd, numpy as np >>> ts = pd.Timestamp('2013-01-04') >>> ts Timestamp('2013-01-04 00:00:00', tz=None) >>> dt64 = np.datetime64(ts) >>> dt64 numpy.datetime64('2013-01-03T19:00:00.000000-0500') >>> dt64 == ts True >>> dt64 in [ts] True >>> dt64 in {ts} False
I think that usually this behavior - work in a list that does not work in a set - is connected with something wrong with __hash__ :
>>> hash(dt64) 1357257600000000 >>> hash(ts) -7276108168457487299
You cannot run membership test if the hashes do not match. I can come up with several ways to fix this, but choosing the best one will depend on the design they made while implementing Timestamps, which I cannot comment on.
source share