removing duplicates using json python 1

removing duplicates using json python

all_ids = [ each['obj_id'] for each in ds ] # get 'ds' from above snippet
unique_stuff = [ ds[ all_ids.index(id) ] for id in set(ids) ]

Here is what the above code is Doing:
1. Get a list of all the ids in the dataset
2. Get a list of unique ids
3. Get the index of each unique id in the list of all ids
4. Get the item from the dataset that corresponds to each unique id

Similar Posts