当前位置: 代码迷 >> 综合 >> 【pandas】DataFrame的apply函数
  详细解决方案

【pandas】DataFrame的apply函数

热度:57   发布时间:2024-02-10 10:38:21.0

DataFrame中的apply函数:将函数应用到由列或行形成的一维数组上。

示例,根据新增一列,其列值根据另外两列的值计算得到。

#打标签
def target(a,b,c):if a==1 or (b==1 and c>=0.5):return 1else:return 0dfTest['target'] = dfTest.apply(lambda x: target(x.question_click, x.appear,x.score), axis = 1)

 

  相关解决方案