title: set an index while merging two dataframe
body: <p>I have a dataframe like this  :</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>dte</th>
  <th>res</th>
  <th>year</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1995-01-01</td>
  <td>65.3</td>
  <td>1995</td>
  </tr>
  <tr>
  <td>1995-01-02</td>
  <td>65.5</td>
  <td>1995</td>
  </tr>
  <tr>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  </tr>
  <tr>
  <td>2019-01-03</td>
  <td>55.2</td>
  <td>2019</td>
  </tr>
  <tr>
  <td>2019-01-04</td>
  <td>52.2</td>
  <td>2019</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>and I'm trying to create another file in this format :</p>
  <pre><code>| year-1995  |  res |  year-1996 |  res |  year-1997 |  res | year-1998  | res  |
  |----------- |------|------------|------|------------|------|------------|------| 
  | 1995-01-01 | 65.3 | 1996-01-01 | 70.5 | 1997-01-01 | 70.5 | 1998-01-01 | 70.5 |    
  | 1995-01-02 | 65.5 | 1996-01-02 | 68.3 | 1997-01-02 | 68.3 | 1998-01-02 | 68.3 |     
  | 1995-01-03 | 61.8 | 1996-01-03 | 65.2 | 1997-01-03 | 65.2 | 1998-01-03 | 65.2 |       
  | 1995-01-04 | 55.2 | 1996-01-04 | 60.4 | 1997-01-04 | 60.4 | 1998-01-04 | 60.4 |        
  | 1995-01-05 | 52.2 | 1996-01-05 | 55.8 | 1997-01-05 | 55.8 | 1998-01-05 | 55.8 |          
  </code></pre>
  <p>basically I want every year in a different column.</p>
  <p>Here is what I already did :</p>
  <pre><code>import pandas as pd 
  import numpy as np 
  import openpyxl as op 
  import datetime as dt 
  
  def reader(file) : 
      return pd.read_csv(file,sep=&quot;;&quot;)
  
  vierzon=reader(&quot;input/vierzon.csv&quot;) 
  output=&quot;output/writer.xlsx&quot;
  
  vierzon['dte']=pd.to_datetime(vierzon['dte'])
  vierzon['date']=vierzon['dte'].dt.date
  vierzon['year']=pd.DatetimeIndex(vierzon['date']).year
  del vierzon['date']
  
  currentYear=vierzon.iloc[0]['year']
  myDict={}
  count=0
  
  for row in vierzon.itertuples(): 
  
      if row[3]!=currentYear and count==0 :
  
          df=pd.DataFrame(myDict,index=[row.dte])
          df=df.transpose()    
          myDict={row.dte:row.res}
          currentYear=row[3]
  
      if row[3]!=currentYear and count!=0 :   
  
          df2=pd.DataFrame(myDict,index=[row.dte])
          df2=df2.transpose()
          df=df.append(df2)        
          myDict={row.dte:row.res}
          currentYear=row[3]
  
      myDict[row.dte]=row.res
  
  print(df)
  
  df.to_excel(output,sheet_name='vierzon')
  </code></pre>
  <p>when I write in my loop <code>df=pd.DataFrame(myDict,index=[row.dte])</code> and <code>df2=pd.DataFrame(myDict,index=[row.dte])</code>  it doesn't work at all.
  so i tried : <code>df=pd.DataFrame(myDict,index=[output])</code> and <code>df2=pd.DataFrame(myDict,index=[output])</code> but my years are still on the same column as my first table.</p>
  <p>I already checked, df and df2 seems fine, so maybe my issue is in my .append ?</p>
  <p>I know it's about the index, but i have no idea how to fix it, i don't understand well how it works. Can you help me ?</p>
  <p>thank you.</p>