- API reference
- Series
- pandas.Serie...
pandas.Series.explode#
- Series.explode(ignore_index=False)[source]#
Transform each element of a list-like to a row.
- Parameters:
- ignore_indexbool, default False
If True, the resulting index will be labeled 0, 1, …, n - 1.
- Returns:
- Series
Exploded lists to rows; index will be duplicated for these rows.
See also
Series.str.split
Split string values on specified separator.
Series.unstack
Unstack, a.k.a. pivot, Series with MultiIndex to produce DataFrame.
DataFrame.melt
Unpivot a DataFrame from wide format to long format.
DataFrame.explode
Explode a DataFrame from list-like columns to long format.
Notes
This routine will explode list-likes including lists, tuples, sets,Series, and np.ndarray. The result dtype of the subset rows willbe object. Scalars will be returned unchanged, and empty list-likes willresult in a np.nan for that row. In addition, the ordering of elements inthe output will be non-deterministic when exploding sets.
Referencethe user guide for more examples.
Examples
>>>s=pd.Series([[1,2,3],'foo',[],[3,4]])>>>s0 [1, 2, 3]1 foo2 []3 [3, 4]dtype: object
>>>s.explode()0 10 20 31 foo2 NaN3 33 4dtype: object