pandas count values code example
Example 1: df sort values
>>> df.sort_values(by=['col1'], ascending = False)
col1 col2 col3
0 A 2 0
1 A 1 1
2 B 9 9
5 C 4 3
4 D 7 2
3 NaN 8 4
Example 2: count values pandas
>>> index = pd.Index([3, 1, 2, 3, 4, np.nan])
>>> index.value_counts()
3.0 2
4.0 1
2.0 1
1.0 1
dtype: int64
Example 3: pandas count rows with value
len(df[df['score'] == 1.0])
Example 4: value count in python
col-name.value_count()
Example 5: frequency unique pandas
df.stack().value_counts()
Example 6: pandas count values by column
df = pd.DataFrame({'a':list('abssbab')})
df.groupby('a').count()