import numpy as np # importing numpy module df["count"] = np.ones(len(df.index), dtype=int) new_df = pd.pivot_table(data=df, index="col", values="count", aggfunc=np.sum) new_df.sort_values(by=["count"],ascending=False).head(1)