Let's say I have a dataframe like this:
columnA columnB 0 10 90 1 83 17 2 30 21 ... and I have a function like this:
def my_func(a, b): value = #do some calculation return value Now I want to get a new column columnC for my dataframe based on the calculations of the function.
Obviously, df["columnC"]= my_func(df["columnA"], df["columnB"]) does not work.
What can I do to add the column?
apply:df['C'] = df.apply(my_func)my_funcdoes?