Python TA-Lib not working with pandas series

numpy, python

Solution

For `pandas` >= 0.13.0:

Passing a Series directly to a cython function expecting an ndarray type will no long work directly, you must pass Series.values

So before `TA-lib` revises its API to accommodate the newer `pandas` versions, you need to use `Series.values` or `DataFrame.values`.

Problem

I am trying to use the TA-Lib in python on Ubuntu 12.04 as described in the official documentation. However, when using pandas `DataFrame`s or `Series`, as shown in multiple examples on different sources, I get the following `TypeError`: Traceback (most recent call last): File "test1.py", line 14, in analysis['rsi'] = ta.RSI(spy.Close) TypeError: Argument 'real' has incorrect type (expected numpy.ndarray, got Series) When executing e.g. this code: ``` import pandas.io.data as data import pandas as pd import talib as ta import matplotlib.pyplot as plt # Download SP500 data with pandas spyidx = data.get_data_yahoo('SPY', '2013-01-01') analysis = pd.DataFrame(index = spyidx.index) analysis['rsi'] = ta.RSI(spyidx.Close) ``` What went wrong?

Original source