Django Rest Framework make model calculations using pandas or not (seeking efficient way)

Viewed 78

I am using django_rest_framework for a web application. I have created the necessary API end points for all the necessary CRUD operations for the respective tables.

Now I want to perform calculations on the data of multiple tables and send the calculated result as a Response for the frontend to process.

I could think of two ways of doing this, which would be more efficient (or the correct (the Django way) way to do it, if any):

1. Calculations using Pandas

  • Create a view which will be called with a GET request
  • Get the querysets of data from the necessary tables
  • Convert them to pandas DataFrames
  • Perform the necessary calculations
  • Reconvert the DataFrame to a JSON object and return a Response

2. Create a Separate Model, Serializer and View for the Calculations

If there is some other library or method that can do this, please provide some suggestions

0 Answers
Related