Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

two lists with identical entries get order

from collections import defaultdict, deque

indexes = defaultdict(deque)
for i, x in enumerate(lst2):
    indexes[x].append(i)

ids = [indexes[x].popleft() for x in lst1]
Comment

PREVIOUS NEXT
Code Example
Python :: flassger 
Python :: python function for sorting list with mixed data types 
Python :: Specifying your data type 
Python :: pyttsx3 Running a driver event loop 
Python :: Python getting content from xl range 
Python :: continue loop django template 
Python :: aws chalice 
Python :: Code Example of Comparing None with None type 
Python :: Simple Python Permutation Printing result without for loop 
Python :: Math Module atan() Function in python 
Python :: split x and y pandas 
Python :: df .isna percentage 
Python :: python gender input 
Python :: boto3 get_item 
Python :: which can be reversed , string or list? 
Python :: run flask in Jython 
Python :: python subprocess call with no environment variable 
Python :: Python NumPy atleast_1d Function Example 
Python :: display colors in python console 
Python :: Python NumPy asarray Function Example Tuple to an array 
Python :: Python NumPy row_stack Function Syntax 
Python :: Python NumPy hsplit Function Syntax 
Python :: Python __ne__ 
Python :: what are while loops in python 
Python :: NumPy invert Code When the input is a number 
Python :: Termfastapi get ip 
Python :: how to show all rows whith a unique value in a column 
Python :: django hash password Argon 
Python :: gremlin python import 
Python :: groupby and add aggregated column 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =