Calculate the frequency of each value of a series using Pandas

In this python pandas program, we will calculate the frequency of each value of a series using pandas.

Steps to solve the program
  1. Import pandas library as pd.
  2. Create a series using pd.Series().
  3. Calculate the frequency of each value of a series using df.value_counts().
  4. Print the output.
				
					import pandas as pd
df = pd.Series([3,0,3,2,2,0,3,3,2])
print(df)
result = df.value_counts()
print(result)
				
			

Output :

				
					0    3
1    0
2    3
3    2
4    2
5    0
6    3
7    3
8    2
dtype: int64
3    4
2    3
0    2
dtype: int64
				
			

calculate the minimum value from a series

extract items at given positions of a series

Leave a Comment