I have two spreadsheets that both contain UK postcodes, which I'm loading into two pandas DataFrames. I need to go through each row in one DataFrame and check if the 'postcode' value is contained in the 'postcode' column of the second DataFrame.
The code I expected to work is:
data_to_process = pd.read_excel('input.xlsx')
postcodes = pd.read_excel('salespeople_patches.xlsx')
salesperson_postcodes_list = postcodes[postcodes['Salesperson']=='Dave']['Postcode'].to_list()
data = data_to_process[data_to_process['District'] in salesperson_postcodes_list]
The error I'm getting is:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().