Skip to content

Commit 76ea3f6

Browse files
committed
Fix the percentage_of_reoccurring_values_to_all_values calculator to cope with empty lists or lists with no repeatence properly
1 parent c98ee88 commit 76ea3f6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tsfresh/feature_extraction/feature_calculators.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,17 @@ def percentage_of_reoccurring_values_to_all_values(x):
780780
"""
781781
if not isinstance(x, pd.Series):
782782
x = pd.Series(x)
783+
783784
if x.size == 0:
784785
return np.nan
785786

786787
value_counts = x.value_counts()
787-
return value_counts[value_counts > 1].sum() / x.size
788+
reoccuring_values = value_counts[value_counts > 1].sum()
789+
790+
if np.isnan(reoccuring_values):
791+
return 0
792+
793+
return reoccuring_values / x.size
788794

789795

790796
@set_property("fctype", "simple")

0 commit comments

Comments
 (0)