I have to put a column in a list to be able to find matches.
I am trying to create a table "mytable" that gets data from going through each row of another table "table_main" and if it meets the condition, add rows to mytable. I have other tables as well, e.g. "table3" all DataFrame.
I wrote it like:
mytable = {'column1' :[] , 'column2':[] , 'column3': [] , 'column4':[]}
for index, row in table_main.itterrows():
if row['apple'] not in table3['codes'] and row['apple']!= "07":
mytable['column1'].append("2024")
mytable['column2'].append(str(row['number']))
mytable['column3'].append(str(row['apple']))
mytable['column4'].append("first condition")
but it can't understand row['apple'] values exist in table3['codes']. I tried to put str( before them still not working. Only works when I put table3['codes'].tolist() but I don't want to do it. Does anyone know why?
Try this :
Updated code For Matching row: