Skip to content

Commit

Permalink
Check And Remove Duplicates in chosen_metrics (#202)
Browse files Browse the repository at this point in the history
* Check if user provides duplicate metrics and remove

* black
  • Loading branch information
michaelmckinsey1 authored Oct 25, 2024
1 parent 23a351c commit 0b77659
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions thicket/thicket.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: MIT

import collections
import copy
import os
import pickle
Expand Down Expand Up @@ -576,6 +577,17 @@ def _rep_agg_func(col):
else:
return col[0]

# Remove duplicate metrics in chosen_metrics if the user provided duplicates
unique_metrics = list(set(chosen_metrics))
if len(unique_metrics) != len(chosen_metrics):
dupe_mets = [
met
for met, count in collections.Counter(chosen_metrics).items()
if count > 1
]
warnings.warn(f"Removing duplicate metrics in chosen_metrics: {dupe_mets}")
chosen_metrics = unique_metrics

# Check if chosen_metrics are in the dataframe
dupe_cols = [col for col in chosen_metrics if col in self.dataframe.columns]
if overwrite:
Expand Down

0 comments on commit 0b77659

Please sign in to comment.