Python Program to Count Occurrences of Items in a Python List Using Pandas Library
# Count the Occurrence of an Item in a List Using the panda's library in python import pandas as pd # declaring the list l = [1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5] count = pd.Series(l).value_counts() print("Element Count") print(count)
Output:
Element Count
2 3
4 3
3 2
5 2
1 1
dtype: int64