用python脚本窗口小部件创建暨列



我不能用另一个累积总和创建一个新列。如果您像我这样的Python,橙色的文档很难理解。

这是我在python脚本widget中拥有的代码

import numpy as np
## make a copy from the data that widget recieves
out_data = in_data.copy()
## compute cumulative sum of column values
newCumsumColValues = np.cumsum(out_data[:,('myCumsumcolTarget')])                
## i got the values
print(newCumsumColValuesl)        
## i need to create a new column with the values in out_data
## i've tried to update column values first to test
## with an static value column values updated to 8
out_data[:,'myCumsumcolTarget'] = 8    
## with newCumsumColValue is NOT working
out_data[:,'myCumsumcolTarget'] = newCumsumColValues

这些示例很难理解:

https://docs.orange.biolab.si/3/visual-programming/widgets/data/pythonscript.htmlhttps://docs.orange.biolab.si/3/data-mining-library/tutorial/data.html#exploration-of-the-data-data-domain

预先感谢文斯。

尝试:

out_data.X[:, i] = newCumsumColValues

i

out_data.domain.index(out_data.domain['myCumsumcolTarget'])

此代码有点复杂,但起作用。

最新更新