Skip to content

Commit 81a5994

Browse files
authored
CLN: Remove unused code (#57851)
* CLN: Remove unused code * CLN: Fix docstring
1 parent 7ea1c44 commit 81a5994

File tree

5 files changed

+5
-62
lines changed

5 files changed

+5
-62
lines changed

pandas/core/apply.py

-22
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
Literal,
1313
cast,
1414
)
15-
import warnings
1615

1716
import numpy as np
1817

@@ -30,7 +29,6 @@
3029
from pandas.compat._optional import import_optional_dependency
3130
from pandas.errors import SpecificationError
3231
from pandas.util._decorators import cache_readonly
33-
from pandas.util._exceptions import find_stack_level
3432

3533
from pandas.core.dtypes.cast import is_nested_object
3634
from pandas.core.dtypes.common import (
@@ -1992,23 +1990,3 @@ def include_axis(op_name: Literal["agg", "apply"], colg: Series | DataFrame) ->
19921990
return isinstance(colg, ABCDataFrame) or (
19931991
isinstance(colg, ABCSeries) and op_name == "agg"
19941992
)
1995-
1996-
1997-
def warn_alias_replacement(
1998-
obj: AggObjType,
1999-
func: Callable,
2000-
alias: str,
2001-
) -> None:
2002-
if alias.startswith("np."):
2003-
full_alias = alias
2004-
else:
2005-
full_alias = f"{type(obj).__name__}.{alias}"
2006-
alias = f'"{alias}"'
2007-
warnings.warn(
2008-
f"The provided callable {func} is currently using "
2009-
f"{full_alias}. In a future version of pandas, "
2010-
f"the provided callable will be used directly. To keep current "
2011-
f"behavior pass the string {alias} instead.",
2012-
category=FutureWarning,
2013-
stacklevel=find_stack_level(),
2014-
)

pandas/core/arrays/sparse/array.py

-6
Original file line numberDiff line numberDiff line change
@@ -673,12 +673,6 @@ def __len__(self) -> int:
673673
def _null_fill_value(self) -> bool:
674674
return self._dtype._is_na_fill_value
675675

676-
def _fill_value_matches(self, fill_value) -> bool:
677-
if self._null_fill_value:
678-
return isna(fill_value)
679-
else:
680-
return self.fill_value == fill_value
681-
682676
@property
683677
def nbytes(self) -> int:
684678
return self.sp_values.nbytes + self.sp_index.nbytes

pandas/core/groupby/categorical.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
)
1111

1212

13-
def recode_for_groupby(
14-
c: Categorical, sort: bool, observed: bool
15-
) -> tuple[Categorical, Categorical | None]:
13+
def recode_for_groupby(c: Categorical, sort: bool, observed: bool) -> Categorical:
1614
"""
1715
Code the categories to ensure we can groupby for categoricals.
1816
@@ -42,8 +40,6 @@ def recode_for_groupby(
4240
appearance in codes (unless ordered=True, in which case the
4341
original order is preserved), followed by any unrepresented
4442
categories in the original order.
45-
Categorical or None
46-
If we are observed, return the original categorical, otherwise None
4743
"""
4844
# we only care about observed values
4945
if observed:
@@ -63,11 +59,11 @@ def recode_for_groupby(
6359
# return a new categorical that maps our new codes
6460
# and categories
6561
dtype = CategoricalDtype(categories, ordered=c.ordered)
66-
return Categorical._simple_new(codes, dtype=dtype), c
62+
return Categorical._simple_new(codes, dtype=dtype)
6763

6864
# Already sorted according to c.categories; all is fine
6965
if sort:
70-
return c, None
66+
return c
7167

7268
# sort=False should order groups in as-encountered order (GH-8868)
7369

@@ -84,4 +80,4 @@ def recode_for_groupby(
8480
else:
8581
take_codes = unique_notnan_codes
8682

87-
return Categorical(c, c.unique().categories.take(take_codes)), None
83+
return Categorical(c, c.unique().categories.take(take_codes))

pandas/core/groupby/grouper.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ class Grouper:
238238

239239
sort: bool
240240
dropna: bool
241-
_gpr_index: Index | None
242241
_grouper: Index | None
243242

244243
_attributes: tuple[str, ...] = ("key", "level", "freq", "sort", "dropna")
@@ -266,8 +265,6 @@ def __init__(
266265

267266
self._grouper_deprecated = None
268267
self._indexer_deprecated: npt.NDArray[np.intp] | None = None
269-
self._obj_deprecated = None
270-
self._gpr_index = None
271268
self.binner = None
272269
self._grouper = None
273270
self._indexer: npt.NDArray[np.intp] | None = None
@@ -380,10 +377,6 @@ def _set_grouper(
380377
ax = ax.take(indexer)
381378
obj = obj.take(indexer, axis=0)
382379

383-
# error: Incompatible types in assignment (expression has type
384-
# "NDFrameT", variable has type "None")
385-
self._obj_deprecated = obj # type: ignore[assignment]
386-
self._gpr_index = ax
387380
return obj, ax, indexer
388381

389382
@final
@@ -433,7 +426,6 @@ class Grouping:
433426
"""
434427

435428
_codes: npt.NDArray[np.signedinteger] | None = None
436-
_all_grouper: Categorical | None
437429
_orig_cats: Index | None
438430
_index: Index
439431

@@ -452,7 +444,6 @@ def __init__(
452444
self.level = level
453445
self._orig_grouper = grouper
454446
grouping_vector = _convert_grouper(index, grouper)
455-
self._all_grouper = None
456447
self._orig_cats = None
457448
self._index = index
458449
self._sort = sort
@@ -536,9 +527,7 @@ def __init__(
536527
elif isinstance(getattr(grouping_vector, "dtype", None), CategoricalDtype):
537528
# a passed Categorical
538529
self._orig_cats = grouping_vector.categories
539-
grouping_vector, self._all_grouper = recode_for_groupby(
540-
grouping_vector, sort, observed
541-
)
530+
grouping_vector = recode_for_groupby(grouping_vector, sort, observed)
542531

543532
self.grouping_vector = grouping_vector
544533

pandas/core/internals/managers.py

-14
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,6 @@ def __nonzero__(self) -> bool:
267267
# Python3 compat
268268
__bool__ = __nonzero__
269269

270-
def _normalize_axis(self, axis: AxisInt) -> int:
271-
# switch axis to follow BlockManager logic
272-
if self.ndim == 2:
273-
axis = 1 if axis == 0 else 0
274-
return axis
275-
276270
def set_axis(self, axis: AxisInt, new_labels: Index) -> None:
277271
# Caller is responsible for ensuring we have an Index object.
278272
self._validate_set_axis(axis, new_labels)
@@ -446,14 +440,6 @@ def apply(
446440
out = type(self).from_blocks(result_blocks, self.axes)
447441
return out
448442

449-
def apply_with_block(
450-
self,
451-
f,
452-
align_keys: list[str] | None = None,
453-
**kwargs,
454-
) -> Self:
455-
raise AbstractMethodError(self)
456-
457443
@final
458444
def isna(self, func) -> Self:
459445
return self.apply("apply", func=func)

0 commit comments

Comments
 (0)