How to do 'lateral view explode()' in pandas : <p>I want to do this :</p>

<pre><code># input:
        A   B
0  [1, 2]  10
1  [5, 6] -20
# output:
   A   B
0  1  10
1  2  10
2  5 -20
3  6 -20
</code></pre>

<p>Every column A's value is a list</p>

<pre><code>df = pd.DataFrame({'A':[[1,2],[5,6]],'B':[10,-20]})
df = pd.DataFrame([[item]+list(df.loc[line,'B':]) for line in df.index for item in df.loc[line,'A']],
                  columns=df.columns)
</code></pre>

<p>The above code can work but it's very slow</p>

<p>is there any clever method?</p>

<p>Thank you</p>
