Skip to content

Commit 8ff488a

Browse files
jbrockmendeljreback
authored andcommitted
REF: remove unreachable code in core.internals (#26800)
1 parent b72a4ff commit 8ff488a

File tree

2 files changed

+8
-45
lines changed

2 files changed

+8
-45
lines changed

pandas/core/internals/blocks.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,14 @@ def split_and_operate(self, mask, f, inplace):
417417
new_values = self.values
418418

419419
def make_a_block(nv, ref_loc):
420-
if isinstance(nv, Block):
421-
block = nv
422-
elif isinstance(nv, list):
420+
if isinstance(nv, list):
421+
assert len(nv) == 1, nv
422+
assert isinstance(nv[0], Block)
423423
block = nv[0]
424424
else:
425425
# Put back the dimension that was taken from it and make
426426
# a block out of the result.
427-
try:
428-
nv = _block_shape(nv, ndim=self.ndim)
429-
except (AttributeError, NotImplementedError):
430-
pass
427+
nv = _block_shape(nv, ndim=self.ndim)
431428
block = self.make_block(values=nv,
432429
placement=ref_loc)
433430
return block
@@ -2629,10 +2626,10 @@ def f(m, v, i):
26292626
values = fn(v.ravel(), **fn_kwargs)
26302627
try:
26312628
values = values.reshape(shape)
2632-
values = _block_shape(values, ndim=self.ndim)
26332629
except (AttributeError, NotImplementedError):
26342630
pass
26352631

2632+
values = _block_shape(values, ndim=self.ndim)
26362633
return values
26372634

26382635
if by_item and not self._is_single_block:
@@ -3168,8 +3165,6 @@ def _putmask_smart(v, m, n):
31683165
# n should be the length of the mask or a scalar here
31693166
if not is_list_like(n):
31703167
n = np.repeat(n, len(m))
3171-
elif isinstance(n, np.ndarray) and n.ndim == 0: # numpy scalar
3172-
n = np.repeat(np.array(n, ndmin=1), len(m))
31733168

31743169
# see if we are only masking values that if putted
31753170
# will work in the current dtype

pandas/core/internals/managers.py

+3-35
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,11 @@ def quantile(self, axis=0, consolidate=True, transposed=False,
433433
self._consolidate_inplace()
434434

435435
def get_axe(block, qs, axes):
436+
# Because Series dispatches to DataFrame, we will always have
437+
# block.ndim == 2
436438
from pandas import Float64Index
437439
if is_list_like(qs):
438440
ax = Float64Index(qs)
439-
elif block.ndim == 1:
440-
ax = Float64Index([qs])
441441
else:
442442
ax = axes[0]
443443
return ax
@@ -1345,27 +1345,6 @@ def take(self, indexer, axis=1, verify=True, convert=True):
13451345
return self.reindex_indexer(new_axis=new_labels, indexer=indexer,
13461346
axis=axis, allow_dups=True)
13471347

1348-
def merge(self, other, lsuffix='', rsuffix=''):
1349-
# We assume at this point that the axes of self and other match.
1350-
# This is only called from Panel.join, which reindexes prior
1351-
# to calling to ensure this assumption holds.
1352-
l, r = items_overlap_with_suffix(left=self.items, lsuffix=lsuffix,
1353-
right=other.items, rsuffix=rsuffix)
1354-
new_items = _concat_indexes([l, r])
1355-
1356-
new_blocks = [blk.copy(deep=False) for blk in self.blocks]
1357-
1358-
offset = self.shape[0]
1359-
for blk in other.blocks:
1360-
blk = blk.copy(deep=False)
1361-
blk.mgr_locs = blk.mgr_locs.add(offset)
1362-
new_blocks.append(blk)
1363-
1364-
new_axes = list(self.axes)
1365-
new_axes[0] = new_items
1366-
1367-
return self.__class__(_consolidate(new_blocks), new_axes)
1368-
13691348
def equals(self, other):
13701349
self_axes, other_axes = self.axes, other.axes
13711350
if len(self_axes) != len(other_axes):
@@ -1553,14 +1532,6 @@ def get_values(self):
15531532
""" return a dense type view """
15541533
return np.array(self._block.to_dense(), copy=False)
15551534

1556-
@property
1557-
def asobject(self):
1558-
"""
1559-
return a object dtype array. datetime/timedelta like values are boxed
1560-
to Timestamp/Timedelta instances.
1561-
"""
1562-
return self._block.get_values(dtype=object)
1563-
15641535
@property
15651536
def _can_hold_na(self):
15661537
return self._block._can_hold_na
@@ -1949,10 +1920,7 @@ def _compare_or_regex_search(a, b, regex=False):
19491920
return result
19501921

19511922

1952-
def _concat_indexes(indexes):
1953-
return indexes[0].append(indexes[1:])
1954-
1955-
1923+
# TODO: this is no longer used in this module, could be moved to concat
19561924
def items_overlap_with_suffix(left, lsuffix, right, rsuffix):
19571925
"""
19581926
If two indices overlap, add suffixes to overlapping entries.

0 commit comments

Comments
 (0)