Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({'P': range(4), 'Q': range(2, 6)})
df
Out[2]:
P Q
0 0 2
1 1 3
2 2 4
3 3 5

In [3]:
df.transform(lambda x: x + 2)
Out[3]:
P Q
0 2 4
1 3 5
2 4 6
3 5 7

Even though the resulting Series must have the same length as the input Series, it is possible to provide several
input functions:

In [4]:
s = pd.Series(range(4))
s
Out[4]:
0    0
1    1
2    2
3    3
dtype: int64
In [5]:
s.transform([np.sqrt, np.exp])
Out[5]:
sqrt exp
0 0.000000 1.000000
1 1.000000 2.718282
2 1.414214 7.389056
3 1.732051 20.085537