I came across this problem at work today and I would like to know if there is an efficient way to do this.
Basically I have a dataframe which look like this
df = pd.DataFrame([1,2,3], columns = ['a'])
I also have a function that returns a tuple. (Make note that this is only a minimal example, my problem is different)
compute = lambda x: (2*x, 3*x)
I need to find a way to do something that would ideally look like this:
(df['b'], df['c']) = df['a'].apply(compute)
Unfortunately, this syntax doesn't work and I can't wrap my head around another way to do it.
The only similar problem is this , but the solution seems really 'hacky' and I am convinced there is a better way to do it.
Thank you!!