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 create role discord.py 
Python :: python append value to dictionary list 
Python :: python not equal multiple values 
Python :: python password checker 
Python :: django admin override save 
Python :: How to append train and Test dataset in python 
Python :: get requests python 
Python :: get dataframe column into a list 
Python :: python subtract list from list 
Python :: how to play and stop music python 
Python :: pandas swapaxes example 
Python :: Iterate through characters of a string in python 
Python :: how to make a checksum to a file python 
Python :: python keyboard key codes 
Python :: Find Files With a Certain Extension in the Directory and Its Subdirectories in Python 
Python :: pd df rename 
Python :: multiprocessing print does not work 
Python :: create pyspark dataframe from list 
Python :: python sockets 
Python :: how to replace the last character of a string in python 
Python :: add metadata png PIL 
Python :: handwriting python 
Python :: get scipy version python 
Python :: what is *args and **kwargs in django 
Python :: pandas get outliers 
Python :: how to print a variable in python 
Python :: sha256 decrypt python 
Python :: how to set and run flask app on terminal 
Python :: django get fields data from object model 
Python :: python split string into floats 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =