您的位置:首页 > 移动开发

pandas 使用apply同时处理两列数据

2017-10-17 21:23 621 查看
df = pd.DataFrame ({'a' : np.random.randn(6),
'b' : ['foo', 'bar'] * 3,
'c' : np.random.randn(6)})

def my_test(a, b):
return a + b

df['Value'] = df.apply(lambda row: my_test(row['a'], row['c']), axis=1)
print df


多的不说,看了代码就懂了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: