2016-04-16 10 views
0

Ich habe versucht, eine sehr einfache .apply auf ein sarray in graph lab create und ich bin verwirrt, warum es nicht funktioniert.GraphLab .apply auf sframe

def myfunc (x): 
if(x == 0): 
    x = -1 

sa = SArray([0,0,0,1,1], dtype=int) 

sa.apply(myfunc, dtype = int) 

Meine Ausgabe ist

[None, None, None, None, None] 

Warum ist es nicht [-1, -1, -1, 1, 1], und wie kann ich es beheben?

Antwort

0

habe ich es mit

sa.apply(lambda sa : -1 if sa ==0 else sa) 

zu arbeiten, aber ich bin immer noch nicht sicher, warum das, was ich oben versucht nicht funktioniert ...