Creating arrays and DataFrames
When numerical algorithms require some arrays to store data, a module called NumPy, short for Numerical Python, is a good resource for utility functions, objects, and classes that are used to create, transform, and manipulate arrays.
The module is best known for its n-dimensional arrays or ndarrays, which consume less memory storage than the typical Python lists. An ndarray
incurs less overhead when performing data manipulation than executing the list operations in totality. Moreover, ndarray
is strictly heterogeneous, unlike Python’s list collections.
But before we start our NumPy-FastAPI service implementation, we need to install the numpy
module using the pip
command:
pip install numpy
Our first API service will process some survey data and return it in ndarray
form. The following get_respondent_answers()
API retrieves a list of survey data from PostgreSQL through Piccolo and transforms the list of data into an ndarray
:
from survey...