Tutorials References Exercises Sign Up Menu
Create Website Get Certified Pro

Pandas DataFrame explode() Method

❮ DataFrame Reference


Turn every element in the "Typ" column into a row:

import pandas as pd

data = {
  "Brand": ["Ford", "Ford", "Ford"],
  "Model": ["Sierra", "F-150", "Mustang"],
  "Typ" : ["2.0 GL", "Raptor", ["Mach-E", "Mach-1"]]
df = pd.DataFrame(data)

newdf = df.explode('Typ')
Try it Yourself »

Definition and Usage

The explode() method converts each element of the specified column(s) into a row.


dataframe.explode(column, ignore_index)


The parameter ignore_index is a keyword argument.

Parameter Value Description
column String
Required. Specifies the column to explode
ignore_index True
Optional, default False. Specifies whether to ignore index or not. If True the original indexes are ignored, and replaced by 0, 1, 2 etc.

Return Value

A DataFrame with the exploded result.

This method does not change the original DataFrame.

❮ DataFrame Reference