score:4

you don't need (or want) to write anything to a file here. you can create the json and return it from a flask method:

from flask import flask, response

@app.route('/getmyjson')
def getmyjson():
    json = dataframe.to_json(orient='records', date_format='iso')
    response = response(response=json, status=200, mimetype="application/json")
    return(response)

the d3 then becomes:

d3.json("/getmyjson", function (error, data) {
  // ...
  // operations with those data
  // ...
}

Related Query

More Query from same tag