python count variable and put the count in a column of data frame code 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')