2024-04-26 22:03:13 发布
网友
actual_df['new_col'] = np.where(lookup_df['name'].str.contains(actual_df['name'] + '-'), lookup_df['name'], 'Not Found')
上述代码引发以下错误:
'Series' objects are mutable, thus they cannot be hashed
如何使用另一个数据帧执行所需的查找
若两列的长度相同,则使用切片代替“str.contains()”方法
actual_df['new_col']= np.where(lookup_df['name'] == actual_df["name"].str[:-1], df2['name2'], 'Not Found')
如果没有,请使用下面的“df.isin()”方法:
actual_df['new_col'] = actual_df["name"][actual_df["name"].isin(lookup_df["name"].str[:-1])]
若两列的长度相同,则使用切片代替“str.contains()”方法
如果没有,请使用下面的“df.isin()”方法:
相关问题 更多 >
编程相关推荐