Skip to content

Commit ab59ad4

Browse files
committed
BUG: Override SparseBlock._try_coerce_result to make result flatten and sparse
1 parent e1d61b9 commit ab59ad4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pandas/core/internals.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,6 +2855,12 @@ def sparse_reindex(self, new_index):
28552855
return self.make_block_same_class(values, sparse_index=new_index,
28562856
placement=self.mgr_locs)
28572857

2858+
def _try_coerce_result(self, result):
2859+
""" reverse of try_coerce_args """
2860+
if isinstance(result, np.ndarray):
2861+
result = SparseArray(result.flatten(), kind=self.kind)
2862+
return result
2863+
28582864

28592865
def make_block(values, placement, klass=None, ndim=None, dtype=None,
28602866
fastpath=False, **kwargs):

0 commit comments

Comments
 (0)