Skip to content
Exercises · Q7

Q.What do you understand by the term MODE? Name the function which is used to calculate it.

Puducherry TnboardTextbookSubjective· 2mImportance★★★★★
51% · 27/53 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

mode() returns the value that occurs most often in a column. Applied to this chapter's own Hindi marks, df['Hindi'].mode() returns 24 -- three students scored 24 in Hindi, more than any other single mark.

What Mode Measures

Mean, median and mode are all "typical value" summaries, but they answer different questions. The mean averages every value; the median finds the middle value once sorted; the mode simply counts occurrences and reports whichever value appears most often. It's the only one of the three that makes sense for categorical data too (e.g. the most common blood group in a class) -- you can't meaningfully "average" categories, but you can count which one is most frequent.

A dataset can have one mode (unimodal), several tied modes (multimodal), or -- if every value is unique -- no mode at all.

The Chapter's Own Example

Section 3.2.7 of this chapter runs mode() directly on the case-study DataFrame's Hindi column:

print(df['Hindi'])

Output:

0     20
1     22
2     24
3     24
4     25
5     23
6     15
7     17
8     21
9     22
10    24
11    25
Name: Hindi, dtype: int64
print(df['Hindi'].mode())

Output:

0    24
dtype: int64

Counting the values by hand confirms it: 24 appears three times (indices 2, 3, 10), 25 and 22 each appear twice, and every other mark (20, 23, 15, 17, 21) appears once. No other value ties or beats 24's count of three, so mode() correctly returns a single-element Series containing 24.

Tip

mode() always returns a Series, never a bare scalar -- even when there is exactly one mode, as here. That's because pandas can't know in advance whether a column is multimodal; if two values were tied for most frequent, mode() would return BOTH in the Series. To pull out just the first value, use df['Hindi'].mode()[0].

The chapter leaves a natural follow-up as Activity 3.3: "Calculate the mode of marks scored in Maths" -- solved the exact same way, just swapping the column: df['Maths'].mode().

The Function …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.