Skip to content

Commit 76fd718

Browse files
authored
CLN: _get_daily_rule (#37775)
1 parent b00749c commit 76fd718

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,6 @@ def _scalar_from_string(self, value: str) -> DTScalarOrNaT:
143143
"""
144144
raise AbstractMethodError(self)
145145

146-
@classmethod
147-
def _rebox_native(cls, value: int) -> Union[int, np.datetime64, np.timedelta64]:
148-
"""
149-
Box an integer unboxed via _unbox_scalar into the native type for
150-
the underlying ndarray.
151-
"""
152-
raise AbstractMethodError(cls)
153-
154146
def _unbox_scalar(
155147
self, value: DTScalarOrNaT, setitem: bool = False
156148
) -> Union[np.int64, np.datetime64, np.timedelta64]:

pandas/tseries/frequencies.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,7 @@ def _infer_daily_rule(self) -> Optional[str]:
321321
return _maybe_add_count(monthly_rule, self.mdiffs[0])
322322

323323
if self.is_unique:
324-
days = self.deltas[0] / _ONE_DAY
325-
if days % 7 == 0:
326-
# Weekly
327-
day = int_to_weekday[self.rep_stamp.weekday()]
328-
return _maybe_add_count(f"W-{day}", days / 7)
329-
else:
330-
return _maybe_add_count("D", days)
324+
return self._get_daily_rule()
331325

332326
if self._is_business_daily():
333327
return "B"
@@ -338,6 +332,16 @@ def _infer_daily_rule(self) -> Optional[str]:
338332

339333
return None
340334

335+
def _get_daily_rule(self) -> Optional[str]:
336+
days = self.deltas[0] / _ONE_DAY
337+
if days % 7 == 0:
338+
# Weekly
339+
wd = int_to_weekday[self.rep_stamp.weekday()]
340+
alias = f"W-{wd}"
341+
return _maybe_add_count(alias, days / 7)
342+
else:
343+
return _maybe_add_count("D", days)
344+
341345
def _get_annual_rule(self) -> Optional[str]:
342346
if len(self.ydiffs) > 1:
343347
return None
@@ -406,14 +410,7 @@ def _get_wom_rule(self) -> Optional[str]:
406410
class _TimedeltaFrequencyInferer(_FrequencyInferer):
407411
def _infer_daily_rule(self):
408412
if self.is_unique:
409-
days = self.deltas[0] / _ONE_DAY
410-
if days % 7 == 0:
411-
# Weekly
412-
wd = int_to_weekday[self.rep_stamp.weekday()]
413-
alias = f"W-{wd}"
414-
return _maybe_add_count(alias, days / 7)
415-
else:
416-
return _maybe_add_count("D", days)
413+
return self._get_daily_rule()
417414

418415

419416
def _is_multiple(us, mult: int) -> bool:

0 commit comments

Comments
 (0)