I am aware of these two similar questions:
Pandas replace values
Pandas: Replacing column values in dataframe
I used a different approach for substitutin
to_rep = dict(zip([1, 3, 2],[3, 6, 7])) df.replace({'A':to_rep, 'B':to_rep}, inplace = True)
This will return:
A B C 0 3 7 8 1 6 4 8 2 5 3 8