1

I am using RAPIDS (0.9 release) docker container. How can I do the following with RAPIDS cuDF?

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

rnyai
  • 25
  • 3

1 Answers1

1

You can do this in the same way as with pandas.

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
Nick Becker
  • 4,059
  • 13
  • 19