I'm fully aware of Counter.most_commen
but this feels like cheating to me. I wanna do it myself.
Here is my function.
def mode(self):
unq = []
m = 0
for i in self.arrData:
if i not in unq:
unq.append(i)
for i in unq:
count = self.arrData.count(i)
if count > m:
m = i
return m
When using the test data:
34.9, 35.0, 35.2, 35.4, 35.8, 36.0, 36.1, 36.2, 36.3, 36.4, 36.4, 36.4, 36.4, 36.5, 36.6, 36.7, 36.7, 36.8, 36.8, 37.0, 37.2, 37.3, 37.9, 38.2, 38.3, 38.3, 38.4, 38.8, 39.0, 39.4
I keep getting the fist element as m.