|
47 | 47 | find_common_type)
|
48 | 48 | from pandas.core.dtypes.missing import (
|
49 | 49 | isna, notna, array_equivalent,
|
50 |
| - na_value_for_dtype, |
51 | 50 | _isna_compat,
|
52 | 51 | is_null_datelike_scalar)
|
53 | 52 | import pandas.core.dtypes.concat as _concat
|
@@ -445,18 +444,14 @@ def make_a_block(nv, ref_loc):
|
445 | 444 | except (AttributeError, NotImplementedError):
|
446 | 445 | pass
|
447 | 446 |
|
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 | + |
456 | 451 | return block
|
457 | 452 |
|
458 | 453 | # ndim == 1
|
459 |
| - if self.ndim == 1 or isinstance(self, SparseBlock): |
| 454 | + if self.ndim == 1: |
460 | 455 | if mask.any():
|
461 | 456 | nv = f(mask, new_values, None)
|
462 | 457 | else:
|
@@ -1405,8 +1400,6 @@ def where(self, other, cond, align=True, raise_on_error=True,
|
1405 | 1400 | if not hasattr(cond, 'shape'):
|
1406 | 1401 | raise ValueError("where must have a condition that is ndarray "
|
1407 | 1402 | "like")
|
1408 |
| - else: |
1409 |
| - cond = cond.reshape(values.shape) |
1410 | 1403 |
|
1411 | 1404 | # our where function
|
1412 | 1405 | def func(cond, values, other):
|
@@ -1453,13 +1446,7 @@ def func(cond, values, other):
|
1453 | 1446 | if try_cast:
|
1454 | 1447 | result = self._try_cast_result(result)
|
1455 | 1448 |
|
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) |
1463 | 1450 |
|
1464 | 1451 | # might need to separate out blocks
|
1465 | 1452 | axis = cond.ndim - 1
|
@@ -1582,10 +1569,6 @@ def _nanpercentile(values, q, axis, **kw):
|
1582 | 1569 | result = self._try_coerce_result(result)
|
1583 | 1570 | if is_scalar(result):
|
1584 | 1571 | return ax, self.make_block_scalar(result)
|
1585 |
| - |
1586 |
| - if isinstance(self, SparseBlock): |
1587 |
| - result = SparseArray(result.flatten()) |
1588 |
| - |
1589 | 1572 | return ax, make_block(result,
|
1590 | 1573 | placement=np.arange(len(result)),
|
1591 | 1574 | ndim=ndim)
|
|
0 commit comments