import cudf df = cudf.DataFrame({'A': [1, 2, 3], 'B': ['foo', 'bar', 'baz'], 'C': [4.0, 5.0, 6.0]}) df.set_index('B', inplace=True) print(df)
A C B foo 1 4.0 bar 2 5.0 baz 3 6.0
import cudf df = cudf.DataFrame({'A': [1, 2, 3], 'B': ['foo', 'bar', 'baz'], 'C': [4.0, 5.0, 6.0]}) df.set_index(['B', 'A'], inplace=True) print(df)
C B A foo 1 4.0 bar 2 5.0 baz 3 6.0In this example, we set both the 'B' and 'A' columns as the multi-level index. The resulting DataFrame shows the values in columns 'B' and 'A' as the index, with column 'C' remaining unchanged. The set_index() method is part of the cudf.core package.