Are there any methods to apply several columns of SFrame to get a new SFrame?

User 2728 | 12/3/2015, 11:47:10 PM

I want to return two new columns based on four columns. When I use apply function, it returns SArray. I need a SFrame. Are there any methods to apply several columns of SFrame to get a new SFrame?

Comments

User 954 | 12/4/2015, 11:57:26 PM

Hi,

No unfortunately it does not exist. The best you can do is to pass the new SArray's to a new SFrame: import graphlab as gl sf = gl.SFrame({'a':[1,2,3],'b':[2,3,4],'c':[3,4,5]}) sa1 = sf.apply(lambda row: row['a'] + row['b']) sa2 = sf.apply(lambda row: row['c'] + row['b']) new_sf = gl.SFrame({'sum1':sa1,'sum2':sa2})


User 2728 | 12/18/2015, 2:28:38 AM

Yes. This is what I did in my code.


User 2728 | 1/21/2016, 1:30:41 AM

I think flat_map function is what I need.


User 3069 | 2/2/2016, 3:27:18 PM

Do you know when flat_map was introduced? When I tried to find function that did this thing I didn't find anything. I manage to make it from other basic functions but probably with some overhead