diff --git a/pandas/core/apply.py b/pandas/core/apply.py index f2fb503be86f5..de2fd9394e2fa 100644 --- a/pandas/core/apply.py +++ b/pandas/core/apply.py @@ -12,7 +12,6 @@ Literal, cast, ) -import warnings import numpy as np @@ -30,7 +29,6 @@ from pandas.compat._optional import import_optional_dependency from pandas.errors import SpecificationError from pandas.util._decorators import cache_readonly -from pandas.util._exceptions import find_stack_level from pandas.core.dtypes.cast import is_nested_object from pandas.core.dtypes.common import ( @@ -1992,23 +1990,3 @@ def include_axis(op_name: Literal["agg", "apply"], colg: Series | DataFrame) -> return isinstance(colg, ABCDataFrame) or ( isinstance(colg, ABCSeries) and op_name == "agg" ) - - -def warn_alias_replacement( - obj: AggObjType, - func: Callable, - alias: str, -) -> None: - if alias.startswith("np."): - full_alias = alias - else: - full_alias = f"{type(obj).__name__}.{alias}" - alias = f'"{alias}"' - warnings.warn( - f"The provided callable {func} is currently using " - f"{full_alias}. In a future version of pandas, " - f"the provided callable will be used directly. To keep current " - f"behavior pass the string {alias} instead.", - category=FutureWarning, - stacklevel=find_stack_level(), - ) diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index 8d94662ab4303..bf44e5e099530 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -673,12 +673,6 @@ def __len__(self) -> int: def _null_fill_value(self) -> bool: return self._dtype._is_na_fill_value - def _fill_value_matches(self, fill_value) -> bool: - if self._null_fill_value: - return isna(fill_value) - else: - return self.fill_value == fill_value - @property def nbytes(self) -> int: return self.sp_values.nbytes + self.sp_index.nbytes diff --git a/pandas/core/groupby/categorical.py b/pandas/core/groupby/categorical.py index 037ca81477677..49130d91a0126 100644 --- a/pandas/core/groupby/categorical.py +++ b/pandas/core/groupby/categorical.py @@ -10,9 +10,7 @@ ) -def recode_for_groupby( - c: Categorical, sort: bool, observed: bool -) -> tuple[Categorical, Categorical | None]: +def recode_for_groupby(c: Categorical, sort: bool, observed: bool) -> Categorical: """ Code the categories to ensure we can groupby for categoricals. @@ -42,8 +40,6 @@ def recode_for_groupby( appearance in codes (unless ordered=True, in which case the original order is preserved), followed by any unrepresented categories in the original order. - Categorical or None - If we are observed, return the original categorical, otherwise None """ # we only care about observed values if observed: @@ -63,11 +59,11 @@ def recode_for_groupby( # return a new categorical that maps our new codes # and categories dtype = CategoricalDtype(categories, ordered=c.ordered) - return Categorical._simple_new(codes, dtype=dtype), c + return Categorical._simple_new(codes, dtype=dtype) # Already sorted according to c.categories; all is fine if sort: - return c, None + return c # sort=False should order groups in as-encountered order (GH-8868) @@ -84,4 +80,4 @@ def recode_for_groupby( else: take_codes = unique_notnan_codes - return Categorical(c, c.unique().categories.take(take_codes)), None + return Categorical(c, c.unique().categories.take(take_codes)) diff --git a/pandas/core/groupby/grouper.py b/pandas/core/groupby/grouper.py index 3040f9c64beff..239d78b3b8b7a 100644 --- a/pandas/core/groupby/grouper.py +++ b/pandas/core/groupby/grouper.py @@ -238,7 +238,6 @@ class Grouper: sort: bool dropna: bool - _gpr_index: Index | None _grouper: Index | None _attributes: tuple[str, ...] = ("key", "level", "freq", "sort", "dropna") @@ -266,8 +265,6 @@ def __init__( self._grouper_deprecated = None self._indexer_deprecated: npt.NDArray[np.intp] | None = None - self._obj_deprecated = None - self._gpr_index = None self.binner = None self._grouper = None self._indexer: npt.NDArray[np.intp] | None = None @@ -380,10 +377,6 @@ def _set_grouper( ax = ax.take(indexer) obj = obj.take(indexer, axis=0) - # error: Incompatible types in assignment (expression has type - # "NDFrameT", variable has type "None") - self._obj_deprecated = obj # type: ignore[assignment] - self._gpr_index = ax return obj, ax, indexer @final @@ -433,7 +426,6 @@ class Grouping: """ _codes: npt.NDArray[np.signedinteger] | None = None - _all_grouper: Categorical | None _orig_cats: Index | None _index: Index @@ -452,7 +444,6 @@ def __init__( self.level = level self._orig_grouper = grouper grouping_vector = _convert_grouper(index, grouper) - self._all_grouper = None self._orig_cats = None self._index = index self._sort = sort @@ -536,9 +527,7 @@ def __init__( elif isinstance(getattr(grouping_vector, "dtype", None), CategoricalDtype): # a passed Categorical self._orig_cats = grouping_vector.categories - grouping_vector, self._all_grouper = recode_for_groupby( - grouping_vector, sort, observed - ) + grouping_vector = recode_for_groupby(grouping_vector, sort, observed) self.grouping_vector = grouping_vector diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 46716bb8bf81e..d920ebc60de8c 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -267,12 +267,6 @@ def __nonzero__(self) -> bool: # Python3 compat __bool__ = __nonzero__ - def _normalize_axis(self, axis: AxisInt) -> int: - # switch axis to follow BlockManager logic - if self.ndim == 2: - axis = 1 if axis == 0 else 0 - return axis - def set_axis(self, axis: AxisInt, new_labels: Index) -> None: # Caller is responsible for ensuring we have an Index object. self._validate_set_axis(axis, new_labels) @@ -446,14 +440,6 @@ def apply( out = type(self).from_blocks(result_blocks, self.axes) return out - def apply_with_block( - self, - f, - align_keys: list[str] | None = None, - **kwargs, - ) -> Self: - raise AbstractMethodError(self) - @final def isna(self, func) -> Self: return self.apply("apply", func=func)