count the variable in a column python example
Example: python count variable and put the count in a column of data frame
df['freq'] = df.groupby('myvar')['myvar'].transform('count')
df['freq'] = df.groupby('myvar')['myvar'].transform('count')