+ 1

i need function Finding mode for sequencing.

i need function which Finding mode for sequencing and If you have two or more modes of mode. Return all And if you do not have it, None. thanks advanced

2nd Jun 2018, 7:22 AM
ieghdvnj
1 Réponse
+ 1
The typical answer would be to use standard implementations for mode() such as in Numpy. However, the non-standard handling you have requested (mainly multiples) can be accomplished without external imports. def mode(array): if not array: return None items = set(array) most = max(map(array.count, items)) if most < 2: return None modes = list(filter(lambda x: array.count(x) == most, items)) return modes[0] if len(modes) == 1 else modes
5th Jun 2018, 3:36 AM
1_coder