Skip to content

REF: remove unreachable code in core.internals #26800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,14 @@ def split_and_operate(self, mask, f, inplace):
new_values = self.values

def make_a_block(nv, ref_loc):
if isinstance(nv, Block):
block = nv
elif isinstance(nv, list):
if isinstance(nv, list):
assert len(nv) == 1, nv
assert isinstance(nv[0], Block)
block = nv[0]
else:
# Put back the dimension that was taken from it and make
# a block out of the result.
try:
nv = _block_shape(nv, ndim=self.ndim)
except (AttributeError, NotImplementedError):
pass
nv = _block_shape(nv, ndim=self.ndim)
block = self.make_block(values=nv,
placement=ref_loc)
return block
Expand Down Expand Up @@ -2629,10 +2626,10 @@ def f(m, v, i):
values = fn(v.ravel(), **fn_kwargs)
try:
values = values.reshape(shape)
values = _block_shape(values, ndim=self.ndim)
except (AttributeError, NotImplementedError):
pass

values = _block_shape(values, ndim=self.ndim)
return values

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

# see if we are only masking values that if putted
# will work in the current dtype
Expand Down
38 changes: 3 additions & 35 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,11 @@ def quantile(self, axis=0, consolidate=True, transposed=False,
self._consolidate_inplace()

def get_axe(block, qs, axes):
# Because Series dispatches to DataFrame, we will always have
# block.ndim == 2
from pandas import Float64Index
if is_list_like(qs):
ax = Float64Index(qs)
elif block.ndim == 1:
ax = Float64Index([qs])
else:
ax = axes[0]
return ax
Expand Down Expand Up @@ -1345,27 +1345,6 @@ def take(self, indexer, axis=1, verify=True, convert=True):
return self.reindex_indexer(new_axis=new_labels, indexer=indexer,
axis=axis, allow_dups=True)

def merge(self, other, lsuffix='', rsuffix=''):
# We assume at this point that the axes of self and other match.
# This is only called from Panel.join, which reindexes prior
# to calling to ensure this assumption holds.
l, r = items_overlap_with_suffix(left=self.items, lsuffix=lsuffix,
right=other.items, rsuffix=rsuffix)
new_items = _concat_indexes([l, r])

new_blocks = [blk.copy(deep=False) for blk in self.blocks]

offset = self.shape[0]
for blk in other.blocks:
blk = blk.copy(deep=False)
blk.mgr_locs = blk.mgr_locs.add(offset)
new_blocks.append(blk)

new_axes = list(self.axes)
new_axes[0] = new_items

return self.__class__(_consolidate(new_blocks), new_axes)

def equals(self, other):
self_axes, other_axes = self.axes, other.axes
if len(self_axes) != len(other_axes):
Expand Down Expand Up @@ -1553,14 +1532,6 @@ def get_values(self):
""" return a dense type view """
return np.array(self._block.to_dense(), copy=False)

@property
def asobject(self):
"""
return a object dtype array. datetime/timedelta like values are boxed
to Timestamp/Timedelta instances.
"""
return self._block.get_values(dtype=object)

@property
def _can_hold_na(self):
return self._block._can_hold_na
Expand Down Expand Up @@ -1949,10 +1920,7 @@ def _compare_or_regex_search(a, b, regex=False):
return result


def _concat_indexes(indexes):
return indexes[0].append(indexes[1:])


# TODO: this is no longer used in this module, could be moved to concat
def items_overlap_with_suffix(left, lsuffix, right, rsuffix):
"""
If two indices overlap, add suffixes to overlapping entries.
Expand Down