I am trying to replace values in a column, but for some reason one of the values is not changing. The three values are - 'xxx' , 'aaa' and 0. The problem is with the zero.
This is part of the code I am using:
df['source'] = np.select(conditions, ['xxx', 'aaa'], default=0)
df['source'] = df['source'].replace({'xxx': 'xxx', 'aaa': 'aaa', 0: 'test'})
First I am using np.select based on some conditions and since I cant put string value on default, I want to replace the zero with another string. And I can't understand what I am doing wrong.
df['source'] = df['source'].replace(0, 'test')or maybe replace0with the string'0'?since I cant put string value on defaultwhy is that?default = 'test'doesnot work?