Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
36
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rdm-software
SaQC
Commits
0b414cb2
Commit
0b414cb2
authored
4 years ago
by
Peter Lünenschloß
Browse files
Options
Downloads
Patches
Plain Diff
added indexer for forward facing windows to custom rllling mechanics
parent
5970ee03
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!193
Release 1.4
,
!188
Release 1.4
,
!138
WIP: Detect and reset offset
Pipeline
#8181
passed with stage
in 6 minutes and 19 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/lib/tools.py
+18
-3
18 additions, 3 deletions
saqc/lib/tools.py
with
18 additions
and
3 deletions
saqc/lib/tools.py
+
18
−
3
View file @
0b414cb2
...
...
@@ -361,15 +361,25 @@ def mutateIndex(index, old_name, new_name):
class
FreqIndexer
(
BaseIndexer
):
# indexer class capable of generating indices for frequency determined windows,
# arbitrary window skips and forward facing windows (meant to be used by pd.rolling)
def
get_window_bounds
(
self
,
num_values
,
min_periods
,
center
,
closed
):
i_dir
=
1
if
self
.
forward
:
i_dir
=
-
1
start
,
end
=
calculate_variable_window_bounds
(
num_values
,
self
.
window_size
,
min_periods
,
center
,
closed
,
self
.
index_array
)
self
.
index_array
[::
i_dir
])
if
self
.
forward
:
start
,
end
=
(
num_values
-
end
)[::
-
1
],
(
num_values
-
start
)[::
-
1
]
end
[
~
self
.
win_points
]
=
0
start
[
~
self
.
win_points
]
=
0
return
start
,
end
class
PeriodsIndexer
(
BaseIndexer
):
# indexer class capable of generating periods-number determined windows and
# arbitrary window skips (meant to be used by pd.rolling)
def
get_window_bounds
(
self
,
num_values
,
min_periods
,
center
,
closed
):
start_s
=
np
.
zeros
(
self
.
window_size
,
dtype
=
"
int64
"
)
start_e
=
(
...
...
@@ -387,7 +397,8 @@ class PeriodsIndexer(BaseIndexer):
return
start
,
end
def
customRolling
(
to_roll
,
winsz
,
func
,
roll_mask
,
min_periods
=
1
,
center
=
False
,
closed
=
None
,
raw
=
True
,
engine
=
None
):
def
customRolling
(
to_roll
,
winsz
,
func
,
roll_mask
,
min_periods
=
1
,
center
=
False
,
closed
=
None
,
raw
=
True
,
engine
=
None
,
forward
=
False
):
"""
A wrapper around pandas.rolling.apply(), that allows for skipping func application on
arbitrary selections of windows.
...
...
@@ -418,6 +429,9 @@ def customRolling(to_roll, winsz, func, roll_mask, min_periods=1, center=False,
Gets passed on to the raw parameter of pandas.Rolling.apply.
engine : {None,
'
numba
'
}, default None
Gets passed on to the engine parameter of pandas.Rolling.apply.
forward : bool, default False
If true, roll with forward facing windows. (not yet implemented for
integer defined windows.)
Returns
-------
...
...
@@ -433,7 +447,8 @@ def customRolling(to_roll, winsz, func, roll_mask, min_periods=1, center=False,
win_points
=
roll_mask
,
index_array
=
to_roll
.
index
.
to_numpy
(
int
),
center
=
center
,
closed
=
closed
)
closed
=
closed
,
forward
=
forward
)
elif
isinstance
(
winsz
,
int
):
indexer
=
PeriodsIndexer
(
window_size
=
winsz
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment