title: Flatten pandas data frame with a JSON column
body: <p>I have a <strong>very large</strong> dataset in CSV format in which one column is a JSON string. I want to read this information into a <strong>flat</strong> Pandas data frame. How can I achieve this efficiently?</p>
  
  <p>Input CSV:</p>
  
  <pre><code>col1,col2,col3,col4
  1,Programming,"{""col3_1"":null,""col3_2"":""Java""}",11
  2,Sport,"{""col3_1"":null,""col3_2"":""Soccer""}",22
  3,Food,"{""col3_1"":null,""col3_2"":""Pizza""}",33 
  </code></pre>
  
  <p>Expected DataFrame:</p>
  
  <pre><code>+---------------------------------------------------------------+
  |   col1    |    col2     |   col3_1    |   col3_2  |   col4    |
  +---------------------------------------------------------------+
  |    1      | Programming |    None     |    Java   |    11     |
  |    2      |    Sport    |    None     |   Soccer  |    22     |
  |    3      |    Food     |    None     |   Pizza   |    33     |
  +---------------------------------------------------------------+
  </code></pre>
  
  <p>I can currently get the expected output using the following code. I just want to know if there is a more efficient way to achieve the same.</p>
  
  <pre><code>import json
  import pandas
  dataset = pandas.read_csv('/dataset.csv')
  dataset['col3'] = dataset['col3'].apply(json.loads)
  dataset['col3_1'] = dataset['col3'].apply(lambda row: row['col3_1'])
  dataset['col3_2'] = dataset['col3'].apply(lambda row: row['col3_2'])
  dataset = dataset.drop(columns=['col3'])
  </code></pre>