Boolean for unique value in a column

后端 未结 3 1872
孤街浪徒
孤街浪徒 2020-12-12 02:28

For my dataframe, e.g.

df = pd.DataFrame([1, 3, 7, 1], columns=[\'data\'])

I want to know for each index if the value is unique in the col

3条回答
  •  春和景丽
    2020-12-12 03:03

    from collections import Counter
    
    c = Counter(df.client.to_list())
    
    df["new_col"] = df.client.apply(lambda x:not(c[x] >1) )
    

提交回复
热议问题