title: Creating a dataframe from monthly values which dont start on january
body: <p>So, i have some data in list form, such as:</p>
  <pre><code>Q=[2,3,4,5,6,7,8,9,10,11,12]                                     #values
  M=[11,0,1,2,3,4,5,6,7,8,9]                                       #months
  Y=[2010,2011,2011,2011,2011,2011,2011,2011,2011,2011,2011]       #years
  </code></pre>
  <p>And i want to get a dataframe, with one row per year, and one column per month, adding the data of Q on the positions given by M and Y.</p>
  <p>so far i have tried a couple of things, my current code is as follows:</p>
  <pre><code>def save_data(data_list,year_info,month_info):
      
      #how many datapoints
      n_data=len(data_list)
      
      #how many years
      y0=year_info[0]
      yf=year_info[n_data-1]
      n_years=yf-y0+1
      
      #creating the list i want to fill out
      df_list=[[math.nan]*12]*n_years
      
      ind=0
      for y in range(n_years):
          for m in range(12):
              if ind&lt;len(data_list):
                  if year_info[ind]-y0==y and month_info[ind]==m:
                      df_list[y][m]=data_list[ind]
                      ind+=1
      
          
      df=pd.DataFrame(df_list)
      
      return df
  </code></pre>
  <p>I get this output:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th>0</th>
  <th>1</th>
  <th>2</th>
  <th>3</th>
  <th>4</th>
  <th>5</th>
  <th>6</th>
  <th>7</th>
  <th>8</th>
  <th>9</th>
  <th>10</th>
  <th>11</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td><strong>0</strong></td>
  <td>3</td>
  <td>4</td>
  <td>5</td>
  <td>6</td>
  <td>7</td>
  <td>8</td>
  <td>9</td>
  <td>10</td>
  <td>11</td>
  <td>12</td>
  <td>nan</td>
  <td>2</td>
  </tr>
  <tr>
  <td><strong>1</strong></td>
  <td>3</td>
  <td>4</td>
  <td>5</td>
  <td>6</td>
  <td>7</td>
  <td>8</td>
  <td>9</td>
  <td>10</td>
  <td>11</td>
  <td>12</td>
  <td>nan</td>
  <td>2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>And i want to get:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th></th>
  <th>0</th>
  <th>1</th>
  <th>2</th>
  <th>3</th>
  <th>4</th>
  <th>5</th>
  <th>6</th>
  <th>7</th>
  <th>8</th>
  <th>9</th>
  <th>10</th>
  <th>11</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td><strong>0</strong></td>
  <td>nan</td>
  <td>nan</td>
  <td>nan</td>
  <td>nan</td>
  <td>nan</td>
  <td>nan</td>
  <td>nan</td>
  <td>nan</td>
  <td>nan</td>
  <td>nan</td>
  <td>nan</td>
  <td>2</td>
  </tr>
  <tr>
  <td><strong>1</strong></td>
  <td>3</td>
  <td>4</td>
  <td>5</td>
  <td>6</td>
  <td>7</td>
  <td>8</td>
  <td>9</td>
  <td>10</td>
  <td>11</td>
  <td>12</td>
  <td>nan</td>
  <td>nan</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I have tried doing a bunch of diferent things, but so far nothing has worked, I'm wondering if there's a more straightforward way of doing this, my code seems to be overwriting in a weird way, i do not know for instance why is there a 2 on the last value of second row, since that's the first value of my list.</p>
  <p>Thanks in advance!</p>