Skip to content

Commit 6423ee8

Browse files
authored
REF: remove unused variable and checks (#59463)
* REF: removed unused convert keyword * REF: remove unhit field checks * REF: inline _object_ops
1 parent 91875d0 commit 6423ee8

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

pandas/core/arrays/datetimes.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,8 @@ def f(self):
158158
# these return a boolean by-definition
159159
return result
160160

161-
if field in self._object_ops:
162-
result = fields.get_date_name_field(values, field, reso=self._creso)
163-
result = self._maybe_mask_results(result, fill_value=None)
164-
165-
else:
166-
result = fields.get_date_field(values, field, reso=self._creso)
167-
result = self._maybe_mask_results(
168-
result, fill_value=None, convert="float64"
169-
)
161+
result = fields.get_date_field(values, field, reso=self._creso)
162+
result = self._maybe_mask_results(result, fill_value=None, convert="float64")
170163

171164
return result
172165

@@ -243,7 +236,6 @@ def _scalar_type(self) -> type[Timestamp]:
243236
"is_year_end",
244237
"is_leap_year",
245238
]
246-
_object_ops: list[str] = ["freq", "tz"]
247239
_field_ops: list[str] = [
248240
"year",
249241
"month",
@@ -264,7 +256,7 @@ def _scalar_type(self) -> type[Timestamp]:
264256
]
265257
_other_ops: list[str] = ["date", "time", "timetz"]
266258
_datetimelike_ops: list[str] = (
267-
_field_ops + _object_ops + _bool_ops + _other_ops + ["unit"]
259+
_field_ops + _bool_ops + _other_ops + ["unit", "freq", "tz"]
268260
)
269261
_datetimelike_methods: list[str] = [
270262
"to_period",

pandas/core/arrays/string_.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ def _str_map(
354354
self, f, na_value=None, dtype: Dtype | None = None, convert: bool = True
355355
):
356356
if self.dtype.na_value is np.nan:
357-
return self._str_map_nan_semantics(
358-
f, na_value=na_value, dtype=dtype, convert=convert
359-
)
357+
return self._str_map_nan_semantics(f, na_value=na_value, dtype=dtype)
360358

361359
from pandas.arrays import BooleanArray
362360

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

434-
def _str_map_nan_semantics(
435-
self, f, na_value=None, dtype: Dtype | None = None, convert: bool = True
436-
):
432+
def _str_map_nan_semantics(self, f, na_value=None, dtype: Dtype | None = None):
437433
if dtype is None:
438434
dtype = self.dtype
439435
if na_value is None:

pandas/core/arrays/timedeltas.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ def _scalar_type(self) -> type[Timedelta]:
152152
# define my properties & methods for delegation
153153
_other_ops: list[str] = []
154154
_bool_ops: list[str] = []
155-
_object_ops: list[str] = ["freq"]
156155
_field_ops: list[str] = ["days", "seconds", "microseconds", "nanoseconds"]
157-
_datetimelike_ops: list[str] = _field_ops + _object_ops + _bool_ops + ["unit"]
156+
_datetimelike_ops: list[str] = _field_ops + _bool_ops + ["unit", "freq"]
158157
_datetimelike_methods: list[str] = [
159158
"to_pytimedelta",
160159
"total_seconds",

0 commit comments

Comments
 (0)