I have been trying for a while but keep getting following error. I have the following df
object article
aa 123
aa 124
ab 123
ab 123
ac 123
ac 125
ad 123
ad 125
what I want is:
object Count_unique_arcicle
aa 2
ab 1
ac 2
ad 2
what i get is:
object Count_unique_arcicle
aa nan
ab nan
ac nan
ad nan
Ive tried the following with no luck.
df= sql_query[['object ', 'article']]
df['Count_unique_arcicle'] = df['object'].groupby(df['object ']).transform('count')
df['Count_unique_arcicle'] = df['object'].groupby(df['object']).nunique()```