title: How to format float to 4 decimal places within json dumps?
body: <p>Have difficulty in converting <code>pf_stats</code> output to have 4 decimal places:</p>
  
  <pre><code>import json
  import numpy as np
  
  
  def run_simulation(H, P, B, C, mu, sigma, T, L):
  
      x = normal(mu, sigma, (L, T))
  
      pf_all = []
  
      for xs in x:
          pf = calc(xs, H, P, B, C)
          pf_all.append(pf)
  
      pf_means = np.mean(pf_all, axis=1)
  
      funcs = [np.average, np.median, np.min, np.max]
      func_names = ["Average", "Median", "Min", "Max"]
  
      pf_stats= [f(pf_means) for f in funcs]
  
  
      return json.dumps({
          'functions' : func_names,
          'pf_stats' : pf_stats
      })
  </code></pre>