Apply function to each cell in DataFrame
You can use applymap()
which is concise for your case.
df.applymap(foo_bar)# A B C#0 wow bar wow bar#1 bar wow wow bar
Another option is to vectorize your function and then use apply
method:
import numpy as npdf.apply(np.vectorize(foo_bar))# A B C#0 wow bar wow bar#1 bar wow wow bar