Search code examples
pandasdataframecondacudf

Expected a bytes object, got a 'int' object erro with cudf


I have a pandas dataframe, all the columns are objects type. I am trying to convert it to cudf by typing cudf.from_pandas(df) but I have this error:

ArrowTypeError: Expected a bytes object, got a 'int' object

I don't understand why even that columns are string and not int. My second question is how to append to a cudf a new element ( like pandas : df. append())


Solution

  • cudf does have an df.append() capability for Series.

    import cudf
    df1 = cudf.DataFrame({'a': [0, 1, 2, 3],'b': [0.1, 0.2, 0.3, 0.4]})
    df2 = cudf.DataFrame({'a': [4, 5, 6, 7],'b': [0.1, 0.2, None, 0.3]}) #your new elements
    df3= df1.a.append(df2.a)
    df3
    

    Output:

    0    0
    1    1
    2    2
    3    3
    0    4
    1    5
    2    6
    3    7
    Name: a, dtype: int64