Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Bug Fixes
- Bug in ``.xs`` with a ``nan`` in level when dropped (:issue:`6574`)
- Bug in fillna with method = 'bfill/ffill' and ``datetime64[ns]`` dtype (:issue:`6587`)
- Bug in sql writing with mixed dtypes possibly leading to data loss (:issue:`6509`)

- Bug in popping from a Series (:issue:`6600`)

pandas 0.13.1
-------------
Expand Down
20 changes: 15 additions & 5 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3733,11 +3733,21 @@ def reindex_axis0_with_method(self, new_axis, indexer=None, method=None,
def _delete_from_block(self, i, item):
super(SingleBlockManager, self)._delete_from_block(i, item)

# reset our state
self._block = (
self.blocks[0] if len(self.blocks) else
make_block(np.array([], dtype=self._block.dtype), [], [])
)
# possibly need to merge split blocks
if len(self.blocks) > 1:
new_items = Index(list(itertools.chain(*[ b.items for b in self.blocks ])))
block = make_block(np.concatenate([ b.values for b in self.blocks ]),
new_items,
new_items,
dtype=self._block.dtype)

elif len(self.blocks):
block = self.blocks[0]
else:
block = make_block(np.array([], dtype=self._block.dtype), [], [])

self.blocks = [block]
self._block = block
self._values = self._block.values

def get_slice(self, slobj):
Expand Down
15 changes: 15 additions & 0 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,21 @@ def test_setindex(self):
def test_array_finalize(self):
pass

def test_pop(self):
# GH 6600
df = DataFrame({
'A': 0,
'B': np.arange(5,dtype='int64'),
'C': 0,
})
k = df.iloc[4]

result = k.pop('B')
self.assertEqual(result, 4)

expected = Series([0,0],index=['A','C'])
assert_series_equal(k, expected)

def test_not_hashable(self):
s_empty = Series()
s = Series([1])
Expand Down