title: Single CSV output with data in different columns
body: <p>I have a number of CSV files with data in the first three columns only. I want to copy data from each CSV file and paste it into one single CSV file in column order. For example data from the first CSV file goes into columns 1,2 and 3 in the output file. Similarly, data from the 2nd CSV goes to columns 4,5, and 6 of the same output CSV file and so on. Any help would be highly appreciated. Thanks.</p>
  <p>I have tried the following code but it gets me the output in same columns only.</p>
  <pre><code>import glob
  import pandas as pd
  import time
  import numpy as np
  start = time.time()
  
  Filename='Combined_Data.csv'
  
  extension = 'csv'
  all_filenames = [i for i in glob.glob('*.{}'.format(extension))]
  
  for i in range(len(all_filenames)):
      data= pd.read_csv(all_filenames[i],skiprows=23)
      data= data.rename({'G1': 'CH1', 'G2': 'CH2','Dis': 'CH3'},axis=1) 
      data= data[['CH1','CH2','CH3']]
      data= data.apply(pd.to_numeric, errors='coerce')
      print(all_filenames[i])
      if i == 0:
      data.to_csv(Filename,sep=',',index=False,header=True,mode='a')
      else:
      data.to_csv(Filename,sep=',',index=False,header=False,mode='a')
  
  end = time.time()
  print((end - start),'Seconds(Execution Time)')
  </code></pre>