import cudf # create a DataFrame df = cudf.DataFrame({'col1': [2, 1, 3], 'col2': ['b', 'a', 'c']}) # sort by col1 df = df.sort_values('col1') print(df)
col1 col2 1 1 a 0 2 b 2 3 c
import cudf # create a DataFrame df = cudf.DataFrame({'col1': ['a', 'b', 'a', 'b'], 'col2': [1, 2, 3, 4]}) # group by col1 and sum col2 grouped_df = df.groupby('col1').agg({'col2': 'sum'}) print(grouped_df)
col2 col1 a 4 b 6In both examples, we imported the `cudf` library and created a `DataFrame` object using the `cudf.DataFrame()` method. We then performed operations on the `DataFrame` object, such as sorting or grouping, using methods like `sort_values()` and `groupby()`.