1

有人可以提供一些如何applymap在 cuDF 系列上使用该方法的示例吗?

以下是从文档中复制的,这里是文档的链接。

applymap(self, udf, out_dtype=None)
  Apply a elemenwise function to transform the values in the Column.

  The user function is expected to take one argument and return the result, which will be stored to the output Series. The function cannot reference globals except for other simple scalar objects.

  Parameters
    udf : function
      Wrapped by `numba.cuda.jit` for call on the GPU as a device function.

    out_dtype : numpy.dtype; optional
      The dtype for use in the output. By default, the result will have the same dtype as the source.

  Returns
    result: Series
      The mask and index are preserved.
4

1 回答 1

2

API 文档有一个使用最新版本https://rapidsai.github.io/projects/cudf/en/0.9.0/10min.html#Applymap的 applymap 的示例:

def add_ten(num):
    return num + 10

print(df['a'].applymap(add_ten))

通常,您传递一个期望对标量进行操作的函数,该函数被 JIT 编译成矢量化 GPU 代码,并在 GPU 上针对 Series 中的每个元素执行。

于 2019-10-11T01:27:49.163 回答