I have two csv file like the below:
city.csv :
City,Province
aa,b
bb,c
ee,b
customers.csv:
Address, CustomerID
John Smith aa blab blab, 234
Micheal Smith bb blab2 blab2, 123
I want join two csv files with pandas dataframe with the condion (if City in address).
I try the below code:
import pandas as pd
df1 = pd.read_csv(r"city.csv")
df2 = pd.read_csv(r"customers.csv")
df1["City"] = df2.drop("Address", 1).isin(df2["Address"]).any(1)
I follow this Q/A but it did not work for me. How to join these two csv files in pandas dataframe?