title: DataFrame transformation in Python Pandas
body: <p>I am trying to transform a Pandas DataFrame into a new one with every item from a certain column given its own row. For example:</p>
  
  <p>Before:</p>
  
  <pre><code>   ID             Name        Date   Location
  0   0       John, Dave  01/01/1992     Mexico
  1   1              Tim  07/07/1997  Australia
  2   2       Mike, John  12/24/2012     Zambia
  3   3  Bob, Rick, Tony  05/17/2007       Cuba
  4   4            Roger  04/05/2000    Iceland
  5   5           Carlos  05/24/1995       Guam
  </code></pre>
  
  <p>Current Solution:</p>
  
  <pre><code>new_df = pd.DataFrame(columns = df.columns)
  for index,row in df.iterrows():
      new_row = pd.DataFrame(df.loc[index]).transpose()
      target_info = df.loc[index,'Name']
      if (len(target_info.split(',')) &gt; 1):
          for item in target_info.split(','):
              new_row.loc[index,'Name'] = item
             new_df = new_df.append(new_row)
      else:
          new_df = new_df.append(new_row)  
  </code></pre>
  
  <p>After:</p>
  
  <pre><code>  ID    Name        Date   Location
  0  0    John  01/01/1992     Mexico
  0  0    Dave  01/01/1992     Mexico
  1  1     Tim  07/07/1997  Australia
  2  2    Mike  12/24/2012     Zambia
  2  2    John  12/24/2012     Zambia
  3  3     Bob  05/17/2007       Cuba
  3  3    Rick  05/17/2007       Cuba
  3  3    Tony  05/17/2007       Cuba
  4  4   Roger  04/05/2000    Iceland
  5  5  Carlos  05/24/1995       Guam
  </code></pre>
  
  <p>Surely there is something more elegant?</p>