find how many things appear in dataframe python code example
Example 1: pd count how many item occurs in another column
df['Counts'] = df.groupby(['Color'])['Value'].transform('count')
Example 2: pandas count
>>> df.set_index(["Person", "Single"]).count(level="Person")
Age
Person
John 2
Lewis 1
Myla 1