Mohamed Abdallah
Mohamed Abdallah

Reputation: 33

convert an sframe column to a list

I need to convert an SFrame column to a list.

input :

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

output:

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

Upvotes: 2

Views: 4390

Answers (2)

papayawarrior
papayawarrior

Reputation: 1027

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']

Upvotes: 10

mounir ben salem
mounir ben salem

Reputation: 366

HINT: you can convert it to an array using:

arr = sf.to_numpy()

Upvotes: 0

Related Questions