Skip to content
Snippets Groups Projects
Commit 3abef7e6 authored by David Schäfer's avatar David Schäfer
Browse files

New config function cov

parent e6249908
No related branches found
No related tags found
3 merge requests!685Release 2.4,!684Release 2.4,!676New config function cov
......@@ -12,11 +12,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
- Methods `logicalAnd` and `logicalOr`
- `Flags` supports slicing and column selection with `list` or a `pd.Index`
- Expose the `History` via `SaQC._history_`
- Config function `cov` (coefficient of variation)
### Changed
- Deprecate `interpolate`, `linear` and `shift` in favor of `align`
- Deprecate `roll` in favor of `rolling`
- Rename `interplateInvalid` to `interpolate`
- Rename `interpolateIndex` to `align`
- Rename `interpolateIndex` to `align`
- Deprecate `flagMVScore` parameters: `partition_min` in favor of `window`, `partition_min` in favor of `min_periods`, `min_periods` in favor of `min_periods_r`
### Removed
- Parameter `limit` from `align`
......@@ -35,9 +36,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
- python 3.11 support
- added Local Outlier Factor functionality
### Changed
- Remove all flag value restrictions from the default flagging scheme `FloatTranslator`
- Renamed `TranslationScheme.forward` to `TranslationScheme.toInternal`
- Renamed `TranslationScheme.backward` to `TranslationScheme.toExternal`
- Remove all flag value restrictions from the default flagging scheme `FloatTranslator`
- Renamed `TranslationScheme.forward` to `TranslationScheme.toInternal`
- Renamed `TranslationScheme.backward` to `TranslationScheme.toExternal`
- Changed default value of the parameter `limit` for `SaQC.interpolateIndex` and `SaQC.interpolateInvalid` to ``None``
- Changed default value of the parameter ``overwrite`` for ``concatFlags`` to ``False``
- Deprecate ``transferFlags`` in favor of ``concatFlags``
......@@ -72,7 +73,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
### Removed
- `closed` keyword in `flagJumps`
### Fixed
- fixed undesired behavior in `flagIsolated` for not harmonized data
- fixed undesired behavior in `flagIsolated` for not harmonized data
- fixed failing translation of `dfilter`-defaults
- fixed unbound recursion error when interpolating with order-independent methods in `interpolateIndex`
- fixed not working min_periods condition if `window=None` in `assignZScore`
......
......@@ -7,6 +7,7 @@
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import scipy.stats as st
import saqc.lib.ts_operators as ts_ops
......@@ -21,6 +22,14 @@ def zscore(obj):
return st.zscore(obj, nan_policy="omit")
def cv(series: pd.Series) -> pd.Series:
"""
calculates the coefficient of variation on a min-max scaled time series
"""
series_ = (series - series.min()) / (series.max() - series.min())
return series_.std() / series_.mean()
ENVIRONMENT = {
# Infinity constant
"inf": np.inf,
......@@ -50,6 +59,8 @@ ENVIRONMENT = {
"std": np.nanstd,
# Variance. Ignores NaN.
"var": np.nanvar,
# Coefficient of variation.
"cv": cv,
# Median. Ignores NaN.
"median": np.nanmedian,
# Count Number of values. Ignores NaNs.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment