Skip to content
Snippets Groups Projects
Commit da54613c authored by Peter Lünenschloß's avatar Peter Lünenschloß
Browse files

exposed target in rolling func

parent 2a9f61ed
No related branches found
No related tags found
1 merge request!850Horizontal axis rolling
Pipeline #207029 failed with stages
in 2 minutes and 18 seconds
This commit is part of merge request !850. Comments created here will be created in the context of that merge request.
......@@ -34,6 +34,7 @@ class RollingMixin:
self: "SaQC",
field: str,
window: str | int,
target: str = None,
func: Callable[[pd.Series], np.ndarray] | str = "mean",
min_periods: int = 0,
center: bool = True,
......@@ -55,6 +56,11 @@ class RollingMixin:
sampled timeseries, the period number will be casted down to an odd number if
``center=True``.
target :
Field to write the result of the rolling calculation to. Will be generated if not existant.
If not given, `field` will be overwritten with the calculations result.
If multiple fields are given, `target` must be assigned.
func : default mean
Function to roll with.
......@@ -66,9 +72,9 @@ class RollingMixin:
"""
# HINT: checking in _roll
if len(field) == 1:
if "target" in kwargs:
self = self.copyField(field[0], target=kwargs["target"])
field = kwargs["target"]
if target:
self = self.copyField(field[0], target=target)
field = target
self._data, self._flags = _roll(
data=self._data,
......@@ -81,23 +87,23 @@ class RollingMixin:
**kwargs,
)
else:
if not "target" in kwargs:
if not target:
raise ValueError(
"Target has to be assigned for cross statistics calculations."
)
for t in kwargs["target"]:
if t not in self._data.columns:
self[t] = saqc.SaQC(
pd.Series(
np.nan, index=self.data[field].to_pandas().index, name=t
)
if target not in self._data.columns:
self[target] = saqc.SaQC(
pd.Series(
np.nan, index=self.data[field].to_pandas().index, name=target
)
)
self._data, self._flags = _hroll(
data=self._data,
field=field,
flags=self._flags,
target=kwargs["target"],
target=target,
window=window,
func=func,
min_periods=min_periods,
......
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