wesm/pandas — Issue #367: Exception Joining DataFrames and Series
Author: CRP
Created: 2011-11-15 15:53:22+00:00
State: open

In [23]: a=DataFrame(randn(5,2),index=[1,2,3,6,7],columns=['a','b'])

In [24]: b=Series([6,7,8,9],index=[0,1,2,3],name='c')

In [25]: c=Series([6,7,8,9],name='c')

In [26]: a
Out[26]:
a b
1 -0.268 -0.1305
2 0.2243 0.4644
3 0.4767 -0.5677
6 0.1806 0.6276
7 0.9767 0.3687

In [27]: b
Out[27]:
0 6
1 7
2 8
3 9
Name: c

In [28]: c
Out[28]:
0 6
1 7
2 8
3 9
Name: c

In [29]: a.join(b,how='outer')
Out[29]:
a b c
0 NaN NaN 6
1 -0.268 -0.1305 7
2 0.2243 0.4644 8
3 0.4767 -0.5677 9
6 0.1806 0.6276 NaN
7 0.9767 0.3687 NaN

In [30]: a.join(c,how='outer')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/Users/c.prinoth/ in ()
----> 1 a.join(c,how='outer')

/Library/Python/2.6/site-packages/pandas/core/frame.pyc in join(self, other, on, how, lsuffix, rsuffix)
2303 return self._join_on(other, on, how, lsuffix, rsuffix)
2304 else:
-> 2305 return self._join_index(other, how, lsuffix, rsuffix)
2306
2307 def _join_on(self, other, on, how, lsuffix, rsuffix):

/Library/Python/2.6/site-packages/pandas/core/frame.pyc in _join_index(self, other, how, lsuffix, rsuffix)
2340
2341 # this will always ensure copied data

-> 2342 merged_data = join_managers(thisdata, otherdata, axis=1, how=how)
2343 return self._constructor(merged_data)
2344

/Library/Python/2.6/site-packages/pandas/core/internals.pyc in join_managers(left, right, axis, how, copy)
991
992 def join_managers(left, right, axis=1, how='left', copy=True):
--> 993 op = _JoinOperation(left, right, axis=axis, how=how)
994 return op.get_result(copy=copy)
995

/Library/Python/2.6/site-packages/pandas/core/internals.pyc in __init__(self, left, right, axis, how)
1015 (self.join_index,
1016 self.lindexer,
-> 1017 self.rindexer) = laxis.join(raxis, how=how, return_indexers=True)
1018
1019 # do NOT sort

/Library/Python/2.6/site-packages/pandas/core/index.pyc in join(self, other, how, return_indexers)
491 if self.is_monotonic and other.is_monotonic:
492 return self._join_monotonic(other, how=how,
--> 493 return_indexers=return_indexers)
494
495 if how == 'left':

/Library/Python/2.6/site-packages/pandas/core/index.pyc in _join_monotonic(self, other, how, return_indexers)
530 join_index = Index(join_index)
531 elif how == 'outer':
--> 532 join_index, lidx, ridx = lib.outer_join_indexer_object(self, other)
533 join_index = Index(join_index)
534 else: # pragma: no cover

/Library/Python/2.6/site-packages/pandas/_tseries.so in pandas._tseries.outer_join_indexer_object (pandas/src/tseries.c:43677)()

ValueError: Buffer dtype mismatch, expected 'Python object' but got 'long'