【发布时间】:2021-03-02 06:47:58
【问题描述】:
我有一个简单的代码,它采用三个数据帧(Pandas 库)并将“PROLIFIC_PID”列的值分配为该数据帧的索引
def pid_set(a, b, c): #accepts three dataframes at a time and returns dataframes with same name with PID as index
a = a.set_index('PROLIFIC_PID')
b = b.set_index('PROLIFIC_PID')
c = c.set_index('PROLIFIC_PID')
return a, b, c
我想更改上面的代码,使其获取 X 个数据帧,将 PID 设置为索引,并返回 X 个新数据帧。我尝试了上面代码的多种变体,但没有成功——尝试将索引数据帧放在列表中并仅返回列表,我尝试将“传递”作为返回等——但它们没有像我希望的那样运行。
【问题讨论】:
标签: python pandas return definition