What I am trying to do is to replace a value based on the row value. But I couldn't figure out how to do it. Code is like below.
def get_new_value_b(db, value_a):
# Take a value_a and return value_b
...
a_list = ["a", "b", "c"]
df.loc[df["value_a"] in a_list, "value_b"] = get_new_value_b(db,df["value_a"])
What I want to do here is to replace a value_a if the value exists in a_list
But on the condition, there is an error.
Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
Also if the condition is True, I want to get a new value by passing the value_a to a function (get_new_value_b)
but seems like it also refers to the entire column, not the specific value in the row.
How can I fix this issue?