Pandas Merge returns NaN

后端 未结 2 506
隐瞒了意图╮
隐瞒了意图╮ 2021-01-01 19:48

I have issues with the merging of two large Dataframes since the merge returns NaN values though there are fitting values. The two dfs are shaped like:

df1

2条回答
  •  天涯浪人
    2021-01-01 20:54

    You need same dtype of joined columns:

    #convert first or second to str or int
    MergeDat['Motor'] = MergeDat['Motor'].astype(str)
    #Motor['Motor'] = Motor['Motor'].astype(str)
    
    #MergeDat['Motor'] = MergeDat['Motor'].astype(int)
    Motor['Motor'] = Motor['Motor'].astype(int)
    

    #convert first or second to str or int
    #MergeDat['Motor'] = MergeDat['Motor'].astype(str)
    Motor['Motor'] = Motor['Motor'].astype(str)
    
    MergeDat['Motor'] = MergeDat['Motor'].astype(int)
    #Motor['Motor'] = Motor['Motor'].astype(int)
    
    
    MergeDat=MergeDat.merge(Motor,how="left")
    

提交回复
热议问题