Skip to content

CLN: Remove unused code #57851

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
Mar 15, 2024
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
22 changes: 0 additions & 22 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Literal,
cast,
)
import warnings

import numpy as np

Expand All @@ -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 (
Expand Down Expand Up @@ -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(),
)
6 changes: 0 additions & 6 deletions pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions pandas/core/groupby/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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:
Expand All @@ -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)

Expand All @@ -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))
13 changes: 1 addition & 12 deletions pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -433,7 +426,6 @@ class Grouping:
"""

_codes: npt.NDArray[np.signedinteger] | None = None
_all_grouper: Categorical | None
_orig_cats: Index | None
_index: Index

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
14 changes: 0 additions & 14 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down