Create multiple columns in Pandas Dataframe from one function

前端 未结 3 1907
失恋的感觉
失恋的感觉 2021-02-08 00:10

I\'m a python newbie, so I hope my two questions are clear and complete. I posted the actual code and a test data set in csv format below.

I\'ve been able to construct t

3条回答
  •  醉话见心
    2021-02-08 00:53

    If I understand you right, what you should be doing is returning a Series from your function. Something like:

    return pandas.Series({"IV": iv, "Vega": vega})
    

    If you want to put the result into new columns of the same input DataFrame, then just do:

    df[["IV", "Vega"]] = df.apply(newtonRap, axis=1)
    

提交回复
热议问题