【问题标题】:Create cumsum column with Python Script Widget in Orange使用橙色的 Python 脚本小部件创建 cumsum 列
【发布时间】:2018-04-16 23:29:11
【问题描述】:

我无法使用另一列的累积总和创建一个新列。 如果您像我一样是 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

提前致谢, 文斯。

【问题讨论】:

    标签: python orange


    【解决方案1】:

    试试:

    out_data.X[:, i] = newCumsumColValues
    

    i 在哪里

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

    这段代码有点复杂,但是可以。

    【讨论】:

    • 非常感谢@Matphy,完美运行。你说得对,有点复杂。问候。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-20
    • 2019-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-31
    相关资源
    最近更新 更多