MCPcopy
hub / github.com/pandas-dev/pandas / _get_wom_rule

Method _get_wom_rule

pandas/tseries/frequencies.py:414–429  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

412 )
413
414 def _get_wom_rule(self) -> str | None:
415 weekdays = unique(self.index.weekday)
416 if len(weekdays) > 1:
417 return None
418
419 week_of_months = unique((self.index.day - 1) // 7)
420 # Only attempt to infer up to WOM-4. See #9425
421 week_of_months = week_of_months[week_of_months < 4]
422 if len(week_of_months) == 0 or len(week_of_months) > 1:
423 return None
424
425 # get which week
426 week = week_of_months[0] + 1
427 wd = int_to_weekday[weekdays[0]]
428
429 return f"WOM-{week}{wd}"
430
431
432class _TimedeltaFrequencyInferer(_FrequencyInferer):

Callers 1

_infer_daily_ruleMethod · 0.95

Calls 1

uniqueFunction · 0.90

Tested by

no test coverage detected