def rsi(df, n, field = 'close'): RSI_key = 'RSI%s' % str(n) df[RSI_key][-1] = talib.RSI(df[field][(-n-1):], n)[-1]