2
I would like to know if there is the possibility of using the filter
with a function lambda
to select a conjunto de dados
of a array de J
SON
in the Python
.
Example: I have the following JSON
already as dict
in the Python
, follows the structure. And would like to filtrar
the dict's internos
who are of the type 'event' == 'a'
.
{'events': [{'event':'a', ...},{'event':'b',...},{'event':'a'...}]}
I’d like something like:
list_a = dict(filter(lambda x: [events][][x] == 'a', data_json.items()))
I can’t seem to see a way filtrar
the most internal dictionaries of this 'events'
.
What do you want in return of this
filter
???– ThiagoO
I would like to get all the contents of the array of 'Events' that have 'Event' = 'a' .
– Matheus Vinícius de Andrade
Only by using
lambda
?– ThiagoO
Yes, that’s the question.
– Matheus Vinícius de Andrade
Try f = filter(lambda x: x['Event'] ='a',dic['Events'])
– AnthraxisBR