wesm/pandas — Issue #335: Issue with _set_item not consolidating
Author: creeson
Created: 2011-11-04 21:15:22+00:00
State: open

The following code breaks (though it worked in previous versions of pandas):

import pandas as ps

x = ps.DataFrame(index=[1,2,3], columns=None, data=None)
s = ps.Series(index=[1,2,3], data=[10,20,30])
x['a']=s
x['b']=s*2
y = ps.DataFrame(index=[1,2,3], columns=None, data=None)
y['c']=s
y['d']=s*2
z = x.join(y, how='outer')

Error:
z = x.join(y, how='outer')
File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 2191, in join
return self._join_index(other, how, lsuffix, rsuffix)
File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 2226, in _join_index
merged_data = join_managers(thisdata, otherdata, axis=1, how=how)
File "C:\Python27\lib\site-packages\pandas\core\internals.py", line 983, in join_managers
op = _JoinOperation(left, right, axis=axis, how=how)
File "C:\Python27\lib\site-packages\pandas\core\internals.py", line 997, in __init__
assert(left.is_consolidated())
AssertionError

If I add self._consolidate_inplace() to _set_item it no longer breaks, but I am not sure if this is where you would want to add it.

Thanks!