Get dict, string etc. values "out of" an SArray

User 3807 | 3/20/2016, 5:42:47 PM

Hi, sorry this is for sure an extremely stupid question, but I can't find how to extract raw string/dict etc values out of an SArray (e.g., to manipulate them with functions like sorted() etc) Could anyone please advise? Thank you Sigrid

Comments

User 1190 | 3/21/2016, 6:46:24 PM

You can transform an SArray into a list at cost. However, most of the functionality in list can be achieved without converting it to list. You can do elementwise transform using apply(), and there are also sort(), topk()... sa = gl.SArray(['a','b', 'c']) ls = list(sa)


User 3807 | 3/22/2016, 8:47:20 PM

Thank you! However, in my case the underlying datatype is a string, and I get an error when I want to use a String function:

In [58]: list(song_data['artist']).split() ... AttributeError: 'list' object has no attribute 'split'

What do I use in this case? Thank you!