title: Pandas dataframe to flask template as a json
body: <p>I try to output a pandas dataframe in a flask template. My idea was to transform it to json and then loop through the table </p>
  
  <p>I tested this </p>
  
  <pre><code>jsonfiles = df.to_json(orient='records')
  
  return render_template('index.html', ctrsuccess=jsonfiles)
  </code></pre>
  
  <p>In the template I try to output like this:</p>
  
  <pre><code>        {%if ctrsuccess %}
          &lt;div class="table-responsive"&gt;
              &lt;table class="table table-striped"&gt;
                  &lt;tbody&gt;
                      {%for ctrrow in ctrsuccess %}
                      &lt;tr&gt;
                          &lt;td&gt;{{ ctrrow['positionint'] }}&lt;/td&gt;
                      &lt;/tr&gt;
                      {%endfor%}
                  &lt;/tbody&gt;
              &lt;/table&gt;
          &lt;/div&gt;
          {%endif%}
  </code></pre>
  
  <p>In the template i get a proper looking json if i just draw ctrsuccess. But the table is empty </p>
  
  <pre><code>[{"positionint":1.0,"clicks":1138.0,"impressions":4768.0,"ctr":0.2386744966,"clickCtr10p":1251.8,"clickCtr50p":1707.0,"clickCtr100p":2276.0},{"positionint":2.0,"clicks":3160.0,"impressions":49899.0,"ctr":0.0633279224,"clickCtr10p":3476.0,"clickCtr50p":4740.0,"clickCtr100p":6320.0},{"positionint":3.0,"clicks":1255.0,"impressions":50020.0,"ctr":0.025089964,"clickCtr10p":1380.5,"clickCtr50p":1882.5,"clickCtr100p":2510.0},{"positionint":4.0,"clicks":363.0,"impressions":39077.0,"ctr":0.0092893518,"clickCtr10p":399.3,"clickCtr50p":544.5,"clickCtr100p":726.0},{"positionint":5.0,"clicks":216.0,"impressions":18419.0,"ctr":0.011727021,"clickCtr10p":237.6,"clickCtr50p":324.0,"clickCtr100p":432.0},{"positionint":6.0,"clicks":307.0,"impressions":15447.0,"ctr":0.0198744093,"clickCtr10p":337.7,"clickCtr50p":460.5,"clickCtr100p":614.0},{"positionint":7.0,"clicks":248.0,"impressions":24709.0,"ctr":0.0100368287,"clickCtr10p":272.8,"clickCtr50p":372.0,"clickCtr100p":496.0},{"positionint":8.0,"clicks":236.0,"impressions":26853.0,"ctr":0.0087885897,"clickCtr10p":259.6,"clickCtr50p":354.0,"clickCtr100p":472.0},{"positionint":9.0,"clicks":139.0,"impressions":26577.0,"ctr":0.0052300862,"clickCtr10p":152.9,"clickCtr50p":208.5,"clickCtr100p":278.0},{"positionint":10.0,"clicks":23.0,"impressions":2046.0,"ctr":0.0112414467,"clickCtr10p":25.3,"clickCtr50p":34.5,"clickCtr100p":46.0},{"positionint":null,"clicks":7085.0,"impressions":257815.0,"ctr":null,"clickCtr10p":7793.5,"clickCtr50p":10627.5,"clickCtr100p":14170.0},{"positionint":null,"clicks":null,"impressions":null,"ctr":null,"clickCtr10p":1417.0,"clickCtr50p":7085.0,"clickCtr100p":14170.0}]
  </code></pre>