Value Counts & Unique
Analyze the distribution of values in your data with value_counts() and related methods.
Basic Value Counts
Count occurrences of each unique value:
Loading Pandas Playground...
Normalized Counts (Percentages)
Get proportions instead of counts:
Loading Pandas Playground...
Sorting Options
Control the order of results:
Loading Pandas Playground...
Binning with Value Counts
Count values in ranges:
Loading Pandas Playground...
Unique Values
Get distinct values:
Loading Pandas Playground...
Value Counts Across Multiple Columns
Count combinations:
Loading Pandas Playground...
Including Missing Values
Count NaN as a category:
Loading Pandas Playground...
Exercise: Count Categories
Loading Exercise...
Exercise: Count Unique
Loading Exercise...
Key Points
value_counts()counts unique valuesnormalize=Truefor percentagessort_index()to sort by valuesunique()returns array of unique valuesnunique()counts unique valuesdropna=Falseincludes NaN in counts- Can count combinations of multiple columns
Up next · Lesson 32 of 42
Binning Data
1 min read
31 of 42 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

