Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 917 Bytes

using_value_count.md

File metadata and controls

40 lines (31 loc) · 917 Bytes

value_count() and it's greatness

There is a super simple way to count all your results, in a row for example using value_count() - "Return a Series containing counts of unique rows in the DataFrame."

Lets take this Series:

df['Hobbyist']

The above takes the Hobbyist columne from the Stackoverflow dev survey. The output is below:

0        Yes
1         No
2        Yes
3         No
4        Yes
        ... 
88878    Yes
88879     No
88880     No
88881     No
88882    Yes
Name: Hobbyist, Length: 88883, dtype: object

This is now a series and it has 88,882 entries, couting those could require a loop or a function, with pandas it's super simple.

df['Hobbyist'].value_counts()
Yes    71257
No     17626
Name: Hobbyist, dtype: int64

Easy pease!