【问题标题】:GraphLab .apply to sframeGraphLab .apply 到 sframe
【发布时间】:2016-04-17 05:23:01
【问题描述】:

我试图在图形实验室创建一个非常简单的 .apply 应用程序,但我对它为什么不起作用感到困惑。

def myfunc (x):
if(x == 0):
    x = -1

sa = SArray([0,0,0,1,1], dtype=int)

sa.apply(myfunc, dtype = int)

我的输出是

[None, None, None, None, None]

为什么不是 [-1, -1, -1, 1, 1],我该如何解决?

【问题讨论】:

    标签: python-2.7 graphlab


    【解决方案1】:

    我让它工作了

    sa.apply(lambda sa : -1 if sa ==0 else sa)
    

    但我仍然不确定为什么我上面尝试的方法不起作用...

    【讨论】:

      猜你喜欢
      • 2017-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多