pyspark.pandas.DataFrame.explode¶
- 
DataFrame.explode(column: Union[Any, Tuple[Any, …]]) → pyspark.pandas.frame.DataFrame[source]¶ Transform each element of a list-like to a row, replicating index values.
- Parameters
 - columnstr or tuple
 Column to explode.
- Returns
 - DataFrame
 Exploded lists to rows of the subset columns; index will be duplicated for these rows.
See also
DataFrame.unstackPivot a level of the (necessarily hierarchical) index labels.
DataFrame.meltUnpivot a DataFrame from wide format to long format.
Examples
>>> df = ps.DataFrame({'A': [[1, 2, 3], [], [3, 4]], 'B': 1}) >>> df A B 0 [1, 2, 3] 1 1 [] 1 2 [3, 4] 1
>>> df.explode('A') A B 0 1.0 1 0 2.0 1 0 3.0 1 1 NaN 1 2 3.0 1 2 4.0 1