title: How to create a dataframe column combined with multiple columns in pandas
body: <p>I have some data that tracks the changes of company names over time. However, instead of having each name change on a single row, I would like to have them concatenated all in one field. </p>
  
  <p>The <strong>input</strong> data can be built using:</p>
  
  <pre><code>#Import the modules:
  import pandas as pd
  import numpy as np
  
  #Create the empty data frame:
  df = pd.DataFrame(columns=['dt','old_name','new_name'])
  
  #Populate the data frame:
  df.loc[len(df)] = ['01/01/2001', 'AAA', 'BBB']
  df.loc[len(df)] = ['02/02/2002', 'BBB', 'CCC']
  df.loc[len(df)] = ['03/03/2003', 'CCC', 'DDD']
  
  #View the output:
  df
  </code></pre>
  
  <p>How I want the <strong>output</strong> to look like can be created using this:</p>
  
  <pre><code>#Create the empty data frame:
  end_df = pd.DataFrame(columns=['dt','name'])
  
  #Populate:
  end_df.loc[len(end_df)] = ['01/01/2001', 'AAA-BBB-CCC-DDD']
  end_df.loc[len(end_df)] = ['02/02/2002', 'AAA-BBB-CCC-DDD']
  end_df.loc[len(end_df)] = ['03/03/2003', 'AAA-BBB-CCC-DDD']
  
  #View the output:
  end_df
  </code></pre>
  
  <p><strong><em>Edit:</em></strong> I am running this code in Pyspark2 using a pandas data frame - in case that makes any difference to the syntax. 
  <strong>Also,</strong> there are multiple groups of names in my data set. By this I mean, there are more groups of name changes unrelated to the first group whose names will need to be concatenated. </p>
  
  <p><strong>Sample Grouped Input:</strong> </p>
  
  <pre><code>#Create the empty data frame:
  df = pd.DataFrame(columns=['dt','old_name','new_name'])
  
  #Populate the data frame:
  df.loc[len(df)] = ['01/01/2001', 'AAA', 'BBB']
  df.loc[len(df)] = ['02/02/2002', 'BBB', 'CCC']
  df.loc[len(df)] = ['03/03/2003', 'CCC', 'DDD']
  df.loc[len(df)] = ['02/01/2001', 'XXX', 'YYY']
  df.loc[len(df)] = ['03/02/2002', 'YYY', 'ZZZ']
  </code></pre>
  
  <p><strong>Sample Grouped Output:</strong> </p>
  
  <pre><code>#Create the empty data frame:
  end_df = pd.DataFrame(columns=['dt','name'])
  
  #Populate:
  end_df.loc[len(end_df)] = ['01/01/2001', 'AAA-BBB-CCC-DDD']
  end_df.loc[len(end_df)] = ['02/02/2002', 'AAA-BBB-CCC-DDD']
  end_df.loc[len(end_df)] = ['03/03/2003', 'AAA-BBB-CCC-DDD']
  end_df.loc[len(end_df)] = ['02/01/2001', 'XXX-YYY-ZZZ']
  end_df.loc[len(end_df)] = ['03/02/2002', 'XXX-YYY-ZZZ']
  </code></pre>
  
  <p>Let me know if you need any further clarification. </p>