I am new to scipy. I am trying to get maximum occurred value of string column.
Here is my Code:
import pandas as pd
import numpy as np
from scipy.stats import mode
print ("Maximum Occurence of Store Owner " + str(mode(df_units["StoreOwner"], nan_policy='omit').mode[0]))
Here is first few rows of Store Owner Data:
0 Muhammed MacIntyre
1 Barry French
2 Barry French
3 Clay Rozendal
4 Carlos Soltero
In above code I am trying to get maximum occured store Owner value in from the datframe. But it is returning all the values as it is.
You could do:
pdf = pd.DataFrame(dict(A=['a', 'a', 'b', 'c', 'd']))
pdf.A.value_counts().idxmax()
This gives you the value that occured most frequently in the column A
of the dataframe pdf
.