Q:

How to update the values of one column's row where another column value matches specific value?

I have a dataframe with four columns id1, id2, config_type, call_frequency, however, the id1 and id2 don't matter much.
I need to replace the value of the call_frequency column with a specific string where a condition matches another column.
Input:

Output:

Basically I need to replace the values in the corresponding call_frequency column when config_types are matched.
{'type2':'string2', 'type3':'string3', 'type4':'string4'}

and the non-matching values should be left untouched.
I tried:
df[df.config_type == 'dict_key', 'column'] = 'dict_value'

But it's giving me error.

TypeError: 'Series' objects are mutable, thus they cannot be hashed

Any idea how to fix this?

A:

use loc.

d = {'type2':'string2', 'type3':'string3', 'type4':'string4'}
for k,v in d.items():
    df.loc[df.config_type==k, 'call_frequency'] = v

