Skip to content
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

"x in ix" fails for dupe keys in DatetimeIndex #2380

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ install:
- 'if [ $TRAVIS_PYTHON_VERSION == "3.3" ]; then pip uninstall numpy; pip install https://github.com/numpy/numpy/archive/v1.7.0b2.tar.gz; fi'
- 'if [ $TRAVIS_PYTHON_VERSION == "3.2" ] || [ $TRAVIS_PYTHON_VERSION == "3.1" ]; then pip install https://github.com/y-p/numpy/archive/1.6.2_with_travis_fix.tar.gz; fi'
- 'if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then pip install numpy; fi' # should be nop if pre-installed
- pip install --use-mirrors cython nose pytz python-dateutil;
- pip install --use-mirrors cython nose pytz python-dateutil xlrd openpyxl;

script:
- python setup.py build_ext install
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,6 @@ def test_append_many(self):
assert_series_equal(result, self.ts)

def test_all_any(self):
np.random.seed(12345)
ts = tm.makeTimeSeries()
bool_series = ts > 0
self.assert_(not bool_series.all())
Expand Down
3 changes: 2 additions & 1 deletion pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ def _add_delta(self, delta):

def __contains__(self, key):
try:
return np.isscalar(self.get_loc(key))
res = self.get_loc(key)
return np.isscalar(res) or type(res) == slice
except (KeyError, TypeError):
return False

Expand Down
5 changes: 5 additions & 0 deletions pandas/tseries/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def test_index_unique(self):
uniques = self.dups.index.unique()
self.assert_(uniques.dtype == 'M8[ns]') # sanity

def test_index_dupes_contains(self):
d = datetime(2011, 12, 5, 20, 30)
ix=DatetimeIndex([d,d])
self.assertTrue(d in ix)

def test_duplicate_dates_indexing(self):
ts = self.dups

Expand Down