This is a follow up of the question here:
How to modify a dataframe using function? Lets say I want to make call .upper() on values in a
df = pd.DataFrame({'a':['london','newyork','berlin'],
'b':['uk','usa','germany'],
'c':[7,8,9]})
df1 = df[['a', 'b']]
def doSomething(x):
return x.a
print (df1.apply(doSomething, axis=1))
0 london
1 newyork
2 berlin
dtype: object
call `.upper()` on values in `a`:
return
0 LONDON
1 NEWYORK
2 BERLIN
dtype: object