best way to transfer data from flask to d3
<p>I have csv tables, processed in Pandas, that I would like to serve from Flask to the browser so that I can use d3 to display the information. How do I transfer the data from Flask to the browser? </p>

<p>Use the to_csv method of the Pandas dataframe, and return that from your flask server:</p>

<pre><code># app.py
@app.route('/my/data/entpoint')
def get_d3_data():
    df = pandas.DataFrame(...) # Constructed however you need it
    return df.to_csv()
</code></pre>

<p>Then on the front end, direct d3.tsv to your endpoint above:</p>

<pre><code>&lt;!-- page.html --&gt;
&lt;script&gt;
d3.tsv("/my/data/endpoint", function(data) {
  console.log(data); // Do something with data
});
&lt;/script&gt;
</code></pre>

javascript python d3.js flask routing