How to convert column with list of values into rows in Pandas DataFrame
<p>Hi I have a dataframe like this:</p>

<pre><code>    A             B 
0:  some value    [[L1, L2]]
</code></pre>

<p>I want to change it into:</p>

<pre><code>    A             B 
0:  some value    L1
1:  some value    L2
</code></pre>

<p>How can I do that?</p>

<p>you can do it this way:</p>

<pre><code>In [84]: df
Out[84]:
               A               B
0     some value      [[L1, L2]]
1  another value  [[L3, L4, L5]]

In [85]: (df['B'].apply(lambda x: pd.Series(x[0]))
   ....:         .stack()
   ....:         .reset_index(level=1, drop=True)
   ....:         .to_frame('B')
   ....:         .join(df[['A']], how='left')
   ....: )
Out[85]:
    B              A
0  L1     some value
0  L2     some value
1  L3  another value
1  L4  another value
1  L5  another value
</code></pre>

python pandas dataframe