Skip to content

Commit

Permalink
BUG: fix join op between Index/Int64Index, GH #367
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Nov 16, 2011
1 parent 11fe72f commit 81ef580
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,21 @@ pandas 0.5.1
- Bug fix in reflexive binary addition in Series and DataFrame for
non-commutative operations (like string concatenation) (GH #353)
- setupegg.py will invoke Cython (GH #192)
- Fix block consolidation bug after inserting column into MultiIndex (GH #366)
- Fix bug in join operations between Index and Int64Index (GH #367)

Thanks
------

- Marius Cobzarenco
- Joel Cross
- Jeff Hammerbacher
- Adam Klein
- Jev Kuznetsov
- Kieran O'Mahony
- Wouter Overmeire
- Nathan Pinger
- Christian Prinoth
- Chang She
- Aman Thakral
- Dieter Vandenbussche
Expand Down
3 changes: 3 additions & 0 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ def join(self, other, how='left', return_indexers=False):

def _join_monotonic(self, other, how='left', return_indexers=False):
this_vals = self.values

if self.dtype != other.dtype:
other = Index(other, dtype=object)
other_vals = other.values

if how == 'left':
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,20 +519,30 @@ def test_join_non_int_index(self):
other = Index([3, 6, 7, 8, 10], dtype=object)

outer = self.index.join(other, how='outer')
outer2 = other.join(self.index, how='outer')
expected = Index([0, 2, 3, 4, 6, 7, 8, 10, 12, 14,
16, 18], dtype=object)
self.assert_(outer.equals(outer2))
self.assert_(outer.equals(expected))

inner = self.index.join(other, how='inner')
inner2 = other.join(self.index, how='inner')
expected = Index([6, 8, 10], dtype=object)
self.assert_(inner.equals(inner2))
self.assert_(inner.equals(expected))

left = self.index.join(other, how='left')
self.assert_(left.equals(self.index))

left2 = other.join(self.index, how='left')
self.assert_(left2.equals(other))

right = self.index.join(other, how='right')
self.assert_(right.equals(other))

right2 = other.join(self.index, how='right')
self.assert_(right2.equals(self.index))

def test_intersection(self):
other = Index([1, 2, 3, 4, 5])
result = self.index.intersection(other)
Expand Down

0 comments on commit 81ef580

Please sign in to comment.