From b59a23b85fefbf1802ebf94d50e87f9e8249097f Mon Sep 17 00:00:00 2001 From: Thomas K Stover Date: Mon, 27 Oct 2025 15:44:45 +0000 Subject: [PATCH 1/2] Added handling to drop duplicates from extract output --- wrangles/recipe_wrangles/extract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrangles/recipe_wrangles/extract.py b/wrangles/recipe_wrangles/extract.py index fdb85e76b..d0052cc60 100644 --- a/wrangles/recipe_wrangles/extract.py +++ b/wrangles/recipe_wrangles/extract.py @@ -631,7 +631,7 @@ def custom( ) # Concatenate the results into a single column - df[output] = [_format.concatenate([x for x in row if x], ' ') for row in df_temp.values.tolist()] + df[output] = [list(dict.fromkeys(_format.concatenate([x for x in row if x], ' '))) for row in df_temp.values.tolist()] else: # Iterate through the inputs, outputs and model_ids From 39da19d438a9d0d2e79a959a7db22b8c3165e50e Mon Sep 17 00:00:00 2001 From: Thomas K Stover Date: Mon, 27 Oct 2025 15:45:12 +0000 Subject: [PATCH 2/2] Added test for multiple input columns with the same match --- tests/recipes/wrangles/test_extract.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/recipes/wrangles/test_extract.py b/tests/recipes/wrangles/test_extract.py index 523a74b8e..94d4df8a2 100644 --- a/tests/recipes/wrangles/test_extract.py +++ b/tests/recipes/wrangles/test_extract.py @@ -1797,6 +1797,30 @@ def test_extract_regex_first(self): assert df['Output'][0] == ['cotton', 'This is a match'] assert df['Output'][1] == ['red', 'This is a match'] + def test_extract_custom_multi_match(self): + """ + Test the output with multiple input columns with the same matches + """ + df = wrangles.recipe.run( + """ + wrangles: + - extract.custom: + input: + - Col1 + - Col2 + - Col3 + output: Output + model_id: 1eddb7e8-1b2b-4a52 + """, + dataframe=pd.DataFrame({ + 'Col1': ['Charizard is a dragon.'], + 'Col2': ['Charizard is a pokemon.'], + 'Col3': ['Something else about charizard.'] + }) + ) + assert df.iloc[0]['Output'] == ['Charizard'] + + class TestExtractRegex: """