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
204de095
Commit
204de095
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
fixed count - monkey-patch roller - see comment
parent
e6f927ed
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
,
!166
Rolling rework fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/lib/rolling.py
+21
-1
21 additions, 1 deletion
saqc/lib/rolling.py
with
21 additions
and
1 deletion
saqc/lib/rolling.py
+
21
−
1
View file @
204de095
...
...
@@ -371,4 +371,24 @@ def customRoller(obj, window, min_periods=None, # aka minimum non-nan values
# is, because we cannot throw out values by ourself in the indexer, because min_periods also evaluates NA values
# in its count and we have no control over the actual values, just their indexes.
theirs
.
update
(
min_periods
=
x
.
min_periods
)
return
obj
.
rolling
(
indexer
,
center
=
None
,
**
theirs
)
roller
=
obj
.
rolling
(
indexer
,
center
=
None
,
**
theirs
)
# ----- count hack -------
# Unfortunately pandas calls count differently if a BaseIndexer
# instance is given. IMO, the intention behind this is to call
# count different for dt-like windows, but if a user pass a own
# indexer we also end up in this case /:
# The only possibility is to monkey-patch pandas...
def
new_count
():
self
=
roller
if
not
x
.
is_freq_type
:
result
=
obj
.
notna
().
astype
(
int
)
theirs
.
update
(
min_periods
=
min_periods
or
0
)
return
customRoller
(
result
,
window
,
**
theirs
,
**
ours
).
sum
()
return
self
.
_old_count
()
roller
.
_old_count
=
roller
.
count
roller
.
count
=
new_count
# ----- count hack -------
return
roller
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