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 number of common element in two python array

len([x for x in list1 if x in list2])
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 :: python module path 
Python :: stop flask server 
Python :: data type array 
Python :: downgrade python version windows 
Python :: python dictoinary add value 
Python :: how to add value in array django 
Python :: len of iterator python 
Python :: a list of keys and a list of values to a dictionary python 
Python :: queue functions in python 
Python :: reply_photo bot telegram python 
Python :: standard deviation in python numpy 
Python :: print each element of list in new line python 
Python :: python internship 
Python :: teardown module pytest 
Python :: how to add zeros in front of numbers in pandas 
Python :: count element in set python 
Python :: python array of tuples for loop 
Python :: create new dataframe from existing data frame python 
Python :: python random choices weights 
Python :: max function python 
Python :: python print variable 
Python :: for loops python 
Python :: how to multiply in python 
Python :: pandas fillna 
Python :: python string replace letters with numbers 
Python :: double a value in a list python 
Python :: python list extend() 
Python :: how to extract dictionary value from string in python 
Python :: text color python tkinter 
Python :: How to show variable in Jupyter 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =