I have a list of dictionaries like so:
[{'end': 34,
'entity_group': 'ORG',
'score': 0.99919325,
'start': 0,
'word': ' Community College Alabama'},
{'end': 54,
'entity_group': 'LOC',
'score': 0.90115756,
'start': 42,
'word': ' Maxwell Blvd'},
{'end': 66,
'entity_group': 'LOC',
'score': 0.9890175,
'start': 56,
'word': ' Montgomery'},
{'end': 70,
'entity_group': 'LOC',
'score': 0.9988833,
'start': 68,
'word': ' AL'}]
I would like to extract values of word, but only the ones where 'entity_group': 'LOC'. So for the above example, that would be:
[' Maxwell Blvd', ' Montgomery', ' AL']
I have tried to do this:
[[item for item in d.items()] for d in a]
… but this does not yield what I want.
>Solution :
[d['word'] for d in a if d['entity_group'] == 'LOC']