pythondataframecudf

Multiply two df in GPU (cudf)


I have two dataframe in GPU. I want to multiply each element of each df. Here is a simple version of my dataframes:

import cudf
a = cudf.DataFrame()
a['c1'] = [1, 2]
b = cudf.DataFrame()
b['c1'] = [2, 5]

I want to see this output:

    c1
0   2
1   10

I am using a.multiply(b), however, I get error;AttributeError: DataFrame object has no attribute multiply

Can you please help me with that? Thanks.


Solution

  • In the current version of cuDF, this works as expected. You may be using an older version in which this API was not yet implemented. I recommend upgrading.

    import cudf
    
    a = cudf.DataFrame()
    a['c1'] = [1, 2]
    b = cudf.DataFrame()
    b['c1'] = [2, 5]
    
    print(a.multiply(b))
       c1
    0   2
    1  10