You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在员工DataFrame中查找LOV列并通过映射DataFrame替换为对应编码

需求说明

现有一份包含员工ID及各国合同相关信息的脏数据DataFrame,其中部分列为LOV(可选值列表)列——这类列的可选值范围因国家而异,部分仅适用于单一国家,部分覆盖多个或全部国家;同时LOV列分为必填和非必填两类,用于判断对应字段是否允许空值。

需借助另一份映射DataFrame完成以下操作:

  • 检查主DataFrame中的字段值是否存在于映射DataFrame的对应可选值范围内;
  • 若存在,则将该值替换为映射DataFrame中对应的编码;
  • 若主DataFrame中的值不在对应映射列表内,需在主DataFrame中新增名为错误信息的列,记录出错的字段名(若多个字段出错,则以列表形式存储)。

示例输入DataFrame

ID  国家  合同类型       岗位类型
1   CZ  Permanent     BOFF
1   ES  Fixed-term    .
2   CZ  Contractor    Front-Office
3   PT  Permanent   
4   PT  2022-01-01    Employee
4   PT  Fixed-term    Office
4   ES                Employee
5   SK  Permanent     Employee

映射DataFrame

国家  字段     可选值          编码      是否必填
CZ  合同类型  Permanent       PE        是
CZ  合同类型  Fixed-term      FX        是
CZ  合同类型  Contractor      CT        是
ES  合同类型  Permanent       PERMA     否
SK  合同类型  Permanent       PER-01    是
SK  合同类型  Fixed-term      FIX-01    是
ES  岗位类型  Office          OFF       是
CZ  岗位类型  Back-Office     BOFF      是 
CZ  岗位类型  Front-Office    FOFF      是 
PT  岗位类型  Employee        EMP       否
PT  岗位类型  Front-Office    FRONT     否

处理后结果DataFrame

ID  国家  合同类型       岗位类型  错误信息
1   CZ  PE          BOFF    ['岗位类型']
1   ES  Fixed-term  .       ['合同类型','岗位类型']
2   CZ  CT          FOFF    
3   PT  Permanent       
4   PT  2022-01-01  FRONT   ['岗位类型']
4   PT  Fixed-term  Office  ['岗位类型']
4   ES  Employee            ['合同类型','岗位类型']
5   SK  PER-01      Employee    

内容的提问来源于Stack Exchange,提问作者Paulo Cortez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 13:57:44