gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 14:40:43 35 4
gpt4 key购买 nike

我无法使用另一列的累积和来创建一个新列。如果你像我一样刚接触 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/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com