1
Straightforward.
Creating the Dataframe
>>> import pandas as pd
>>> df = pd.DataFrame({"A": [1, 2, 3, 4, 5, 6], "B": ["um", "dois", "a", "a", "cinco", "seis"], "C": ["a", "b", "outros", "outros", "c", "c"]})
>>> df
A B C
0 1 um a
1 2 dois b
2 3 a outros
3 4 a outros
4 5 cinco c
5 6 seis c
Changing the value
>>> df.loc[df.B == "a", "C"] = "a"
>>> df
A B C
0 1 um a
1 2 dois b
2 3 a a
3 4 a a
4 5 cinco c
5 6 seis c
>>>
With the help of Numpy
>>> import numpy as np
>>> df['C'] = np.where((df.B == 'a'), 'a', df.C)
>>> df
A B C
0 1 um a
1 2 dois b
2 3 a a
3 4 a a
4 5 cinco c
5 6 seis c
I hope it helps
Hello, what are you considering as a highlight? if it is a specific value you can use the apply method.
– Fernando dos Santos
In your case I believe it would look like this;
df['C'] = df.apply(lambda x: x['B'] if x['B'] == 'A' else x['C'] , axis=1)
– Fernando dos Santos