title: Concatenate related fields and replace within data frame
body: <p>I'm in the process of concatenating two related fields throughout a large dataset. I feel like I have most of what I need but can't concat the fields properly. </p>
  
  <p>dataframe: </p>
  
  <pre><code>id| date1foo| time1bar| date2foo| time2bar| date3foo | time3bar
  --|---------|---------|---------|---------|----------|--------
  2 |1/4/2017 |01:03:45 |1/4/2017 |01:03:45 |1/4/2019  |12:44:45
  3 |2/4/2017 |03:12:32 |2/4/2017 |03:16:23 |3/4/2019  |22:32:55
  4 |2/5/2017 |04:11:54 |7/5/2017 |06:23:31 |2/19/2019 |19:03:11
  5 |2/6/2017 |02:15:34 |9/15/2017|01:12:32 |3/15/2019 |11:11:11
  6 |3/17/2017|04:44:12 |10/3/2017|07:19:52 |4/4/2019  |07:03:14
  </code></pre>
  
  <p>I need to replace these fields with new merged fields. So: </p>
  
  <pre><code>id| datetime1        | datetime2        | datetime3   
  --|------------------|------------------|------------------|
  2 |1/4/2017 01:03:45 |1/4/2017 01:03:45 |1/4/2019 12:44:45
  3 |2/4/2017 03:12:32 |2/4/2017 03:16:23 |3/4/2019 22:32:55
  4 |2/5/2017 04:11:54 |7/5/2017 06:23:31 |2/19/2019 19:03:11
  5 |2/6/2017 02:15:34 |9/15/2017 01:12:32|3/15/2019 11:11:11
  6 |3/17/2017 04:44:12|10/3/2017 07:19:52|4/4/2019 07:03:14
  </code></pre>
  
  <p>I feel like I'm getting close with what I have below. </p>
  
  <p>code: </p>
  
  <pre><code>pattern_date = re.compile("date[0-9]{1,2}foo")
  pattern_time = re.compile("time[0-9]{1,2}bar")
  
  cols_date = [pattern_date.match(x).group() for x in df.columns if
          pattern_date.match(x) is not None]
  
  cols_time = [pattern_time.match(x).group() for x in df.columns if
          pattern_time.match(x) is not None]
  
  
  df[cols_time] = df[cols_date].applymap(lambda x: str(x) + [i for i in df[cols_date]])
  
  # renaming fields code would go here
  </code></pre>
  
  <p>What am I missing here? Is there a better way to do this? Any help would be much appreciated. </p>
  
  <p>Thanks in advance!</p>