Skip to content

Instantly share code, notes, and snippets.

View ReedJessen's full-sized avatar

Reed Jessen ReedJessen

View GitHub Profile
@ReedJessen
ReedJessen / gist:5abb06f78c045573d93c7c570e887e4b
Created April 9, 2019 17:44 — forked from jonperron/gist:733c3ead188f72f0a8a6f39e3d89295d
Serve pandas dataframe as csv with Django
from django.http import HttpResponse
import pandas as pd
def foo():
your_dataframe = pd.Dataframe()
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename=filename.csv'
results.to_csv(path_or_buf=response,sep=';',float_format='%.2f',index=False,decimal=",")