对于“ true” /“ false”值,将cuDF数据帧列转换为1或0

时间:2019-08-22 14:12:16

标签: rapids cudf

我正在使用RAPIDS(0.9版)泊坞窗容器。如何使用RAPIDS cuDF执行以下操作?

df['new_column'] = df['column_name'] > condition df[['new_column']] *= 1

1 个答案:

答案 0 :(得分:0)

您可以使用与熊猫相同的方式进行操作。

import cudf

df = cudf.DataFrame({'a':[0,1,2,3,4]})
df['new'] = df['a'] >= 3
df['new'] = df['new'].astype('int') # could use int8, int32, or int64

# could also do (df['a'] >= 3).astype('int')
df

    a   new
0   0   0
1   1   0
2   2   0
3   3   1
4   4   1