Skip to content

Commit 89d7207

Browse files
committed
Revert changes in Block.whare
1 parent 7a60276 commit 89d7207

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

pandas/core/internals.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
find_common_type)
4848
from pandas.core.dtypes.missing import (
4949
isna, notna, array_equivalent,
50-
na_value_for_dtype,
5150
_isna_compat,
5251
is_null_datelike_scalar)
5352
import pandas.core.dtypes.concat as _concat
@@ -445,18 +444,14 @@ def make_a_block(nv, ref_loc):
445444
except (AttributeError, NotImplementedError):
446445
pass
447446

448-
if isinstance(self, SparseBlock):
449-
block = self.make_block_same_class(values=nv,
450-
placement=ref_loc,
451-
fastpath=True)
452-
else:
453-
block = self.make_block(values=nv,
454-
placement=ref_loc,
455-
fastpath=True)
447+
block = self.make_block(values=nv,
448+
placement=ref_loc,
449+
fastpath=True)
450+
456451
return block
457452

458453
# ndim == 1
459-
if self.ndim == 1 or isinstance(self, SparseBlock):
454+
if self.ndim == 1:
460455
if mask.any():
461456
nv = f(mask, new_values, None)
462457
else:
@@ -1405,8 +1400,6 @@ def where(self, other, cond, align=True, raise_on_error=True,
14051400
if not hasattr(cond, 'shape'):
14061401
raise ValueError("where must have a condition that is ndarray "
14071402
"like")
1408-
else:
1409-
cond = cond.reshape(values.shape)
14101403

14111404
# our where function
14121405
def func(cond, values, other):
@@ -1453,13 +1446,7 @@ def func(cond, values, other):
14531446
if try_cast:
14541447
result = self._try_cast_result(result)
14551448

1456-
if isinstance(self, SparseBlock):
1457-
fill_value = na_value_for_dtype(result.dtype)
1458-
return self.make_block_same_class(result,
1459-
self.mgr_locs,
1460-
fill_value=fill_value)
1461-
else:
1462-
return self.make_block(result)
1449+
return self.make_block(result)
14631450

14641451
# might need to separate out blocks
14651452
axis = cond.ndim - 1
@@ -1582,10 +1569,6 @@ def _nanpercentile(values, q, axis, **kw):
15821569
result = self._try_coerce_result(result)
15831570
if is_scalar(result):
15841571
return ax, self.make_block_scalar(result)
1585-
1586-
if isinstance(self, SparseBlock):
1587-
result = SparseArray(result.flatten())
1588-
15891572
return ax, make_block(result,
15901573
placement=np.arange(len(result)),
15911574
ndim=ndim)

0 commit comments

Comments
 (0)