# explode

> For the complete documentation index, see [llms.txt](https://kotlin.github.io/dataframe/llms.txt).

Splits list-like values in given columns and spreads them vertically. Values in other columns are duplicated.

API reference: [explode](https://kotlin.github.io/dataframe/api-docs/core/org.jetbrains.kotlinx.dataframe.api/explode.html)

```TEXT
explode(dropEmpty = true) [ { columns } ]
```

Reverse operation: [implode](implode.html)

See [column selectors](columnselectors.html) for how to select the columns for this operation.

Parameters:

* `dropEmpty` — if `true`, removes rows with empty lists or [DataFrame](dataframe.html) objects. Otherwise, they will be exploded into `null`.

Available for:

* [DataFrame](dataframe.html)

* [FrameColumn](datacolumn.html#framecolumn)

* `DataColumn<Collection>`

Exploded columns will change their types:

* `List<T>` to `T`

* [DataFrame](dataframe.html) to [DataRow](datarow.html)

Exploded [FrameColumn](datacolumn.html#framecolumn) will be converted into [ColumnGroup](datacolumn.html#columngroup).

Explode [DataFrame](dataframe.html):

Strings:

```KOTLIN
val df = dataFrameOf("a", "b")(
    1, listOf(1, 2),
    2, listOf(3, 4),
)

df.explode("b")
```

When several columns are exploded in one operation, lists in different columns will be aligned.

```KOTLIN
val df = dataFrameOf(
    "a" to columnOf(listOf(1, 2), listOf(3, 4, 5)),
    "b" to columnOf(listOf(1, 2, 3), listOf(4, 5)),
)
df.explode("a", "b")
```

Explode [DataColumn&lt;Collection&gt;](datacolumn.html):

```KOTLIN
val col by columnOf(listOf(1, 2), listOf(3, 4))

col.explode()
```

Explode [FrameColumn](datacolumn.html#framecolumn):

```KOTLIN
val col by columnOf(
    dataFrameOf("a", "b")(1, 2, 3, 4),
    dataFrameOf("a", "b")(5, 6, 7, 8),
)

col.explode()
```

