Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({'X': range(4), 'Y': range(2, 6)})
df
Out[2]:
X Y
0 0 2
1 1 3
2 2 4
3 3 5
In [3]:
df.transform(lambda x: x + 1)
Out[3]:
X Y
0 1 3
1 2 4
2 3 5
3 4 6

Even though the resulting DataFrame must have the same length as the input DataFrame,
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