While merging 2 DataFrames with following command:
df = pd.merge(df,LFA1, left_on='Vendor', right_index=True, how='left')
... and got the infamous message: "You are trying to merge on object and int64 columns.". It appears that the most probable cause is that the left or right key type is 'int'.
I found two methods to force the types of the keys to str: a. when creating the DataFrame:
LFA1= pd.read_excel(r'G:\FAIA 2018\Extracts\LFA1(Full).xlsx',converters={'Vendor':str})
b. after the creation of the DataFrame:
LFA1['Vendor']=LFA1['Vendor'].astype(str)
Even if I ask for the type right after the command:
df.types()
LFA1.types()
the column 'Vendor' stays 'object', but never shows 'str'.
I believe that this is the root cause behind the message, but none of those methods succeeded apparently in switching the type to string.
I either misunderstood or missed a step...