apply a function to a dataframe column

In [1]:
import pandas as pd
df = pd.DataFrame([['AA', 1], ['BB', 2], ['CC', 3]], columns=['name', 'value'])

In [2]:
df


Out[2]:
name value
0 AA 1
1 BB 2
2 CC 3

In [3]:
def function_1(val_1):
    return "prefix_" + str(val_1)

In [4]:
df['name'] = df['name'].map(function_1)

In [5]:
df


Out[5]:
name value
0 prefix_AA 1
1 prefix_BB 2
2 prefix_CC 3

In [ ]: