Reputation: 25629
How do I get numpy array into python list?
looking for ('foo', 1, 2, 3, 4) series is a numpy array
symbol = 'foo'
def rowp (symbol,series):
rowp=[]
series = series[0:4]
ss = series.tolist
rowp.append(symbol)
rowp.append(ss)
print rowp
I get error:
['foo', <built-in method tolist of numpy.ndarray object at 0x05D07D40>]
Upvotes: 2
Views: 1073
Reputation: 816302
As you can already see by the error message, tolist
[docs] is a method. That means you have to call it:
ss = series.tolist()
Update: Use extend
instead of append
:
rowp.extend(series.tolist())
Btw, the result you get is not an error.
Upvotes: 6