Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find common elements in two lists python

list1 = [1,2,3,4,5,6]
list2 = [3, 5, 7, 9]
list(set(list1).intersection(list2))
Comment

find common in lists

>>> a = [1, 2, 3, 4]
>>> b = [2, 3, 4, 5]
>>> c = [3, 4, 5, 6]
>>> set(a) & set(b) & set(c)
{3, 4}
Comment

find common words in two lists python

list1 = ['little','blue','widget']
list2 = ['there','is','a','little','blue','cup','on','the','table']

list3 = set(list1)&set(list2)

list4 = sorted(list3, key = lambda k : list1.index(k))
Comment

python common elements in two arrays

# using numpy
import numpy as np
a = np.array([1,2,3,2,3,4,3,4,5,6])
b = np.array([7,2,10,2,7,4,9,4,9,8])
# using intersect1d
print(np.intersect1d(a,b))
# output
# [2 4]
Comment

PREVIOUS NEXT
Code Example
Python :: minimal flask application import 
Python :: get screen size python 
Python :: pandas rename specific column 
Python :: txt to list python 
Python :: where to import render in django 
Python :: unix to date python 
Python :: replace all spacec column with underscore in pandas 
Python :: python repeat every n seconds 
Python :: matplotlib log 
Python :: tensorflow check gpu 
Python :: python check if string is date format 
Python :: save plot as pdf python 
Python :: importlib.reload not working 
Python :: python subprocess.run output 
Python :: how to print hello world 10 times in python 
Python :: how to find python location in cmd 
Python :: python strip non numeric in string 
Python :: animations text terminal python 
Python :: python flask sample application 
Python :: plus or minus symbol 
Python :: how to create a list from csv python 
Python :: save machine learning model 
Python :: execute command and get output python 
Python :: how to import csv in pandas 
Python :: python open each file in directory 
Python :: python install command in linux 
Python :: python replace space with underscore 
Python :: python get majority of list 
Python :: seaborn axis limits 
Python :: discord.py clear command 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =