pythongraphlabsframe

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

Solution

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