Returning a Series: http://stackoverflow.com/questions/19121854/using-rolling-apply-on-a-dataframe-object Returning a Scalar: http://stackoverflow.com/questions/21040766/python-pandas-rolling-apply-two-column-input-into-function/21045831#21045831