0

I have trying to do a very simple .apply to an sarray in graph lab create and I am confused as to why it is not working.

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

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

sa.apply(myfunc, dtype = int)

My output is

[None, None, None, None, None]

Why is it not [-1, -1, -1, 1, 1] and how can I fix it?

Hound
  • 932
  • 2
  • 17
  • 26

1 Answers1

0

I got it to work using

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

but I am still not sure why what I tried above does not work...

Hound
  • 932
  • 2
  • 17
  • 26