From fea187f8e7a71a210907a97ac04174ecc2449c0d Mon Sep 17 00:00:00 2001 From: Peter Luenenschloss <peter.luenenschloss@ufz.de> Date: Mon, 15 Jul 2019 16:05:33 +0200 Subject: [PATCH] added offset2seconds transformation to tools.py --- saqc/lib/tools.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/saqc/lib/tools.py b/saqc/lib/tools.py index f908ba434..464737a61 100644 --- a/saqc/lib/tools.py +++ b/saqc/lib/tools.py @@ -120,6 +120,7 @@ def estimateSamplingRate(index): # harmonized with skips) return pd.tseries.frequencies.to_offset(str(int(hist[1][:-1][hist[0] > 0].min())) + 's') + def retrieveTrustworthyOriginal(dataseries, dataflags=None, flagger=None): """Columns of data passed to the saqc runner may not be sampled to its original sampling rate - thus differenciating between missng value - nans und fillvalue nans is impossible. This function evaluates flags for a @@ -148,3 +149,12 @@ def retrieveTrustworthyOriginal(dataseries, dataflags=None, flagger=None): data_rate = estimateSamplingRate(dataseries.index) # resample dataseries to its original sampling rate (now certain, to only get nans, indeed denoting "missing" data) return dataseries.resample(data_rate).asfreq(), data_rate + + +def offset2seconds(offset): + """Function returns total seconds upon "offset like input + + :param offset: offset string or pandas offset object. + """ + + return pd.Timedelta.total_seconds(pd.Timedelta(offset)) -- GitLab