Skip to content

Commit 1c9f23c

Browse files
jbrockmendeljreback
authored andcommitted
CLN: prune unreachable code (#31106)
1 parent f19035d commit 1c9f23c

File tree

6 files changed

+11
-43
lines changed

6 files changed

+11
-43
lines changed

pandas/core/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,12 +583,10 @@ def _is_builtin_func(self, arg):
583583
class ShallowMixin:
584584
_attributes: List[str] = []
585585

586-
def _shallow_copy(self, obj=None, **kwargs):
586+
def _shallow_copy(self, obj, **kwargs):
587587
"""
588588
return a new object with the replacement attributes
589589
"""
590-
if obj is None:
591-
obj = self._selected_obj.copy()
592590

593591
if isinstance(obj, self._constructor):
594592
obj = obj.obj

pandas/core/frame.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,14 +2749,7 @@ def _ixs(self, i: int, axis: int = 0):
27492749
else:
27502750
label = self.columns[i]
27512751

2752-
# if the values returned are not the same length
2753-
# as the index (iow a not found value), iget returns
2754-
# a 0-len ndarray. This is effectively catching
2755-
# a numpy error (as numpy should really raise)
27562752
values = self._data.iget(i)
2757-
2758-
if len(self.index) and not len(values):
2759-
values = np.array([np.nan] * len(self.index), dtype=object)
27602753
result = self._box_col_values(values, label)
27612754

27622755
# this is a cached value, mark it so

pandas/core/generic.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,19 +3173,6 @@ def to_csv(
31733173

31743174
return None
31753175

3176-
# ----------------------------------------------------------------------
3177-
# Fancy Indexing
3178-
3179-
@classmethod
3180-
def _create_indexer(cls, name: str, indexer) -> None:
3181-
"""Create an indexer like _name in the class.
3182-
3183-
Kept for compatibility with geopandas. To be removed in the future. See GH27258
3184-
"""
3185-
if getattr(cls, name, None) is None:
3186-
_indexer = functools.partial(indexer, name)
3187-
setattr(cls, name, property(_indexer, doc=indexer.__doc__))
3188-
31893176
# ----------------------------------------------------------------------
31903177
# Lookup Caching
31913178

@@ -3579,14 +3566,12 @@ def _set_item(self, key, value) -> None:
35793566
self._data.set(key, value)
35803567
self._clear_item_cache()
35813568

3582-
def _set_is_copy(self, ref=None, copy: bool_t = True) -> None:
3569+
def _set_is_copy(self, ref, copy: bool_t = True) -> None:
35833570
if not copy:
35843571
self._is_copy = None
35853572
else:
3586-
if ref is not None:
3587-
self._is_copy = weakref.ref(ref)
3588-
else:
3589-
self._is_copy = None
3573+
assert ref is not None
3574+
self._is_copy = weakref.ref(ref)
35903575

35913576
def _check_is_chained_assignment_possible(self) -> bool_t:
35923577
"""

pandas/core/indexes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3129,7 +3129,7 @@ def _convert_scalar_indexer(self, key, kind=None):
31293129

31303130
if kind in ["getitem"] and is_float(key):
31313131
if not self.is_floating():
3132-
return self._invalid_indexer("label", key)
3132+
self._invalid_indexer("label", key)
31333133

31343134
elif kind in ["loc"] and is_float(key):
31353135

pandas/core/indexing.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,8 @@ def _get_setitem_indexer(self, key):
619619
if isinstance(key, range):
620620
return list(key)
621621

622-
axis = self.axis or 0
623622
try:
624-
return self._convert_to_indexer(key, axis=axis)
623+
return self._convert_to_indexer(key, axis=0)
625624
except TypeError as e:
626625

627626
# invalid indexer type vs 'other' indexing errors
@@ -1472,9 +1471,7 @@ def _get_listlike_indexer(self, key, axis: int, raise_missing: bool = False):
14721471
else:
14731472
keyarr, indexer, new_indexer = ax._reindex_non_unique(keyarr)
14741473

1475-
self._validate_read_indexer(
1476-
keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
1477-
)
1474+
self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing)
14781475
return keyarr, indexer
14791476

14801477
def _getitem_iterable(self, key, axis: int):

pandas/core/internals/managers.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -766,16 +766,14 @@ def copy_func(ax):
766766
res.axes = new_axes
767767
return res
768768

769-
def as_array(self, transpose=False, items=None):
770-
"""Convert the blockmanager data into an numpy array.
769+
def as_array(self, transpose: bool = False) -> np.ndarray:
770+
"""
771+
Convert the blockmanager data into an numpy array.
771772
772773
Parameters
773774
----------
774775
transpose : boolean, default False
775776
If True, transpose the return array
776-
items : list of strings or None
777-
Names of block items that will be included in the returned
778-
array. ``None`` means that all block items will be used
779777
780778
Returns
781779
-------
@@ -785,10 +783,7 @@ def as_array(self, transpose=False, items=None):
785783
arr = np.empty(self.shape, dtype=float)
786784
return arr.transpose() if transpose else arr
787785

788-
if items is not None:
789-
mgr = self.reindex_axis(items, axis=0)
790-
else:
791-
mgr = self
786+
mgr = self
792787

793788
if self._is_single_block and mgr.blocks[0].is_datetimetz:
794789
# TODO(Block.get_values): Make DatetimeTZBlock.get_values

0 commit comments

Comments
 (0)