What does df["city"].value_counts() return in pandas?
Correct answer
C. Counts per distinct value, sorted most frequent first
13 views
C. Counts per distinct value, sorted most frequent first
13 views
value_counts produces a Series whose index holds the distinct values and whose values hold their frequencies, ordered from most to least common by default. Pass normalize=True to get proportions instead of raw counts, and dropna=False to include missing values, which are excluded otherwise. nunique answers a different question by returning just the number of distinct values.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is C? Ask here and get an explanation.