From 9b71b08a20902932a2275fc8a6028a7131ff1301 Mon Sep 17 00:00:00 2001 From: sallybg <136365880+sallybg@users.noreply.github.com> Date: Mon, 22 Apr 2024 12:10:56 -0700 Subject: [PATCH] parse-kp2023: refactor column_set_is_binary() Co-authored-by: Benjamin Capodanno <31941502+bencap@users.noreply.github.com> --- lib/seattleflu/id3c/cli/command/clinical.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/seattleflu/id3c/cli/command/clinical.py b/lib/seattleflu/id3c/cli/command/clinical.py index 43079c12..34f2eca6 100644 --- a/lib/seattleflu/id3c/cli/command/clinical.py +++ b/lib/seattleflu/id3c/cli/command/clinical.py @@ -1107,11 +1107,7 @@ def column_set_is_binary(df: pd.DataFrame, prefix:str) -> bool: otherwise returns False. """ cols = [c for c in df.columns if c.startswith(prefix)] - for c in cols: - if not np.isin(df[c].dropna().unique(), [0, 1]).all(): - return False - - return True + return all([np.isin(df[c].dropna().unique(), [0, 1]).all() for c in cols]) def map_icd10_codes(df: pd.DataFrame, sample_stream: str) -> pd.DataFrame: