Transform to normal Data Frame which has row as list. Split rows to column
<p>My Data Frame output from reading a complex json looks like below.</p>

<p>Where individual row is a list within a single column.</p>

<p>Below is the sample Data Frame(<code>df</code>)</p>

<pre><code>col
[A,1,3,4,Null]
[B,4,5,6,Null]
[C,7,8,9,Null]
</code></pre>

<p>I tried to split to individual column using pandas but it didnt work as individual row itself is a list. 
I want the data frame to look like below.</p>

<pre><code>colA,colB,colC,colD,colE
A    1    3     4    Null
B    4    5     6    Null
C    7    8     9    Null
</code></pre>

<p>I dont need the column name to specified manually it can be auto-generated.</p>

<p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.from_records.html" rel="nofollow"><code>DataFrame.from_records</code></a>, but first need create nested <code>list</code> from values of column <code>col</code>:</p>

<pre><code>df = pd.DataFrame({'col':[['A',1,3,4,'Null'],['B',4,5,6,'Null'],['C',7,8,9,'Null']]})
print (df)
                  col
0  [A, 1, 3, 4, Null]
1  [B, 4, 5, 6, Null]
2  [C, 7, 8, 9, Null]

print (df.col.values.tolist())
[['A', 1, 3, 4, 'Null'], ['B', 4, 5, 6, 'Null'], ['C', 7, 8, 9, 'Null']]

df1 = pd.DataFrame.from_records(df.col.values.tolist(), 
                                columns=['colA','colB','colC','colD','colE'])

print(df1)
  colA  colB  colC  colD  colE
0    A     1     3     4  Null
1    B     4     5     6  Null
2    C     7     8     9  Null
</code></pre>

<hr>

<p>If dont need specify column names:</p>

<pre><code>df1 = pd.DataFrame.from_records(df.col.values.tolist())
print(df1)
   0  1  2  3     4
0  A  1  3  4  Null
1  B  4  5  6  Null
2  C  7  8  9  Null
</code></pre>

<p><strong>Timings</strong>:</p>

<pre><code>#len(df) = 4k
df = pd.concat([df]*1000).reset_index(drop=True)

In [80]: %timeit pd.DataFrame(df['col'].apply(pd.Series).values, columns=['colA','colB','colC','colD','colE'])
1 loop, best of 3: 753 ms per loop

In [81]: %timeit pd.DataFrame.from_records(df.col.values.tolist(), columns=['colA','colB','colC','colD','colE'])
100 loops, best of 3: 3.73 ms per loop
</code></pre>

python list pandas dataframe multiple-columns