diff --git a/saqc/funcs/constants.py b/saqc/funcs/constants.py index d93fb349d6b09f46ca1d16dacff31c993cf1f2ab..d4811092d53c067b385627dc066c7f62f102cdfe 100644 --- a/saqc/funcs/constants.py +++ b/saqc/funcs/constants.py @@ -130,7 +130,6 @@ def flagByVariance( Flags values may have changed, relatively to the flags input. """ dataseries = data[field] - delta = getFreqDelta(dataseries.index) if not delta: raise IndexError("Timeseries irregularly sampled!") @@ -142,6 +141,7 @@ def flagByVariance( max_consec_missing = np.inf min_periods = int(np.ceil(pd.Timedelta(window) / pd.Timedelta(delta))) + window = pd.Timedelta(window) to_set = statPass(dataseries, lambda x: varQC(x, max_missing, max_consec_missing), window, thresh, min_periods=min_periods, comparator='<') diff --git a/saqc/lib/tools.py b/saqc/lib/tools.py index 3b78b46c9417a7e2cc91567521577a824d5bfe12..5ac575ebf86e4da934f94e521a4cca731ddc2b95 100644 --- a/saqc/lib/tools.py +++ b/saqc/lib/tools.py @@ -587,9 +587,9 @@ def getAttrOrApply(in_obj, apply_obj, attr_access='__name__', attr_or='apply'): def statPass(datcol: pd.Series, stat: Callable[[np.array, pd.Series], float], - wnsz: FreqString, + wnsz: pd.Timedelta, thresh: PositiveFloat, - sub_wnsz: FreqString = None, + sub_wnsz: pd.Timedelta = None, sub_thresh: PositiveFloat = None, min_periods: PositiveInt = None, comparator: Literal['>', '>=', '==', '<=', '<'] = '<'): @@ -618,7 +618,6 @@ def statPass(datcol: pd.Series, exceeds = exceeding_sub & exceeds to_set = pd.Series(False, index=exceeds.index) - for g in exceeds.groupby(by=exceeds.values): if g[0]: to_set[g[1].index[0] - wnsz:g[1].index[-1]] = True