Problem filling missing (None) value

User 1014 | 12/4/2014, 4:20:51 PM

I somehow cannot replace None values in an SArray: sa = graphlab.SArray([1,None,3]) sa.apply(lambda xyz: 4 if xyz is None else xyz)

produces: dtype: int Rows: 3 [1, None, 3]

What am I missing? (I've also tried xyz==None)

Comments

User 15 | 12/4/2014, 4:29:34 PM

Try this

<pre> sa = graphlab.SArray([1,None,3]) sa.apply(lambda xyz: 4 if xyz is None else xyz, skip_undefined=False) </pre>

By default, we skip all None values because it causes a lot of unexpected errors for pretty much any operation other than converting Nones.


User 2281 | 9/22/2015, 5:27:37 PM

Still doesn't work. sa = gl.SArray([1,None,3]) print sa sa.apply(lambda xyz: 4 if xyz is None else xyz, skip_undefined=False) print sa [1L, None, 3L] [1L, None, 3L]


User 2281 | 9/22/2015, 5:33:46 PM

OK it should be: sa = gl.SArray([1,None,3]) print sa

sa2=sa.apply(lambda xyz: 4 if xyz is None else xyz, skip_undefined=False) print sa2


User 1178 | 9/22/2015, 9:33:33 PM

Al,

Glad you figured it out! GraphLab Create structures are immutable, so any operation on it should be assigned to another variable explicitly.

Thanks! Ping