I've just built a function that is working fine on my laptop (Mac, but I'm working on a Windows virtual machine of the office laptop), but when I pass it to a colleague o'mine, it raises a ValueError:
"You are trying to merge on object and int64 columns. If you wish to proceed you should use pd.concat"
The line of the code that raises the error is a simple merge that on my laptop works perfectly:
df = pd.merge(df1, df2, on = "x", how = "outer)
The input files are exactly the same (taken directly from the same remote folder). I totally don't know how to fix the problem, and I don't understand why on my laptop it works (even if I open a new script or I restart the kernel, so no stored variables around) and in the one of my colleague it doesn't.
Thanks for your help!
One of the column is an object data type and the other is an integer. They need to be the same format in order to merge. Try adding two lines to change the data type on your colleague's computer.
df2['x'] = df2['x'].astype(str)
df1['x'] = df1['x'].astype(str)
df = pd.merge(df1, df2, on = "x", how = "outer)
The behavior is probably different because of a different version of pandas; or, potentially, there are slight nuances in the excel file, where the excel file on your colleague's computer has one of the columns saved in a different format.