Given this list
a = [a,d]
Give a dataset as such
id | type |
---|---|
a | cat |
b | fish |
c | dog |
d | cat |
If the id items of the dataset are found in the list a, then I need to change the related type item, if not leave the same type item
End result
id | type |
---|---|
a | bird |
b | fish |
c | dog |
d | bird |
This code is not working
df["type"] = np.where(df["id"].isin(a), df["type"].replace("bird"), df["type"])