Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
35
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
bc70cf14
Commit
bc70cf14
authored
5 years ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: plotting failed for flagger with _flags attribute of type
pd.DataFrame
parent
ca5b36e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
saqc/__main__.py
+16
-3
16 additions, 3 deletions
saqc/__main__.py
saqc/flagger/dmpflagger.py
+6
-4
6 additions, 4 deletions
saqc/flagger/dmpflagger.py
saqc/lib/plotting.py
+2
-0
2 additions, 0 deletions
saqc/lib/plotting.py
with
24 additions
and
7 deletions
saqc/__main__.py
+
16
−
3
View file @
bc70cf14
...
...
@@ -8,11 +8,13 @@ import pandas as pd
from
saqc.core
import
run
from
saqc.flagger
import
CategoricalFlagger
from
saqc.flagger.dmpflagger
import
DmpFlagger
,
FlagFields
FLAGGERS
=
{
"
numeric
"
:
CategoricalFlagger
([
-
1
,
0
,
1
]),
"
category
"
:
CategoricalFlagger
([
"
NIL
"
,
"
OK
"
,
"
BAD
"
]),
"
dmp
"
:
DmpFlagger
()
}
...
...
@@ -44,9 +46,20 @@ def main(config, data, flagger, outfile, nodata, fail):
if
outfile
:
flags
=
flagger_result
.
getFlags
()
flags_out
=
flags
.
where
((
flags
.
isnull
()
|
flagger_result
.
isFlagged
()),
flagger_result
.
GOOD
)
cols_out
=
sum
([[
c
,
c
+
"
_flags
"
]
for
c
in
flags_out
],
[])
data_out
=
data_result
.
join
(
flags_out
,
rsuffix
=
"
_flags
"
)
data_out
[
cols_out
].
to_csv
(
outfile
,
header
=
True
,
index
=
True
)
if
isinstance
(
flagger_result
,
DmpFlagger
):
flags
=
flagger_result
.
_flags
flags
.
loc
[
flags_out
.
index
,
(
slice
(
None
),
FlagFields
.
FLAG
)]
=
flags_out
.
values
flags_out
=
flags
if
not
isinstance
(
flags_out
.
columns
,
pd
.
MultiIndex
):
flags_out
.
columns
=
pd
.
MultiIndex
.
from_product
([
flags
.
columns
,
[
"
flag
"
]])
data_result
.
columns
=
pd
.
MultiIndex
.
from_product
([
data_result
.
columns
,
[
"
data
"
]])
# flags_out.columns = flags_out.columns.map("_".join)
data_out
=
data_result
.
join
(
flags_out
)
data_out
.
sort_index
(
axis
=
"
columns
"
).
to_csv
(
outfile
,
header
=
True
,
index
=
True
,
na_rep
=
""
)
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
saqc/flagger/dmpflagger.py
+
6
−
4
View file @
bc70cf14
...
...
@@ -49,12 +49,14 @@ class DmpFlagger(CategoricalFlagger):
"""
if
data
is
not
None
:
flags
=
pd
.
DataFrame
(
data
=
self
.
UNFLAGGED
,
columns
=
self
.
_getColumnIndex
(
data
.
columns
),
index
=
data
.
index
,)
flags
=
pd
.
DataFrame
(
data
=
""
,
columns
=
self
.
_getColumnIndex
(
data
.
columns
),
index
=
data
.
index
,)
flags
.
loc
[:,
self
.
_getColumnIndex
(
data
.
columns
,
[
FlagFields
.
FLAG
])]
=
self
.
UNFLAGGED
elif
flags
is
not
None
:
if
not
isinstance
(
flags
.
columns
,
pd
.
MultiIndex
):
flags
=
flags
.
T
.
set_index
(
keys
=
self
.
_getColumnIndex
(
flags
.
columns
,
[
FlagFields
.
FLAG
])).
T
.
reindex
(
columns
=
self
.
_getColumnIndex
(
flags
.
columns
)
)
cols
=
flags
.
columns
flags
=
flags
.
copy
()
flags
.
columns
=
self
.
_getColumnIndex
(
cols
,
[
FlagFields
.
FLAG
])
flags
=
flags
.
reindex
(
columns
=
self
.
_getColumnIndex
(
cols
),
fill_value
=
""
)
else
:
raise
TypeError
(
"
either
'
data
'
or
'
flags
'
are required
"
)
...
...
This diff is collapsed.
Click to expand it.
saqc/lib/plotting.py
+
2
−
0
View file @
bc70cf14
...
...
@@ -65,6 +65,8 @@ def plotHook(
return
mask
=
flags_old
!=
flags_new
if
isinstance
(
mask
,
pd
.
DataFrame
):
mask
=
mask
.
any
(
axis
=
1
)
__plotvars
.
append
(
varname
)
_plot
(
data
,
flagger_new
,
mask
,
varname
,
title
=
flag_test
,
plot_nans
=
plot_nans
)
...
...
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