From d2758eef46b2ddc6f3b4b5b0d138e0df34ccb89c Mon Sep 17 00:00:00 2001 From: Primoz Date: Wed, 6 Jul 2022 07:36:35 +0000 Subject: [PATCH] Set not NaN sum insted of 0 sum for HRV features windows. --- src/features/cr_features_helper_methods.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/features/cr_features_helper_methods.py b/src/features/cr_features_helper_methods.py index cc3aa216..9e96c497 100644 --- a/src/features/cr_features_helper_methods.py +++ b/src/features/cr_features_helper_methods.py @@ -1,4 +1,5 @@ import pandas as pd +import numpy as np import math as m import sys @@ -39,7 +40,7 @@ def extract_second_order_features(intraday_features, so_features_names, prefix=" # numWindowsNonZero specialized for BVP and IBI sensors if "hrv_num_windows_non_nan" in so_features_names and prefix+"meanHr" in intraday_features.columns: - so_features[prefix+"SO_numWindowsNonNaN"] = intraday_features.groupby(groupby_cols)[prefix+"meanHr"].apply(lambda x: (x!=0).sum()) + so_features[prefix+"SO_numWindowsNonNaN"] = intraday_features.groupby(groupby_cols)[prefix+"meanHr"].apply(lambda x: (~np.isnan(x)).sum()) so_features.reset_index(inplace=True)