I would like to define a function which will be applied to a dataframe whenever it will be called for a specific columns. I don't want to hard code the column names while defining the funtion. Below is my sample code. The lambda function may be complex one but I am trying with a simple one
def add(X, **args):
for arg in args:
X[arg].apply(lambda x: x + 10)
return X
But if I call this function on my function like below I am getting error though I have these columns in my dataframe.
y = add(df_final['ABC', 'XYZ'])
KeyError: ('ABC', 'XYZ')
also I tried calling like below
y = add(df_final, ['ABC', 'XYZ'])
TypeError: add() takes 1 positional argument but 2 were given
It seems that I am missing some basic things here. How to modify the above code to make it working?