I want to make the Dictionary type in the List unique

data

Suppose that the following appears. I want to make this unique.

>>> d = [{'x':1, 'y':2}, {'x':3, 'y':4}, {'x':1, 'y':2}]

unique

>>> [dict(y) for y in set(tuple(x.items()) for x in d)]
[{'y': 4, 'x': 3}, {'y': 2, 'x': 1}]

reference

http://stackoverflow.com/questions/6280978/how-to-uniqify-a-list-of-dict-in-python

Recommended Posts

I want to make the Dictionary type in the List unique
I want to make the second line the column name in pandas
I want to display the progress in Python!
I want to sort a list in the order of other lists
[Python] I want to make a nested list a tuple
I want to use the R dataset in python
I want to see a list of WebDAV files in the Requests module
I checked the reference speed when using python list, dictionary, and set type in.
I want to count unique values in arrays and tuples
I want to align the significant figures in the Numpy array
I want to make input () a nice complement in python
I didn't want to write the AWS key in the program
I want to see the graph in 3D! I can make such a dream come true.
[Linux] I want to know the date when the user logged in
LINEbot development, I want to check the operation in the local environment
I want to pass the G test in one month Day 1
I want to know the population of each country in the world.
I want to pin Spyder to the taskbar
I want to output to the console coolly
I want to print in a comprehension
[Django] Convert QuerySet to dictionary type list
I want to handle the rhyme part1
I want to handle the rhyme part3
I want to display the progress bar
I want to make an automation program!
I want to embed Matplotlib in PySimpleGUI
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
I want to change the color by clicking the scatter point in matplotlib
[Python] I tried to summarize the set type (set) in an easy-to-understand manner.
[C language] I want to generate random numbers in the specified range
I want to batch convert the result of "string" .split () in Python
I want to explain the abstract class (ABCmeta) of Python in detail.
I want to use the Django Debug Toolbar in my Ajax application
I want to leave an arbitrary command in the command history of Shell
I want to do Dunnett's test in Python
I want to pin Datetime.now in Django tests
I want to create a window in Python
I want to make a game with Python
I want to handle the rhyme part7 (BOW)
Make a copy of the list in Python
I want to make fits from my head
I want to create a plug-in type implementation
I want to make C ++ code from Python code!
I want to customize the appearance of zabbix
I want to use the activation function Mish
[Python] I want to know the variables in the function when an error occurs!
I want to use Python in the environment of pyenv + pipenv on Windows 10
[Django memo] I want to set the login user information in the form in advance
I want to make a music player and file music at the same time
I want to set a life cycle in the task definition of ECS
I want to store the result of% time, %% time, etc. in an object (variable)
I want to get the file name, line number, and function name in Python 3.4
I want to write in Python! (1) Code format check
I want to see the file name from DataLoader
I tried to graph the packages installed in Python
I want to easily implement a timeout in python
I want to transition with a button in flask
I want to use self in Backpropagation (tf.custom_gradient) (tensorflow)
I want to grep the execution result of strace