我有一个数据框列,其文本如下
Description
Performed testing on XYZ app
User unable to login
Access denied
Hardware- Mouse is not working
Hardware - CPU is slow
Do not have access to DB
我有一本字典如下:
{'Access':'Security issue','login':'Login Issue','Testing':'Testing','Hardware':'hardware issue'}
我想将关键字映射到我的描述,如果找到关键字,则必须在新列的相同位置填充类别。 我尝试了以下代码:
df1['new_category'] = df1["Change Order Description"].map(map_dic)
上面的代码只映射了字典的最后一个类别。我有更多的类别。有人可以帮我吗。