I have the following Dataframe:
| id1 | result |
|---|---|
| 2 | 0.5 |
| 3 | 1.4 |
| 4 | 1.4 |
| 7 | 3.4 |
| 2 | 1.4 |
I want to check for every row in the column [‘id1’] if the value is unique
The output should be:
False
True
True
True
False
The first and the last are False because id 2 exists twice.
I used this method:
bool = df["id1"].is_unique but that checks if the whole column is unique. I want to check it for each row
>Solution :
df['id1'].map(~(df.groupby('id1').size() > 1))
Output
0 False
1 True
2 True
3 True
4 False
Name: id1, dtype: bool