def?checkformat(df):
????if?df['A']?==?0:
????????return?0
????else:
????????return?np.log(df['A']?/?df['B'])
df['C']?=?df.apply(checkformat,?axis=1)請(qǐng)問(wèn)以上代碼,改成apply調(diào)用lambda函數(shù)怎么用?謝謝!
1 回答

啊成啊
TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊
lambda x: np.log(x['A'] / x['B']) if x['A'] != 0 else 0,不知道對(duì)不對(duì)
添加回答
舉報(bào)
0/150
提交
取消