Skip to content

Commit 354dfec

Browse files
committed
add join to test to common and fix breaks for timedeltas and non-unique categorical indices.
1 parent 7913965 commit 354dfec

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

pandas/core/indexes/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3129,7 +3129,7 @@ def _join_non_unique(self, other, how='left', return_indexers=False):
31293129
left_idx = _ensure_platform_int(left_idx)
31303130
right_idx = _ensure_platform_int(right_idx)
31313131

3132-
join_index = self.values.take(left_idx)
3132+
join_index = np.asarray(self.values.take(left_idx))
31333133
mask = left_idx == -1
31343134
np.putmask(join_index, mask, other._values.take(right_idx))
31353135

@@ -3317,7 +3317,7 @@ def _join_monotonic(self, other, how='left', return_indexers=False):
33173317

33183318
def _wrap_joined_index(self, joined, other):
33193319
name = self.name if self.name == other.name else None
3320-
return Index(joined, name=name)
3320+
return self.__class__(joined, name=name)
33213321

33223322
def _get_string_slice(self, key, use_lhs=True, use_rhs=True):
33233323
# this is for partial string indexing,

pandas/core/indexes/timedeltas.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ def union(self, other):
516516
result.freq = to_offset(result.inferred_freq)
517517
return result
518518

519-
def join(self, other, how='left', level=None, return_indexers=False):
519+
def join(self, other, how='left', level=None, return_indexers=False,
520+
sort=False):
520521
"""
521522
See Index.join
522523
"""
@@ -527,7 +528,8 @@ def join(self, other, how='left', level=None, return_indexers=False):
527528
pass
528529

529530
return Index.join(self, other, how=how, level=level,
530-
return_indexers=return_indexers)
531+
return_indexers=return_indexers,
532+
sort=sort)
531533

532534
def _wrap_joined_index(self, joined, other):
533535
name = self.name if self.name == other.name else None

pandas/tests/indexes/common.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ def test_fillna(self):
909909

910910
def test_nulls(self):
911911
# this is really a smoke test for the methods
912-
# as these are adequantely tested for function elsewhere
912+
# as these are adequately tested for function elsewhere
913913

914914
for name, index in self.indices.items():
915915
if len(index) == 0:
@@ -942,4 +942,9 @@ def test_empty(self):
942942
def test_join_self(self, how):
943943
index = self.create_index()
944944
joined = index.join(index, how=how)
945-
assert index is joined
945+
946+
if index is np.unique(index):
947+
assert index is joined
948+
949+
else:
950+
assert isinstance(joined, type(index))

0 commit comments

Comments
 (0)