cudf.DataFrame.explode#

DataFrame.explode(column, ignore_index=False)[source]#

Transform each element of a list-like to a row, replicating index values.

Parameters:
columnstr

Column to explode.

ignore_indexbool, default False

If True, the resulting index will be labeled 0, 1, …, n - 1.

Returns:
DataFrame

Examples

>>> import cudf
>>> df = cudf.DataFrame({
...     "a": [[1, 2, 3], [], None, [4, 5]],
...     "b": [11, 22, 33, 44],
... })
>>> df
           a   b
0  [1, 2, 3]  11
1         []  22
2       None  33
3     [4, 5]  44
>>> df.explode('a')
      a   b
0     1  11
0     2  11
0     3  11
1  <NA>  22
2  <NA>  33
3     4  44
3     5  44