apply transformation to column pandas code example
Example 1: pandas apply function to column
df['a'] = df['a'].apply(lambda x: x + 1)
Example 2: pandas transform
>>> df = pd.DataFrame({'A': range(3), 'B': range(1, 4)})
>>> df
A B
0 0 1
1 1 2
2 2 3
>>> df.transform(lambda x: x + 1)
A B
0 1 2
1 2 3
2 3 4