Skip to content

Commit 1076443

Browse files
committed
BUG: Override SparseBlock.make_block with fill_value argument
1 parent 89d7207 commit 1076443

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pandas/core/internals.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,20 @@ def copy(self, deep=True, mgr=None):
27352735
kind=self.kind, copy=deep,
27362736
placement=self.mgr_locs)
27372737

2738+
def make_block(self, values, placement=None,
2739+
ndim=None, fill_value=None, **kwargs):
2740+
"""
2741+
Create a new block, with type inference propagate any values that are
2742+
not specified
2743+
"""
2744+
if fill_value is not None and isinstance(values, SparseArray):
2745+
values = SparseArray(values.to_dense(), fill_value=fill_value,
2746+
kind=values.kind, dtype=values.dtype)
2747+
2748+
return super(SparseBlock, self).make_block(values, placement=placement,
2749+
ndim=ndim, fill_value=None,
2750+
**kwargs)
2751+
27382752
def make_block_same_class(self, values, placement, sparse_index=None,
27392753
kind=None, dtype=None, fill_value=None,
27402754
copy=False, fastpath=True, **kwargs):
@@ -2833,7 +2847,7 @@ def sparse_reindex(self, new_index):
28332847

28342848

28352849
def make_block(values, placement, klass=None, ndim=None, dtype=None,
2836-
fastpath=False):
2850+
fastpath=False, **kwargs):
28372851
if klass is None:
28382852
dtype = dtype or values.dtype
28392853
vtype = dtype.type

0 commit comments

Comments
 (0)