I have two dataframes: One contains of name and year.
**name** **year**
ram 1873
rob 1900
Second contains names and texts.
**name** **text**
ram A good kid
ram He was born on 1873
rob He is tall
rob He is 12 yrs old
rob His father died at 1900
I want to find the indices of the rows of second dataframe where the name of second dataframe matches with name of the first df and the text in second df contains the year in first df.
The result should be indices 1,4
My Code:
ind_list = []
for ind1, old in enumerate(A.name):
for ind2, new in enumerate(B.name):
if A.name[ind1] == B.name[ind2]:
if A.year[ind1] in B.text[ind2]:
ind_list.append(ind2)
Any better way to write the above code?