Skip to content

REF: remove unused variable and checks #59463

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 3 commits into from
Aug 13, 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
14 changes: 3 additions & 11 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,8 @@ def f(self):
# these return a boolean by-definition
return result

if field in self._object_ops:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can _object_ops be in-lined in _datetimelike_ops now since this usage is removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. Will update.

result = fields.get_date_name_field(values, field, reso=self._creso)
result = self._maybe_mask_results(result, fill_value=None)

else:
result = fields.get_date_field(values, field, reso=self._creso)
result = self._maybe_mask_results(
result, fill_value=None, convert="float64"
)
result = fields.get_date_field(values, field, reso=self._creso)
result = self._maybe_mask_results(result, fill_value=None, convert="float64")

return result

Expand Down Expand Up @@ -243,7 +236,6 @@ def _scalar_type(self) -> type[Timestamp]:
"is_year_end",
"is_leap_year",
]
_object_ops: list[str] = ["freq", "tz"]
_field_ops: list[str] = [
"year",
"month",
Expand All @@ -264,7 +256,7 @@ def _scalar_type(self) -> type[Timestamp]:
]
_other_ops: list[str] = ["date", "time", "timetz"]
_datetimelike_ops: list[str] = (
_field_ops + _object_ops + _bool_ops + _other_ops + ["unit"]
_field_ops + _bool_ops + _other_ops + ["unit", "freq", "tz"]
)
_datetimelike_methods: list[str] = [
"to_period",
Expand Down
8 changes: 2 additions & 6 deletions pandas/core/arrays/string_.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,7 @@ def _str_map(
self, f, na_value=None, dtype: Dtype | None = None, convert: bool = True
):
if self.dtype.na_value is np.nan:
return self._str_map_nan_semantics(
f, na_value=na_value, dtype=dtype, convert=convert
)
return self._str_map_nan_semantics(f, na_value=na_value, dtype=dtype)

from pandas.arrays import BooleanArray

Expand Down Expand Up @@ -431,9 +429,7 @@ def _str_map_str_or_object(
# -> We don't know the result type. E.g. `.get` can return anything.
return lib.map_infer_mask(arr, f, mask.view("uint8"))

def _str_map_nan_semantics(
self, f, na_value=None, dtype: Dtype | None = None, convert: bool = True
):
def _str_map_nan_semantics(self, f, na_value=None, dtype: Dtype | None = None):
if dtype is None:
dtype = self.dtype
if na_value is None:
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ def _scalar_type(self) -> type[Timedelta]:
# define my properties & methods for delegation
_other_ops: list[str] = []
_bool_ops: list[str] = []
_object_ops: list[str] = ["freq"]
_field_ops: list[str] = ["days", "seconds", "microseconds", "nanoseconds"]
_datetimelike_ops: list[str] = _field_ops + _object_ops + _bool_ops + ["unit"]
_datetimelike_ops: list[str] = _field_ops + _bool_ops + ["unit", "freq"]
_datetimelike_methods: list[str] = [
"to_pytimedelta",
"total_seconds",
Expand Down
Loading