From 41e2f21fe7559cf205b1739cfa4967563f1eb699 Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 17 Aug 2020 13:57:18 +0530 Subject: Convert the django orm values to list for pandas --- statistics_app/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'statistics_app/views.py') diff --git a/statistics_app/views.py b/statistics_app/views.py index 3c9fcae..3e45495 100644 --- a/statistics_app/views.py +++ b/statistics_app/views.py @@ -75,13 +75,15 @@ def workshop_public_stats(request): "instructor__last_name", "coordinator__profile__state", "date", "status" ) - df = pd.DataFrame(data) + df = pd.DataFrame(list(data)) if not df.empty: df.status.replace( [0, 1, 2], ['Pending', 'Success', 'Reject'], inplace=True ) - codes, states = list(zip(*states)) - df.coordinator__profile__state.replace(codes, states, inplace=True) + codes, states_map = list(zip(*states)) + df.coordinator__profile__state.replace( + codes, states_map, inplace=True + ) response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = f'attachment; filename=statistics.csv' output_file = df.to_csv(response, index=False) -- cgit