I have a dataframe:
v1 v2 v3
x b x
o x x
x x x
b b b
g b g
x g x
I want to replace values in columns with 1 and 0. 1 if value is equal x (and type must be changed too), 0 if it anything else (and type must be changed too). How could i do that?
I try this, but it doesnt work:
for i in range(3):
df.iloc[:,i].replace([0,1],['b','x'],inplace=True).astype("int")
And I don't know how to write part with 0 for anything besides of "x"