Home > Blockchain >  Can't find the mode for multiple common values
Can't find the mode for multiple common values

Time:06-12

I want to find the mode in a large dataset. When I have multiple common values I still want to know what they are instead I get output such as:

'no unique mode; found %d equally common values' % len(table)

StatisticsError: no unique mode; found 24 equally common values

I have tried:

import pandas as pd
import statistics 

df=pd.read_csv('Area(1).txt',delimiter='\t')
df4=df.iloc[0:528,5]
print(df4)

statistics.mode(df4)

But given that the dataset is quite big with many common values, I get the StatisticsError I mentioned earlier. Since statistics.mode is not giving me the required output, I have also tried statistics.multimode() but for some reason this command does not work/isn't recognizable at all.

CodePudding user response:

You may just use mode from pandas

df4.mode()
  • Related