In [1]:
import pandas as pd
df = pd.DataFrame([['AA', 1],['BB', 2],['CC', 3]], columns = ['name','value'])
In [2]:
df
Out[2]:
In [3]:
def function_1(val_1, val_2):
return val_1 + str(val_2)
In [4]:
df['col_a'] = df.apply(lambda row: function_1(row['name'], row['value']), axis=1)
In [5]:
df
Out[5]:
In [6]:
def function_2(row):
return row['value'] * 2
In [7]:
df['col_b'] = df.apply(lambda row: function_2(row), axis=1)
In [8]:
df
Out[8]: