Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find all unique items in dictionary value python

L = [{"V":"S001"}, {"V": "S002"}, {"VI": "S001"}, {"VI": "S005"}, {"VII":"S005"}, {"V":"S009"},{"VIII":"S007"}]
print("Original List: ",L)
u_value = set( val for dic in L for val in dic.values())
print("Unique Values: ",u_value)
Comment

print all unique values in a dictionary

dict = {'511':'Vishnu','512':'Vishnu','513':'Ram','514':'Ram','515':'sita'}
list =[] # create empty list
for val in dict.values(): 
  if val in list: 
    continue 
  else:
    list.append(val)

print list
Comment

PREVIOUS NEXT
Code Example
Python :: python print odd numberrs 
Python :: label encoding in python 
Python :: generate unique id from given string python 
Python :: 1d array to one hot 
Python :: python scheduling 
Python :: read emails from gmail python 
Python :: discord py edit message 
Python :: flask migrate 
Python :: replace values in a column by condition python 
Python :: django filter by date range 
Python :: pandas two dataframes equal 
Python :: pyside 
Python :: get length of pandas 
Python :: django logout page 
Python :: string to bits python 
Python :: random library python 
Python :: selenium firefox webdriver 
Python :: cryptography python 
Python :: numpy delete column 
Python :: opencv python grayscale image to color 
Python :: python regex inside quotes 
Python :: python flatten list 
Python :: python convert multidimensional array to one dimensional 
Python :: get page title by python bs4 
Python :: python how to get the folder name of a file 
Python :: kivy change window size 
Python :: wintp python manage.py createsuperuser 
Python :: initialise a 2d array python 
Python :: pandas categorical to numeric 
Python :: django timezone settings 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =