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

def getMyJson():
    json = dataFrame.to_json(orient='records', date_format='iso')
    response = Response(response=json, status=200, mimetype="application/json")

The d3 then becomes:

d3.json("/getMyJson", function (error, data) {
  // ...
  // Operations with those data
  // ...

Related Query

More Query from same tag