A Python module to interact with Lariat API to access data quality metrics and diagnostics
Project description
Lariat Python SDK
A Python module to interact with Lariat API and perform various operations like querying indicators, fetching datasets, etc.
Installation
To install the package, run the following command:
pip install lariat_python_sdk
Usage
First, import the necessary components:
from lariat_client import configure, get_raw_datasets, get_datasets, get_indicators, get_indicator, query, Filter, FilterClause
import datetime
Set up your API key and application key:
API_KEY = "your-api-key"
APP_KEY = "your-app-key"
configure(api_key=API_KEY, application_key=APP_KEY)
Get raw datasets:
raw_datasets = get_raw_datasets(dataset_ids=[1, 2, 3])
Get computed datasets:
datasets = get_datasets()
Get indicators:
indicators = get_indicators(datasets=datasets)
Get a specific indicator:
indicator = get_indicator(id=1)
Query an indicator:
from_ts = datetime.datetime(2022, 1, 1)
to_ts = datetime.datetime(2022, 2, 1)
group_by = ["country"]
filter_clause = FilterClause(field="country", operator="in", values="US,UK")
query_filter = Filter(clauses=[filter_clause], operator="and")
results = query(indicator.id, from_ts, to_ts, group_by, query_filter=query_filter)
# Convert results to a DataFrame
results_df = results.to_df()
# Save results to a CSV file
results.to_csv("results.csv")
Use the RawQuery interface to add additional query arguments
Note: Query arguments attached via the RawQuery interface are subject to changes in their backend interpretation. Use with caution
import lariat_client
import datetime
lariat_client.configure(api_key="some_key", application_key="some_other_key")
indicator = lariat_client.get_indicator(id=1234)
from_ts = datetime.datetime(2023, 5, 1)
to_ts = datetime.datetime(2023, 5, 10)
filter_clause = lariat_client.FilterClause(field="country", operator="in", values="USA")
query_filter = lariat_client.Filter(clauses=[filter_clause], operator="and")
raw_query = lariat_client.RawQuery(
indicator_id=indicator.id,
from_ts=from_ts,
to_ts=to_ts,
aggregate="distinct",
query_filter=query_filter
)
raw_query.add_query_argument("x_axis", "custom_x_axis")
records = raw_query.send()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lariat_python_sdk-0.1.6.tar.gz.
File metadata
- Download URL: lariat_python_sdk-0.1.6.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58a5a83689aa6b5e41a025cd504825417e8653106f7e742bb32d465a9b264155
|
|
| MD5 |
c101f5feb5de37d260777533cf98c05a
|
|
| BLAKE2b-256 |
7f3ce32f74d252a6b8143c2a5e945328a80ded13b559bc3f867f6316d96f0560
|
File details
Details for the file lariat_python_sdk-0.1.6-py3-none-any.whl.
File metadata
- Download URL: lariat_python_sdk-0.1.6-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec9015a3fc8408a181aaab4bbf95a531f6b1862251f4dc18c8b17f0f379cb3b1
|
|
| MD5 |
5c2be107f1e9427e55f95c3e0f3a4080
|
|
| BLAKE2b-256 |
fd2630662a656d6746af3defbf2537c9347a8e071efdfa031f591587a4cd6642
|