pandas 1.4.2

NotesParametersReturnsBackRef
explode(self, ignore_index: 'bool' = False) -> 'Series'
versionadded

Notes

This routine will explode list-likes including lists, tuples, sets, Series, and np.ndarray. The result dtype of the subset rows will be object. Scalars will be returned unchanged, and empty list-likes will result in a np.nan for that row. In addition, the ordering of elements in the output will be non-deterministic when exploding sets.

Reference the user guide <reshaping.explode> for more examples.

Parameters

ignore_index : bool, default False

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

versionadded

Returns

Series

Exploded lists to rows; index will be duplicated for these rows.

Transform each element of a list-like to a row.

See Also

DataFrame.explode

Explode a DataFrame from list-like columns to long format.

DataFrame.melt

Unpivot a DataFrame from wide format to long format.

Series.str.split

Split string values on specified separator.

Series.unstack

Unstack, a.k.a. pivot, Series with MultiIndex to produce DataFrame.

Examples

This example is valid syntax, but we were not able to check execution
>>> s = pd.Series([[1, 2, 3], 'foo', [], [3, 4]])
... s 0 [1, 2, 3] 1 foo 2 [] 3 [3, 4] dtype: object
This example is valid syntax, but we were not able to check execution
>>> s.explode()
0      1
0      2
0      3
1    foo
2    NaN
3      3
3      4
dtype: object
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.frame.DataFrame.explode

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/series.py#4043
type: <class 'function'>
Commit: