I've done already lot of searching but none of the tips I found was the expected answer.
Here is my df structure.
| year | name | value | 
|---|---|---|
| 2000 | Mick | a | 
| 2001 | Mick | a | 
| 2002 | Mick | ab | 
| 2003 | Mick | b | 
| 2000 | Jane | c | 
| 2001 | Jane | c | 
| 2002 | Jane | cd | 
| 2003 | Jane | d | 
And a list of values to replace:
values_i_do_not_want = ['ab', 'cd']
I'd like to replace a value_i_do_not_want with a mode for each name from df['name'] column.
I like to receive a final df:
| year | name | value | 
|---|---|---|
| 2000 | Mick | a | 
| 2001 | Mick | a | 
| 2002 | Mick | a | 
| 2003 | Mick | b | 
| 2000 | Jane | c | 
| 2001 | Jane | c | 
| 2002 | Jane | c | 
| 2003 | Jane | d | 
That is what I found closest to my expectations. I couldn't implement condition to code presented there.