selecting text from column in an SFrame

User 5199 | 5/15/2016, 12:39:17 AM

How does one select an item from a Sframe column? and if present return number of matching elements or return 0?


User 12 | 5/16/2016, 3:46:48 PM

Hi Cliff, Can you give us an example of what you'd like to do? I don't understand what you mean by the number of matching elements - is that within an SFrame column or row, or something else?

In the meantime, SFrame elements can be accessed by column and row:

sf = graphlab.SFrame({'a': [1, 2, 3], 'b': ['apple', 'banana', 'car']})
item = sf['b'][1]
same_item = sf[1]['b']

Thanks, Brian

User 5199 | 5/23/2016, 1:38:59 PM

I meant that how would you return another column with any preselected elements like"apple" and then return a array that has the number of times 'apple' occurs and if not 0. the array would have rows of 'a','b' and for each the number of times 'apple' is in the row. ['a',0]:['b',1] 'apple' would be the heading of the column.