I have two dataframes: One contains of company and its corresponding texts. The texts are in lists
**supplier_company_name Main_Text**
JDA SOFTWARE ['Supply chains','The answer is simple -RunJDA!']
PTC ['Hello', 'Solution']
The second dataframe is texts extracted from the company's website.
Company Text
0 JDA SOFTWARE About | JDA Software
1 JDA SOFTWARE 833.JDA.4ROI
2 JDA SOFTWARE Contact Us
3 JDA SOFTWARE Customer Support
4 PTC Training
5 PTC Partner Advantage
I want to create the new column in second dataframe if the text extracted from the web matches with the any item inside the list in the Main_Text column of the first data frame, fill True
else fill False
.
Code:
target = []
for x in tqdm(range(len(df['supplier_company_name']))): #company name in df1
#print(x)
for y in range(len(samp['Company']): #company name in df2
if samp['Company'][y] == df['supplier_company_name'][x]: #if the company name matches
#check if the text matches
if samp['Company'][y] in df['Main_Text'][x]:
target.append(True)
else:
target.append(False)
How can I change my code to run efficiently?