I am creating a series of calculations in my dataframe and have been using apply successfully, until the one example below. Can anyone explain why "transform" work