我有一个函数,返回多个系列,并希望重命名系列名称。你知道吗
def myfunction(MyDataFrame, UniqueID, Var1, Var2):
RunningSumA = MyDataFrame.groupby([UniqueID])[Var1].cumsum().reset_index()
RunningSumB = MyDataFrame.groupby([UniqueID])[Var2].cumsum().reset_index()
return pd.Series([RunningSumA, RunningSumB])
Result = myfunction(MyDataFrame, UniqueID, Var1, Var2)
当我查看结果系列的前几行时,结果如下:
Result[0].head()
index 0
0 216646 0
1 216647 0
2 216648 0
3 216649 0
4 216650 0
我想将index
和0
重命名为函数中有意义的内容。我试着重新命名这些列,但无法重新命名。我该怎么做?你知道吗
^{} 采用填充列名的name参数:
相关问题 更多 >
编程相关推荐