How to find it in Python List?

for example:
list1 structure: name, ID, color, quantity, type
list1 = [["axiangliao 1, 255, 100, 03], [" a, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4,

list2 structure: name, type, list2
color

how do I find all the elements in list1 that match those in list2?
results
list = [["axiaozhengliao 1, 255, 100, 03"], [" axiong, 2, 481, 50, 50, 06], ["axiong, 47, 255, 500, 03"]

can only for compare one by one? Is there a simple method

Nov.19,2021

import pandas as pd
list1 = [['a',1,255,100,'03'],['a',2,481,50,'06'],['a',47,255,500,'03'],['b',3,1,50,'11']]
df1=pd.DataFrame(list1,columns=["","ID","","",""])
list2 = [['a','03',255],['a','06',481]]
df2=pd.DataFrame(list2,columns=["","",""])
df=pd.merge(df1,df2,how='inner',on=["","",""],right_index=True)
df.sort_index(inplace=True)
print(df)

if it is ordered, you can use dichotomy to find it, if it is not a loop traversal. The data structure of
list is not suitable for random query. If the amount of data is large, try other data structures, such as dictionaries.

Menu