How to create a SFrame from a list of dictionaries

User 2631 | 11/17/2015, 8:40:17 PM

Hello guys, I'm trying to create a SFrame from a list of dictionaries, is it possible? I have some data on a MongoDB collection and I would like to transform it into a SFrame to "play around" a little bit.



User 2156 | 11/17/2015, 8:55:45 PM


if you have the list of dictionaries like this: test = [{'col1':'v1','col2':'test1'},{'col1':'v2','col2':'test2'}], You may get a sframe using the following code: import graphlab as gl sf = gl.SFrame(test) res = sf.unpack('X1')

User 2631 | 11/23/2015, 4:32:54 PM

Thank you for the response, but i'm not getting the right result

SFrame has the function unpack -

Why is this error occurring?

movies is a list of dicitonaries like this:

User 2631 | 11/23/2015, 5:01:48 PM

I got it, it was a mistake in my part. But now I have another question, how can I deal with fields that are lists of dictionaries


Is it better to unpack it in another sFrame and append the id in the first Sframe? And work using a external key like in a SQL database?

User 19 | 11/23/2015, 6:26:50 PM

Hi lfomendes,

It appears that the 'original music' column is a list of dictionaries. You might want to first make a new SArray that just contains dictionaries, and then call unpack on that new column. You might be interested in using output_column_prefix='' so that the final SFrame will have columns 'name', 'id', etc.

Let me know if that helps, Chris