# Buggy code
def _join_monotonic(self, other, how="left", return_indexers=False):
    if self.equals(other):
        ret_index = other if how == "right" else self
        if return_indexers:
            return ret_index, None, None
        else:
            return ret_index

    sv = self.values
    ov = other._values

    if self.is_unique and other.is_unique:
        # We can perform much better than the general case
        if how == "left":
            join_index = self
            lidx = None
            ridx = self._left_indexer_unique(sv, ov)
        elif how == "right":
            join_index = other
            lidx = self._left_indexer_unique(ov, sv)
            ridx = None
        elif how == "inner":
            join_index, lidx, ridx = self._inner_indexer(sv, ov)
            join_index = self._wrap_joined_index(join_index, other)
        elif how == "outer":
            join_index, lidx, ridx = self._outer_indexer(sv, ov)
            join_index = self._wrap_joined_index(join_index, other)
    else:
        if how == "left":
            join_index, lidx, ridx = self._left_indexer(sv, ov)
        elif how == "right":
            join_index, ridx, lidx = self._left_indexer(other, self)
        elif how == "inner":
            join_index, lidx, ridx = self._inner_indexer(sv, ov)
        elif how == "outer":
            join_index, lidx, ridx = self._outer_indexer(sv, ov)
        join_index = self._wrap_joined_index(join_index, other)

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


# Traceback (TypeError)
import pandas as pd
import numpy as np

df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
'foo', 'bar', 'foo', 'foo'],
'B' : ['one', 'one', 'two', 'three',
'two', 'two', 'one', 'three'],
'C' : np.random.randn(8),
'D' : np.random.randn(8)})

s = pd.Series(np.repeat(np.arange(8),2), index=np.repeat(np.arange(8),2), name='TEST')

In []: s.head()

Out[]:
0    0
0    0
1    1
1    1
2    2
dtype: int32

# The following all work as expected
df.join(s, how='inner')
df.join(s, how='outer')
df.join(s, how='left')

# Right Joins Type Error
df.join(s, how='right')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-80-26e8bf54fd8f> in <module>()
----> 1 df.join(s, how='right')

D:\Python27\lib\site-packages\pandas\core\frame.pyc in join(self, other, on, how, lsuffix, rsuffix, sort)
4218         # For SparseDataFrame's benefit
4219         return self._join_compat(other, on=on, how=how, lsuffix=lsuffix,
-> 4220                                  rsuffix=rsuffix, sort=sort)
4221
4222     def _join_compat(self, other, on=None, how='left', lsuffix='', rsuffix='',

D:\Python27\lib\site-packages\pandas\core\frame.pyc in _join_compat(self, other, on, how, lsuffix, rsuffix, sort)
4232             return merge(self, other, left_on=on, how=how,
4233                          left_index=on is None, right_index=True,
-> 4234                          suffixes=(lsuffix, rsuffix), sort=sort)
4235         else:
4236             if on is not None:

D:\Python27\lib\site-packages\pandas\tools\merge.pyc in merge(left, right, how, on, left_on, right_on, left_index, right_index, sort, suffixes, copy, indicator)
33                          right_index=right_index, sort=sort, suffixes=suffixes,
34                          copy=copy, indicator=indicator)
---> 35     return op.get_result()
36 if __debug__:
37     merge.__doc__ = _merge_doc % '\nleft : DataFrame'

D:\Python27\lib\site-packages\pandas\tools\merge.pyc in get_result(self)
194             self.left, self.right = self._indicator_pre_merge(self.left, self.right)
195
--> 196         join_index, left_indexer, right_indexer = self._get_join_info()
197
198         ldata, rdata = self.left._data, self.right._data

D:\Python27\lib\site-packages\pandas\tools\merge.pyc in _get_join_info(self)
309         if self.left_index and self.right_index:
310             join_index, left_indexer, right_indexer = \
--> 311                 left_ax.join(right_ax, how=self.how, return_indexers=True)
312         elif self.right_index and self.how == 'left':
313             join_index, left_indexer, right_indexer = \

D:\Python27\lib\site-packages\pandas\core\index.pyc in join(self, other, how, level, return_indexers)
2212             if self.is_monotonic and other.is_monotonic:
2213                 return self._join_monotonic(other, how=how,
-> 2214                                             return_indexers=return_indexers)
2215             else:
2216                 return self._join_non_unique(other, how=how,

D:\Python27\lib\site-packages\pandas\core\index.pyc in _join_monotonic(self, other, how, return_indexers)
2463                 join_index, lidx, ridx = self._left_indexer(sv, ov)
2464             elif how == 'right':
-> 2465                 join_index, ridx, lidx = self._left_indexer(other, self)
2466             elif how == 'inner':
2467                 join_index, lidx, ridx = self._inner_indexer(sv, ov)

TypeError: Argument 'left' has incorrect type (expected numpy.ndarray, got Int64Index)

# Fixed code
def _join_monotonic(self, other, how="left", return_indexers=False):
    if self.equals(other):
        ret_index = other if how == "right" else self
        if return_indexers:
            return ret_index, None, None
        else:
            return ret_index

    sv = self.values
    ov = other._values

    if self.is_unique and other.is_unique:
        # We can perform much better than the general case
        if how == "left":
            join_index = self
            lidx = None
            ridx = self._left_indexer_unique(sv, ov)
        elif how == "right":
            join_index = other
            lidx = self._left_indexer_unique(ov, sv)
            ridx = None
        elif how == "inner":
            join_index, lidx, ridx = self._inner_indexer(sv, ov)
            join_index = self._wrap_joined_index(join_index, other)
        elif how == "outer":
            join_index, lidx, ridx = self._outer_indexer(sv, ov)
            join_index = self._wrap_joined_index(join_index, other)
    else:
        if how == "left":
            join_index, lidx, ridx = self._left_indexer(sv, ov)
        elif how == "right":
            join_index, ridx, lidx = self._left_indexer(ov, sv)
        elif how == "inner":
            join_index, lidx, ridx = self._inner_indexer(sv, ov)
        elif how == "outer":
            join_index, lidx, ridx = self._outer_indexer(sv, ov)
        join_index = self._wrap_joined_index(join_index, other)

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