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

Function is_superperiod

pandas/tseries/frequencies.py:510–565  ·  view source on GitHub ↗

Returns True if upsampling is possible between source and target frequencies Parameters ---------- source : str or DateOffset Frequency converting from target : str or DateOffset Frequency converting to Returns ------- bool

(source, target)

Source from the content-addressed store, hash-verified

508
509
510def is_superperiod(source, target) -> bool:
511 """
512 Returns True if upsampling is possible between source and target
513 frequencies
514
515 Parameters
516 ----------
517 source : str or DateOffset
518 Frequency converting from
519 target : str or DateOffset
520 Frequency converting to
521
522 Returns
523 -------
524 bool
525 """
526 if target is None or source is None:
527 return False
528 source = _maybe_coerce_freq(source)
529 target = _maybe_coerce_freq(target)
530
531 if _is_annual(source):
532 if _is_annual(target):
533 return get_rule_month(source) == get_rule_month(target)
534
535 if _is_quarterly(target):
536 smonth = get_rule_month(source)
537 tmonth = get_rule_month(target)
538 return _quarter_months_conform(smonth, tmonth)
539 return target in {"D", "C", "B", "M", "h", "min", "s", "ms", "us", "ns"}
540 elif _is_quarterly(source):
541 return target in {"D", "C", "B", "M", "h", "min", "s", "ms", "us", "ns"}
542 elif _is_monthly(source):
543 return target in {"D", "C", "B", "h", "min", "s", "ms", "us", "ns"}
544 elif _is_weekly(source):
545 return target in {source, "D", "C", "B", "h", "min", "s", "ms", "us", "ns"}
546 elif source == "B":
547 return target in {"D", "C", "B", "h", "min", "s", "ms", "us", "ns"}
548 elif source == "C":
549 return target in {"D", "C", "B", "h", "min", "s", "ms", "us", "ns"}
550 elif source == "D":
551 return target in {"D", "C", "B", "h", "min", "s", "ms", "us", "ns"}
552 elif source == "h":
553 return target in {"h", "min", "s", "ms", "us", "ns"}
554 elif source == "min":
555 return target in {"min", "s", "ms", "us", "ns"}
556 elif source == "s":
557 return target in {"s", "ms", "us", "ns"}
558 elif source == "ms":
559 return target in {"ms", "us", "ns"}
560 elif source == "us":
561 return target in {"us", "ns"}
562 elif source == "ns":
563 return target in {"ns"}
564 else:
565 return False
566
567

Callers 4

maybe_resampleFunction · 0.90
_is_supFunction · 0.90
_downsampleMethod · 0.90
test_super_sub_symmetryFunction · 0.90

Calls 6

_maybe_coerce_freqFunction · 0.85
_is_annualFunction · 0.85
_is_quarterlyFunction · 0.85
_quarter_months_conformFunction · 0.85
_is_monthlyFunction · 0.85
_is_weeklyFunction · 0.85

Tested by 1

test_super_sub_symmetryFunction · 0.72