Att, I want to create multiple columns from lambda function\'s multiple return values in python DataFrame.
Similar with the last line of my demo code.
Is there
One way would be to wrap the return value in pd.Series in order to assign to new dataframe columns.
pd.Series
g = lambda x: pd.Series(f_polyfit(x.y1, x.y2, x.y3, x.y5, x.y5, degree=1)) df[['slope', 'R2']] = df.apply(g, axis=1)