python - 使用橙色的 Python 脚本小部件创建 cumsum 列

标签 python orange

我无法使用另一列的累积和来创建一个新列。 如果你像我一样刚接触 Python,橙色文档会很难理解。

这是我的 Python 脚本小部件中的代码

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.html https://docs.orange.biolab.si/3/data-mining-library/tutorial/data.html#exploration-of-the-data-domain

提前致谢, 文斯。

最佳答案

尝试:

out_data.X[:, i] = newCumsumColValues

其中i

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

这段代码有点复杂,但它可以工作。

关于python - 使用橙色的 Python 脚本小部件创建 cumsum 列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46565246/

相关文章:

python - Pyglet OpenGL 设置雾颜色

python - 打乱两个 python 列表

machine-learning - 测试和分数小部件 - 结果发生变化吗?

python - 使用以前保存的模型获得测试数据的分类准确性

python - 更新附加组件需要重新安装 Orange3

python - 需要 py.test 在 python 日志记录模块的日志文件中记录断言错误

python - Quantlib 1.14 和 Quantlib1.14-SWIG : versions of Visual C++ prior to VC++10 (2010) are no longer supported

python - 从字典 python 中创建所有可能的句子

python - 我可以使用Orange CN2分类器只学习一类的规则吗?

Python,排序列表