Skip to content

Commit

Permalink
fix test_reshape.TestDataFrameReshape.test_unstack_preserve_dtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
kernc committed Jun 6, 2017
1 parent 8a91129 commit 88656a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pandas/core/reshape/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def unstack(obj, level, fill_value=None):


def _unstack_frame(obj, level, fill_value=None):
from pandas.core.internals import BlockManager, make_block
from pandas.core.internals import BlockManager, make_block as _make_block

if obj._is_mixed_type:
unstacker = _Unstacker(np.empty((0, 0)), # dummy
Expand Down Expand Up @@ -494,12 +494,14 @@ def _unstack_frame(obj, level, fill_value=None):
if is_sparse(blk.values):
new_placement = [[i] for i in new_placement]
new_values = new_values.T
make_block = blk.make_block_same_class
else:
new_placement = [new_placement]
new_values = [new_values.T]
make_block = _make_block

for cols, placement in zip(new_values, new_placement):
newb = blk.make_block_same_class(cols, placement=placement)
newb = make_block(cols, placement=placement)
new_blocks.append(newb)

klass = type(obj)
Expand Down

0 comments on commit 88656a8

Please sign in to comment.