I have a data frame and I would like to know how many times a given column has the most frequent value.
I try to do it in the following way:
items_co
The NaN values are omitted for calculating frequencies. Please check your code functionality here But you can use the below code for same functionality.
**>> Code:**
# Importing required module
from collections import Counter
# Creating a dataframe
df = pd.DataFrame({ 'A':["jan","jan","jan","mar","mar","feb","jan","dec",
"mar","jan","dec"] })
# Creating a counter object
count = Counter(df['A'])
# Calling a method of Counter object(count)
count.most_common(3)
**>> Output:**
[('jan', 5), ('mar', 3), ('dec', 2)]