Skip to content

pandas.DatetimeIndex.isin always returns an array of False #1763

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

Closed
lesteve opened this issue Aug 13, 2012 · 0 comments
Closed

pandas.DatetimeIndex.isin always returns an array of False #1763

lesteve opened this issue Aug 13, 2012 · 0 comments
Labels
Milestone

Comments

@lesteve
Copy link
Contributor

lesteve commented Aug 13, 2012

pandas version: 0.8.2.dev-742d7fb

import pandas
import pandas.util.testing as put
index = put.makeDateIndex(4)
index.isin(index) # returns array([False, False, False, False], dtype=bool)

It works fine with pandas 0.7.3, i.e. it returns an array of True instead. This works fine as well with a pandas.Int64Index. index.isin(index) just calls pandas.lib.ismember(index._array_values(), set(index)) but I am afraid I lack the skills to understand what goes wrong in the cython code.

Just for some background, the original problem I bumped into:

import numpy as np
import pandas
ts = pandas.TimeSeries(data=[1,2,3], index=[ np.datetime64(x) for x in ['2000', '2000', '2002'] ])
ts.ix[ts.index] # returns an empty timeseries whereas ts[ts.index] works fine

I tracked it down to ts.ix._get_item_iterable which has a special case for when the index has duplicates which use pandas.TimeSeries.isin.

As an aside it looks like pandas.core.common._asarray_tuplesafe(index) is wrong when using numpy 1.6 so that ts.ix[ts.index] still would return an empty array if this bug was fixed, but I guess that's a numpy 1.6 datetime64 bug which I have seen mentioned in a few other places.

@wesm wesm closed this as completed in 3bd9d15 Aug 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants