Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({'P': [[2, 3, 4], 'fff', [], [4, 5]], 'Q': 2})
df
Out[2]:
P Q
0 [2, 3, 4] 2
1 fff 2
2 [] 2
3 [4, 5] 2

Pandas: DataFrame - explode.

In [3]:
df = pd.DataFrame({'P': [[2, 3, 4], 'fff', [], [4, 5]], 'Q': 2})
df.explode('P')
Out[3]:
P Q
0 2 2
0 3 2
0 4 2
1 fff 2
2 NaN 2
3 4 2
3 5 2

Pandas: DataFrame - explode new dataframe.