w3resource

Pandas Series: explode() function

Explode list-likes including lists, tuples, Series, and np.ndarray

The explode() function is used to transform each element of a list-like to a row, replicating the index values.

Syntax:

Series.explode(self) → 'Series'
Pandas Series explode image

Returns: Series- Exploded lists to rows; index will be duplicated for these rows.

Notes:

This routine will explode list-likes including lists, tuples, Series, and np.ndarray. The result dtype of the subset rows will be object. Scalars will be returned unchanged. Empty list-likes will result in a np.nan for that row.

Example:


Download the above Notebook from here.



Inviting useful, relevant, well-written and unique guest posts