pydata/pandas — pull request #8853 by behzadnouri (2014-11-19 03:07:16+00:00)
Title: BUG: type change breaks BlockManager integrity

closes https://github.com/pydata/pandas/issues/8850

on master:

>>> cols = MultiIndex.from_tuples([('1st', 'a'), ('2nd', 'b'), ('3rd', 'c')])
>>> df = DataFrame([[1.0, 2, 3], [4.0, 5, 6]], columns=cols)
>>> df['2nd'] = df['2nd'] * 2.0 # type change in block manager
/usr/lib/python3.4/site-packages/numpy/lib/function_base.py:3612: FutureWarning: in the future negative indices will not be ignored by `numpy.delete`.
"`numpy.delete`.", FutureWarning)
>>> df.values
...
File "/usr/lib/python3.4/site-packages/pandas-0.15.1_72_gf504885-py3.4-linux-x86_64.egg/pandas/core/internals.py", line 2392, in _verify_integrity
tot_items))
AssertionError: Number of manager items must equal union of block items
# manager items: 3, # tot_items: 4
>>> df.blocks
...
File "/usr/lib/python3.4/site-packages/pandas-0.15.1_72_gf504885-py3.4-linux-x86_64.egg/pandas/core/internals.py", line 2392, in _verify_integrity
tot_items))
AssertionError: Number of manager items must equal union of block items
# manager items: 3, # tot_items: 4
`._data` is also broken:

>>> df._data
BlockManager
Items:
1st a
2nd b
3rd c
Axis 1: Int64Index([0, 1], dtype='int64')
FloatBlock: slice(0, 1, 1), 1 x 2, dtype: float64
IntBlock: slice(1, 3, 1), 2 x 2, dtype: int64
FloatBlock: slice(1, 2, 1), 1 x 2, dtype: float64