应用函数到每一行
代码示例:
import pandas as pd df = pd.DataFrame({'a': [1, 4, 7], 'b': [2, 5, 8], 'c': [3, 6, 9]})
def sum_row(row): return row['a'] + row['b'] + row['c']
df['sum'] = df.apply(sum_row, axis=1)
print(df)
上一篇:applyfiltertothelaravelmodel
下一篇:Applyfunctionwithseveralinputparameterstovector