Not surprisingly, DataFrames provide methods for function application. There are two methods you should be aware of, apply and applymap. apply takes a function and, by default, applies the function to the series corresponding to each column of the DataFrame. What is produced depends on what the function does. We can change the axis argument of apply so that instead of applying to columns (that is, across rows), it applies to rows (that is, across columns). applymap has a different purpose than apply. Whereas apply will evaluate the supplied function on each column and thus should be prepared to take a series, applymap will evaluate the pass function on each element of the DataFrame individually.
We could apply ...