-1
from numpy import genfromtxt
Birds = genfromtxt('DataLot.csv', dtype=int, delimiter=',')
import statistics
from collections import Counter
columnaA = Birds[:,1]
print(Counter(columnaA).most_common(6))
print("The multimode of list is : ", statistics.multimode(columnaA))
print("The mode of list is : ", statistics.mode(columnaA))

This gives me this result:

[(9, 93), (10, 90), (8, 89), (13, 83), (11, 83), (5, 80)]
The multimode of list is :  [9]
The mode of list is :  9

Why can't I get a Multimode list? If you see only shows one result for Multimode.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578

1 Answers1

1

This is right. Multimode shows only one result, because there is only one result to show.

The code below:

import statistics
from collections import Counter
columnaA = [1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,5,5,6,6,7,7,8,8,9,9]
print(Counter(columnaA).most_common(6))
print("The multimode of list is : ", statistics.multimode(columnaA))
print("The mode of list is      : ", statistics.mode(columnaA))

prints:

[(1, 4), (2, 4), (3, 4), (4, 3), (5, 2), (6, 2)]
The multimode of list is :  [1, 2, 3]
The mode of list is      :  1

And as you can see from the printout of Counter there are three most frequent values, so the multimode gives a list with three elements.

In case of your data there are no other items occurring the same number of times as the most frequent one, so there is only one value in the list.

      v-- there is only one item with count 93 and this is the [9]
[(9, 93), (10, 90), (8, 89), (13, 83), (11, 83), (5, 80)]
Claudio
  • 7,474
  • 3
  • 18
  • 48
  • ok, that´s it, better use collectiosn to handle mode analisys – user3177225 Sep 25 '22 at 18:31
  • You need to accept the answer if it solved your problem. That's the way stackoverflow works ... – Claudio Sep 25 '22 at 18:39
  • @user3177225 *"better use collectiosn to handle mode analisys"* - Looks like you don't really want to do mode analysis then. As shown, the `statistics` functions work correctly here, you just have some mistaken expectation. – Kelly Bundy Sep 25 '22 at 18:54