Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to unique list in python

import numpy as np

def unique(list1):
    npArray1 = np.array(list1)
    uniqueNpArray1 = np.unique(npArray1)
    return uniqueNpArray.tolist()
  
list1 = [10, 20, 10, 30, 40, 40]
unique(list1) # [10, 20, 30, 40]
Comment

python list unique in order

>>> items = [1, 2, 0, 1, 3, 2]
>>> list(dict.fromkeys(items))  # Or [*dict.fromkeys(items)] if you prefer
[1, 2, 0, 3]
Comment

unique list values python ordered

def get_unique(seq):
    seen = set()
    seen_add = seen.add
    return [x for x in seq if not (x in seen or seen_add(x))]
Comment

unique items in a list python

list(dict.fromkeys(list_with_duplicates))
Comment

PREVIOUS NEXT
Code Example
Python :: how to make a stopwatch in python 
Python :: iterate through an array python 
Python :: plt.savefig specify dpi 
Python :: matplotlib to pdf 
Python :: contains duplicate in python 
Python :: python write line break 
Python :: assign multiline string to variable in python 
Python :: how to rotate screen with python 
Python :: custom validation in django models 
Python :: how to print a number at the end of a for loop in python 
Python :: how to delete a variable python 
Python :: standard deviation python 
Python :: pandas change order of columns in multiindex 
Python :: python cross validation 
Python :: how to select a file in python 
Python :: how to put in code to download discord py 
Python :: STATIC_ROOT 
Python :: python add two numbers 
Python :: default flask app 
Python :: async sleep python 
Python :: python loop append to dictionary 
Python :: comment in python 
Python :: add new keys to a dictionary python 
Python :: what is instance variable in python 
Python :: Converting Hex to RGB value in Python 
Python :: count item in list python 
Python :: get number of zero is a row pandas 
Python :: python delete value from dictionary 
Python :: pandas groupby mean 
Python :: unique_together what is used of it in django 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =