Commit 6f9205a7 authored by Lukas Eller's avatar Lukas Eller

Linking DataFrames Progress Bar added

parent 59379300
......@@ -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
......
......@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment