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

Function _get_periods_per_ymd

pandas/plotting/_matplotlib/converter.py:537–570  ·  view source on GitHub ↗
(freq: BaseOffset)

Source from the content-addressed store, hash-verified

535
536
537def _get_periods_per_ymd(freq: BaseOffset) -> tuple[int, int, int]:
538 # error: "BaseOffset" has no attribute "_period_dtype_code"
539 dtype_code = freq._period_dtype_code # type: ignore[attr-defined]
540 freq_group = FreqGroup.from_period_dtype_code(dtype_code)
541
542 ppd = -1 # placeholder for above-day freqs
543
544 if dtype_code >= FreqGroup.FR_HR.value: # pyright: ignore[reportAttributeAccessIssue]
545 # error: "BaseOffset" has no attribute "_creso"
546 ppd = periods_per_day(freq._creso) # type: ignore[attr-defined]
547 ppm = 28 * ppd
548 ppy = 365 * ppd
549 elif freq_group == FreqGroup.FR_BUS:
550 ppm = 19
551 ppy = 261
552 elif freq_group == FreqGroup.FR_DAY:
553 ppm = 28
554 ppy = 365
555 elif freq_group == FreqGroup.FR_WK:
556 ppm = 3
557 ppy = 52
558 elif freq_group == FreqGroup.FR_MTH:
559 ppm = 1
560 ppy = 12
561 elif freq_group == FreqGroup.FR_QTR:
562 ppm = -1 # placerholder
563 ppy = 4
564 elif freq_group == FreqGroup.FR_ANN:
565 ppm = -1 # placeholder
566 ppy = 1
567 else:
568 raise NotImplementedError(f"Unsupported frequency: {dtype_code}")
569
570 return ppd, ppm, ppy
571
572
573@functools.cache

Callers 3

_daily_finderFunction · 0.85
_monthly_finderFunction · 0.85
_quarterly_finderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected