Python Pandas-将从函数返回的元组保存到2个单独的列中

I am using pandas to run a function on each row of a dataframe and then save the result into a new column. The problem I am having is my function returns a tuple. The function returns for example...

(2345,4837)

我通过执行以下操作将其保存为新列:

myDataFrame['col5'] = myDataFrame.apply(muFunction, axis=1)

这有效,但是我如何将收益分成两列,例如...

myDataFrame['col5'] = myDataFrame.apply(muFunction, axis=1)
myDataFrame['col6'] = myDataFrame.apply(muFunction, axis=1)

但是在col5中的元组的第一部分和在col6中的第二部分,有人有例子吗?

评论