I have two pandas dataframes, df1
and df2
df1 looks like this:
|Name |Age |Country |Industry|Score |
-------------------------------------------------
|BIMBOA MM |8 |CO |Paper |5 |
|AGUA* MM |13 |CH |Finance |7 |
|ENTEL CI |5 |PE |Paper |2 |
|AXTELCPO MM |4 |CO |Oil |1 |
|ALPEKA MM |2 |BR |Oil |9 |
|KIMBERA MM |12 |AR |Finance |1 |
And df2
looks like this:
|Name |Age |Country |Industry|Research Level |
-------------------------------------------------------------
|BIMBOA.MX |8 |CO |Paper |4 |
|AGUA.MX |13 |CH |Finance |0 |
|86964WAJ1=1M |5 |PE |Paper |2 |
|USP9810XAA9=1M |4 |CO |Oil |1 |
|KIMBERA.MX |2 |BR |Oil |0 |
|AXTELCPO.MX |12 |AR |Finance |3 |
And I want to merge them by the column "Name". But, I want to allow to merge with not exact coincidence of the strings in the column. So I coul get somethin like this:
|Name |Age |Country |Industry|Score |Research Level |
-----------------------------------------------------------------
|BIMBOA MM |8 |CO |Paper |5 |4 |
|AGUA* MM |13 |CH |Finance |7 |0 |
|ENTEL CI |5 |PE |Paper |2 |NaN |
|AXTELCPO MM |4 |CO |Oil |1 |3 |
|ALPEKA MM |2 |BR |Oil |9 |NaN |
|KIMBERA MM |12 |AR |Finance |1 |0 |
I tried with this:
merged_df1_df2 = pd.merge_asof(df1, df2, on='Name')
But I got this error:
MergeError: Incompatible merge dtype, dtype('O') and dtype('O'), both sides must have numeric dtype
Do you guys any idea of how can I do this?