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

Function is_subperiod

pandas/tseries/frequencies.py:455–507  ·  view source on GitHub ↗

Returns True if downsampling 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

453
454
455def is_subperiod(source, target) -> bool:
456 """
457 Returns True if downsampling is possible between source and target
458 frequencies
459
460 Parameters
461 ----------
462 source : str or DateOffset
463 Frequency converting from
464 target : str or DateOffset
465 Frequency converting to
466
467 Returns
468 -------
469 bool
470 """
471 if target is None or source is None:
472 return False
473 source = _maybe_coerce_freq(source)
474 target = _maybe_coerce_freq(target)
475
476 if _is_annual(target):
477 if _is_quarterly(source):
478 return _quarter_months_conform(
479 get_rule_month(source), get_rule_month(target)
480 )
481 return source in {"D", "C", "B", "M", "h", "min", "s", "ms", "us", "ns"}
482 elif _is_quarterly(target):
483 return source in {"D", "C", "B", "M", "h", "min", "s", "ms", "us", "ns"}
484 elif _is_monthly(target):
485 return source in {"D", "C", "B", "h", "min", "s", "ms", "us", "ns"}
486 elif _is_weekly(target):
487 return source in {target, "D", "C", "B", "h", "min", "s", "ms", "us", "ns"}
488 elif target == "B":
489 return source in {"B", "h", "min", "s", "ms", "us", "ns"}
490 elif target == "C":
491 return source in {"C", "h", "min", "s", "ms", "us", "ns"}
492 elif target == "D":
493 return source in {"D", "h", "min", "s", "ms", "us", "ns"}
494 elif target == "h":
495 return source in {"h", "min", "s", "ms", "us", "ns"}
496 elif target == "min":
497 return source in {"min", "s", "ms", "us", "ns"}
498 elif target == "s":
499 return source in {"s", "ms", "us", "ns"}
500 elif target == "ms":
501 return source in {"ms", "us", "ns"}
502 elif target == "us":
503 return source in {"us", "ns"}
504 elif target == "ns":
505 return source in {"ns"}
506 else:
507 return False
508
509
510def is_superperiod(source, target) -> bool:

Callers 4

maybe_resampleFunction · 0.90
_is_subFunction · 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