title: Use Flask to convert a Pandas dataframe to CSV and serve a download
body: <p>I have a Pandas dataframe in my Flask app that I want to return as a CSV file.</p>
  
  <pre><code>return Response(df.to_csv())
  </code></pre>
  
  <p>The problem is that the output appears in the browser instead of downloading as a separate file. How can I change that?</p>
  
  <p>I tried the following as well but it just gave empty output.</p>
  
  <pre><code>response = make_response(df.to_csv())
  response.headers['Content-Type'] = 'text/csv'
  return Response(response)
  </code></pre>