Morph DB-utils
morphdb-utils
is a Python library for manipulating and visualizing data on the Morph platform. The library provides a set of functions and decorators that support reading data, executing SQL queries, retrieving file data and visualization. Each function is designed to allow users to efficiently manipulate data and visually display results within Morph's Python cells.
Functions and decorators in the library can be called and used directly in Morph Python cells. In addition, each function can read its settings from environment variables, thus maintaining flexibility in configuration.
Main Functions
- Data loading and conversion: the ability to convert and load SQL queries and file data into a
pandas.DataFrame
. - Data Visualization: decorator that draws data as charts and outputs them in HTML format.
- Error handling: proper handling of errors that may occur during API requests and data processing, providing clear error messages.
Main functions
ref
: retrieve relevant information from a given cell name.execute_sql
: executes an SQL query and returns the result as a DataFrame.load_file_data
: read data from the given file and return it as a DataFrame.load_data
: load data based on a given data source type and return it as a DataFrame.generate_report
: Gathers the visualised data from the cells and generates an aggregated report.
Decorator
transform
: ensures that the data transformation function returnspandas.DataFrame
.visualize
: ensures that the visualization function generates a chart and displays it on the Morph dashboard.report
: displays formatted text and supports cell reporting functions.