You use value_counts()
function in the wrong way:
import pandas as pd
index = pd.Index(['c#', 'java', 'c#', 'c#', 'java'])
index.value_counts()
# Output:
# c# 3
# java 2
# dtype: int64
index.value_counts('c#') # This is wrong and misleading
# Output:
# c# 0.6
# java 0.4
# dtype: float64
index.value_counts()['c#']
# Output:
3
Check the value_counts documentation to understand this behaviour:
Index.value_counts(normalize=False, sort=True, ascending=False, bins=None, dropna=True)[source]
The first positional argument is interpreted as a boolean, and specifies whether to normalize the output.