rename elements in a column of a data frame using pandas
You can pass a dictionary of replacement values into the Series replace method:
In [11]: df['n'].replace({'a': 'x', 'b': 'y', 'c': 'w', 'd': 'z'})Out[11]: 0 z1 x2 y3 w4 w5 x6 z7 yName: n, dtype: objectIn [12]: df['n'] = df['n'].replace({'a': 'x', 'b': 'y', 'c': 'w', 'd': 'z'})