Example #1
0
def test_left_join_indexer():
    a = np.array([1, 2, 3, 4, 5], dtype=np.int64)
    b = np.array([2, 2, 3, 4, 4], dtype=np.int64)

    result = lib.left_join_indexer_int64(b, a)
    expected = np.array([1, 1, 2, 3, 3], dtype='i4')
    assert(np.array_equal(result, expected))
Example #2
0
def test_left_join_indexer():
    a = np.array([1, 2, 3, 4, 5], dtype=np.int64)
    b = np.array([2, 2, 3, 4, 4], dtype=np.int64)

    result = lib.left_join_indexer_int64(b, a)
    expected = np.array([1, 1, 2, 3, 3], dtype='i4')
    assert (np.array_equal(result, expected))
Example #3
0
    def _join_monotonic(self, other, how="left", return_indexers=False):
        if how == "left":
            join_index = self
            lidx = None
            ridx = lib.left_join_indexer_int64(self, other)
        elif how == "right":
            join_index = other
            lidx = lib.left_join_indexer_int64(other, self)
            ridx = None
        elif how == "inner":
            join_index, lidx, ridx = lib.inner_join_indexer_int64(self, other)
            join_index = Int64Index(join_index)
        elif how == "outer":
            join_index, lidx, ridx = lib.outer_join_indexer_int64(self, other)
            join_index = Int64Index(join_index)
        else:  # pragma: no cover
            raise Exception("do not recognize join method %s" % how)

        if return_indexers:
            return join_index, lidx, ridx
        else:
            return join_index