title: How to keep rows order from a pandas DataFrame to a dict
body: <p>I have a pandas DataFrame which is already sorted by date, but I need to serialize this DataFrame to a dict python structure keeping the rows order so I can later return a JSON.</p>
  
  <p>I use a dict where i have some keys and values and I need the DataFrame to be a value. I used pd.to_dict() but this doesn't keep the row ordering. </p>
  
  <p>I've tried to use OrderedDict but I can't serialize this with json.dumps(). I'm using python 2.7.</p>
  
  <pre class="lang-py prettyprint-override"><code>dic_data = {
              'data':data.to_dict(),
              'variable':variables[variable],
              'unit':units[variable],
              'limits':{
                  'limite_superior':lim_sup,
                  'limite_inferior':lim_inf
              }
          }
  
  return HttpResponse(json.dumps(dic_data),content_type="application/json")
  </code></pre>
  
  <p>this is the datraframe data that im trying to convert into rows ordered dict to later serialize it in json </p>
  
  <pre><code>            date_time values
  202   2018-09-01 10:00    0,9
  203   2018-09-01 11:00    0,1
  204   2018-09-01 12:00    0,0
  205   2018-09-01 13:00    0,0
  206   2018-09-01 14:00    0,0
  207   2018-09-01 15:00    0,0
  208   2018-09-01 16:00    0,0
  209   2018-09-01 17:00    0,0
  </code></pre>
  
  <p>the json object that im receving from de data dataframe has the following structure:</p>
  
  <pre><code>{
      date_time:{
                  0:"2018-09-01 20:00",
                  1:"2018-09-01 21:00",
                  ....
                },
      values:{
              0:20.54,
              1:30.45,
              .....
             }
  
  }
  </code></pre>
  
  <p>and actually I need the same structure but with rows ordered.</p>