[英]To run a python function with multiple parameters
I have a function here:我在这里有一个功能:
def ROC(dfH, n):
M = dfH['Close'].diff(n - 1)
N = dfH['Close'].shift(n - 1)
ROC = pd.Series(M / N, name = 'ROC_' + str(n))
dfH = dfH.join(ROC)
return dfH
With the above function I want to make multiple columns by changing the value of n so i run the code使用上述函数,我想通过更改 n 的值来创建多列,因此我运行代码
a = (4, 8)
for j in a:
ROC(dfH, n=a)
which gets to be wrong.这是错误的。 please help thanks in advance.
请帮助提前致谢。
` `
a = (4, 8)
for j in a:
ROC(dfH, n=a)
^
You are using a instead of j in the for loop.您在 for 循环中使用a而不是j 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.