Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
measprocess
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lukas Eller
measprocess
Commits
6f9205a7
Commit
6f9205a7
authored
Mar 26, 2021
by
Lukas Eller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Linking DataFrames Progress Bar added
parent
59379300
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
preprocess.py
measprocess/preprocess.py
+3
-2
setup.py
setup.py
+1
-1
No files found.
measprocess/preprocess.py
View file @
6f9205a7
...
...
@@ -6,6 +6,7 @@ from tqdm import tqdm
def
link_dataframes
(
A
:
pd
.
DataFrame
,
B
:
pd
.
DataFrame
,
ref_col
:
str
,
metric
=
None
,
verbose
=
True
)
->
(
pd
.
DataFrame
,
np
.
ndarray
):
'''
Merge two DataFrames A and B according to the reference colum based on minimum metric.
Note that the final dataframe will include duplicate entries from B, while entries from A will be unique
:param ref_col: Reference Column to merge dataframes. Has to exist in both frames
:param metric: Metric used to determine matches in ref_col. Default lambda a, b: (a - b).abs()
...
...
@@ -23,7 +24,7 @@ def link_dataframes(A: pd.DataFrame, B: pd.DataFrame, ref_col: str, metric=None,
metric
=
lambda
a
,
b
:
(
a
-
b
)
.
abs
()
indices
,
deviations
=
[],
[]
for
_
,
element
in
tqdm
(
A
.
iterrows
(),
total
=
A
.
shape
[
0
],
disable
=
(
not
verbose
)):
for
_
,
element
in
tqdm
(
A
.
iterrows
(),
total
=
A
.
shape
[
0
],
disable
=
(
not
verbose
)
,
desc
=
"Linking Dataframes"
):
distances
=
metric
(
element
[
ref_col
],
B
[
ref_col
]
...
...
@@ -37,7 +38,7 @@ def link_dataframes(A: pd.DataFrame, B: pd.DataFrame, ref_col: str, metric=None,
)
B_with_duplicates
=
pd
.
DataFrame
(
(
B
.
iloc
[
index
]
for
index
in
indices
)
tqdm
((
B
.
iloc
[
index
]
for
index
in
indices
),
total
=
len
(
indices
),
disable
=
(
not
verbose
),
desc
=
"Building combined DataFrame"
)
)
B_with_duplicates
.
columns
=
B
.
columns
...
...
setup.py
View file @
6f9205a7
...
...
@@ -10,7 +10,7 @@ README = (HERE / "README.md").read_text()
# This call to setup() does all the work
setup
(
name
=
"measprocess"
,
version
=
"0.5.
9
"
,
version
=
"0.5.
10
"
,
description
=
"Collection of measurement processing tools"
,
long_description
=
README
,
long_description_content_type
=
"text/markdown"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment