我试图计算数据帧中第一列和其他列(第一列和第二列、第一列和第三列等)之间回归的滚动r平方,但当我尝试线程时,它一直告诉我错误是
TypeError: ParallelRegression() argument after * must be an iterable, not int".
我在想我该怎么解决这个问题?非常感谢!
import threading
totalThreads=3 #three different colors
def ParallelRegression(threadnum):
for i in range(threadnum):
res[:,i]=sm.OLS(df.iloc[:,0], df.iloc[:,i+1]).fit().rsquared
threads=[]
for threadnum in range(totalThreads):
t=threading.Thread(target=ParallelRegression,args=(threadnum))
threads.append(t)
t.start()
for threadnum in range(totalThreads):
threads[threadnum].join()
请参阅下面链接的图片中的数据摘要(df):
threading.Thread
类需要一个iterable参数作为args
参数。您传递的是一个args=(threadnum)
对象,您需要传递一些允许多个参数的iterable对象,即使您只想传递一个参数。args=[threadnum]
会起作用,因为这使得一个list
是可接受的。相关问题 更多 >
编程相关推荐