flatten icon indicating copy to clipboard operation
flatten copied to clipboard

Assistance needed

Open GefenPuravida opened this issue 5 years ago • 0 comments

Sorry to bother.. not really an issue. just an "almost there".

Wondering if someone have a moment to guide me.

I have this data:

in []:

dfc=dfb['entities']
dfc
out []:

0    [{'name': 'Shop', 'type': 'LOCATION', 'salienc...
1    [{'name': 'Shop', 'type': 'LOCATION', 'salienc...
Name: entities, dtype: object
in []:

dfTodict = dfc.to_dict()
dfTodict
out []:

{0: [{'name': 'Shop',
   'type': 'LOCATION',
   'salience': 0.034899305552244186,
   'wikipedia_url': '-'},
  {'name': 'Brand',
   'type': 'ORGANIZATION',
   'salience': 0.019303809851408005,
   'wikipedia_url': 'https://en.wikipedia.org/wiki/Brand'},
......
 {'name': '57', 'type': 'NUMBER', 'salience': 0.0, 'wikipedia_url': '-'}],
 1: [{'name': 'Shop',
   'type': 'LOCATION',
   'salience': 0.054236818104982376,
   'wikipedia_url': '-'},
  {'name': 'Brand',
   'type': 'ORGANIZATION',
   'salience': 0.023990564048290253,
   'wikipedia_url': 'https://en.wikipedia.org/wiki/Brand'},
......

I want to preform the seconed flatten format from the readme:

dic_flattened = (flatten(d) for d in dfTodict)

but then i get a generator object which is difficult for me to understand how to make it a dataframe.

<generator object <genexpr> at 0x0000022301C025E8>

Thank you !

GefenPuravida avatar Aug 13 '19 22:08 GefenPuravida