2

I need to convert an SFrame column to a list.

input :

 `+---------+
  |   word  |
  +---------+
  |   love  |
  |  loves  |
  |   easy  |
  | perfect |
  |  great  |
  +---------+`

output:

['love', 'loves', 'easy', 'perfect', 'great']

2 Answers2

10

I'm surprised the list function gave you an error. This works for me:

import graphlab as gl
sf = gl.SFrame({'fruit': ['apple', 'banana', 'pear']})
list(sf['fruit'])

Returns:

['apple', 'banana', 'pear']
papayawarrior
  • 1,027
  • 7
  • 10
0

HINT: you can convert it to an array using:

arr = sf.to_numpy()
mounir ben salem
  • 366
  • 1
  • 2
  • 11
  • Yeah,I know that . I had an idea to convert sframe to an array then from array to list using tolist(),but I need to convert it directly to list when using huge data set ! – Mohamed Abdallah Mar 28 '16 at 00:40